diff --git a/RGB.NET.Core/Rendering/Textures/PixelTexture.cs b/RGB.NET.Core/Rendering/Textures/PixelTexture.cs index 5c25b6a..3672e2c 100644 --- a/RGB.NET.Core/Rendering/Textures/PixelTexture.cs +++ b/RGB.NET.Core/Rendering/Textures/PixelTexture.cs @@ -43,8 +43,8 @@ public abstract class PixelTexture : ITexture { if (Data.Length == 0) return Color.Transparent; - int x = (int)MathF.Round(Size.Width * point.X.Clamp(0, 1)); - int y = (int)MathF.Round(Size.Height * point.Y.Clamp(0, 1)); + int x = (int)MathF.Round((Size.Width - 1) * point.X.Clamp(0, 1)); + int y = (int)MathF.Round((Size.Height - 1) * point.Y.Clamp(0, 1)); return GetColor(GetPixelData(x, y)); } } @@ -56,11 +56,14 @@ public abstract class PixelTexture : ITexture { if (Data.Length == 0) return Color.Transparent; - int x = (int)MathF.Round(Size.Width * rectangle.Location.X.Clamp(0, 1)); - int y = (int)MathF.Round(Size.Height * rectangle.Location.Y.Clamp(0, 1)); + int x = (int)MathF.Round((Size.Width - 1) * rectangle.Location.X.Clamp(0, 1)); + int y = (int)MathF.Round((Size.Height - 1) * rectangle.Location.Y.Clamp(0, 1)); int width = (int)MathF.Round(Size.Width * rectangle.Size.Width.Clamp(0, 1)); int height = (int)MathF.Round(Size.Height * rectangle.Size.Height.Clamp(0, 1)); + if ((width == 0) && (rectangle.Size.Width > 0)) width = 1; + if ((height == 0) && (rectangle.Size.Height > 0)) height = 1; + return this[x, y, width, height]; } }