summaryrefslogtreecommitdiff
path: root/NW4RTools/Texture.cs
diff options
context:
space:
mode:
Diffstat (limited to 'NW4RTools/Texture.cs')
-rw-r--r--NW4RTools/Texture.cs18
1 files changed, 17 insertions, 1 deletions
diff --git a/NW4RTools/Texture.cs b/NW4RTools/Texture.cs
index 954852d..2de9ad8 100644
--- a/NW4RTools/Texture.cs
+++ b/NW4RTools/Texture.cs
@@ -137,6 +137,8 @@ namespace NW4RTools {
case TextureFormat.RGB5A3:
case TextureFormat.I4:
case TextureFormat.I8:
+ case TextureFormat.IA4:
+ case TextureFormat.IA8:
// I4 is stupid and breaks my parser. I'll keep some state here
bool alreadyHaveI4Nybble = false;
byte currentI4Byte = 0;
@@ -194,6 +196,18 @@ namespace NW4RTools {
} else if (format == TextureFormat.I8) {
byte val = data.ReadByte();
*pPixel = 0xFF000000 | (uint)(val << 16) | (uint)(val << 8) | val;
+
+ } else if (format == TextureFormat.IA4) {
+ byte val = data.ReadByte();
+ uint i = (uint)(val >> 4);
+ uint a = (uint)((val & 0xF0) << 4);
+ *pPixel = (a << 24) | (i << 16) | (i << 8) | i;
+
+ } else if (format == TextureFormat.IA8) {
+ byte i = data.ReadByte();
+ byte a = data.ReadByte();
+ *pPixel = (uint)(a << 24) | (uint)(i << 16) | (uint)(i << 8) | i;
+
}
}
}
@@ -259,7 +273,9 @@ namespace NW4RTools {
image.UnlockBits(bits);
-
+
+ image.RotateFlip(RotateFlipType.RotateNoneFlipY); // TODO: remove this, and fix texcoords properly
+
BaseImage = image;
Format = format;
}