Welcome to mirror list, hosted at ThFree Co, Russian Federation.

NesTiler.git/NesTiler.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'NesTiler/FastBitmap.cs')
-rw-r--r--NesTiler/FastBitmap.cs10
1 files changed, 8 insertions, 2 deletions
diff --git a/NesTiler/FastBitmap.cs b/NesTiler/FastBitmap.cs
index 5831170..e45a899 100644
--- a/NesTiler/FastBitmap.cs
+++ b/NesTiler/FastBitmap.cs
@@ -45,9 +45,15 @@ namespace com.clusterrr.Famicom.NesTiler
}
}
- public SKColor GetPixelColor(int x, int y)
+ public SKColor GetPixelColor(int x, int y, SKColor? defaultColor = null)
{
- return pixels[((y + verticalOffset) * Width) + x];
+ var index = ((y + verticalOffset) * Width) + x;
+ if (index >= pixels.Length)
+ {
+ if (defaultColor.HasValue) return defaultColor.Value;
+ throw new IndexOutOfRangeException($"Pixel {x}x{y} is out of range");
+ }
+ return pixels[index];
}
public void SetPixelColor(int x, int y, SKColor color)