diff options
Diffstat (limited to 'NW4RTools/Texture.cs')
-rw-r--r-- | NW4RTools/Texture.cs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/NW4RTools/Texture.cs b/NW4RTools/Texture.cs index f2cf231..249af79 100644 --- a/NW4RTools/Texture.cs +++ b/NW4RTools/Texture.cs @@ -437,8 +437,10 @@ namespace NW4RTools { byte val = data.ReadByte(); for (int inX = 0; inX < 4; inX++) { - uint *pPixel = (uint*)pRow + x + (iBlockX * 4) + inX; - *pPixel = clrArray[(val >> 6) & 3]; + if ((y + (iBlockY * 4) + inY) < height && (x + (iBlockX * 4) + inX) < width) { + uint *pPixel = (uint*)pRow + x + (iBlockX * 4) + inX; + *pPixel = clrArray[(val >> 6) & 3]; + } val <<= 2; } } |