private static int[] DecodeI8Routine(byte[] I8Data, int Width, int Height) { int[] GrayscaleData = new int[I8Data.Length]; for (int i = 0; i < GrayscaleData.Length; i++) { GrayscaleData[i] = (I8Data[i] << 24) | (I8Data[i] << 16) | (I8Data[i] << 8) | I8Data[i]; } return(BlockFormat.Decode(GrayscaleData, Width, Height, 8, 4)); }
private static int[] DecodeIA8Routine(byte[] IA8Data, int Width, int Height) { int[] GrayscaleData = new int[IA8Data.Length / 2]; for (int i = 0; i < GrayscaleData.Length; i++) { int idx = i * 2; GrayscaleData[i] = (IA8Data[idx] << 24) | (IA8Data[idx + 1] << 16) | (IA8Data[idx + 1] << 8) | IA8Data[idx + 1]; } return(BlockFormat.Decode(GrayscaleData, Width, Height, 4, 4)); }
private static int[] DecodeIA4Routine(byte[] IA4Data, int Width, int Height, bool Unswizzle = true) { int[] GrayscaleData = new int[IA4Data.Length]; for (int i = 0; i < GrayscaleData.Length; i++) { byte LeftPixelValue = (byte)(((IA4Data[i] & 0xF0) | (IA4Data[i] >> 4)) & 0xFF); // Alpha byte RightPixelValue = (byte)(((IA4Data[i] << 4) | (IA4Data[i] & 0x0F)) & 0xFF); GrayscaleData[i] = (LeftPixelValue << 24) | (RightPixelValue << 16) | (RightPixelValue << 8) | RightPixelValue; } return(Unswizzle ? BlockFormat.Decode(GrayscaleData, Width, Height, 8, 4) : GrayscaleData); }
private static int[] DecodeI4Routine(byte[] I4Data, int Width, int Height, bool Unswizzle = true) { int[] GrayscaleData = new int[I4Data.Length * 2]; for (int i = 0; i < I4Data.Length; i++) { byte LeftPixelValue = (byte)((I4Data[i] & 0xF0) | (I4Data[i] >> 4)); byte RightPixelValue = (byte)((I4Data[i] << 4) | (I4Data[i] & 0x0F)); int idx = i * 2; GrayscaleData[idx] = (0xFF << 24) | (LeftPixelValue << 16) | (LeftPixelValue << 8) | LeftPixelValue; GrayscaleData[idx + 1] = (0xFF << 24) | (RightPixelValue << 16) | (RightPixelValue << 8) | RightPixelValue; } return(Unswizzle ? BlockFormat.Decode(GrayscaleData, Width, Height, 8, 8) : GrayscaleData); }
private static int[] C8ImageSubroutineDecode(byte[] C8ImageData, ushort[] Palette, int Width, int Height) { int[] RGB8Palette = new int[Palette.Length]; for (int i = 0; i < RGB8Palette.Length; i++) { RGB8Palette[i] = (int)RGB5A3.ToARGB8(Palette[i]); } byte[] UnscrambledData = BlockFormat.Decode(C8ImageData, Width, Height, 8, 4); int[] ImageData = new int[UnscrambledData.Length]; for (int i = 0; i < ImageData.Length; i++) { ImageData[i] = RGB8Palette[UnscrambledData[i]]; } return(ImageData); }
public static int[] Decode(ushort[] rgba16Data, int width, int height) { var dataOut = new int[width * height]; var position = 0; rgba16Data = BlockFormat.Decode(rgba16Data, width, height, 4, 4); for (var y = 0; y < height; y++) { for (var x = 0; x < width; x++) { dataOut[position] = (int)RGB5A3.ToARGB8(rgba16Data[position]); position++; } } return(dataOut); }
private static int[] C4ImageSubroutineDecode(byte[] C4ImageData, ushort[] Palette, int Width, int Height, bool UsesBlocks = true) { C4ImageData = Utilities.Utilities.SeparateNibbles(C4ImageData); int[] RGB8Palette = new int[Palette.Length]; for (int i = 0; i < RGB8Palette.Length; i++) { RGB8Palette[i] = (int)RGB5A3.ToARGB8(Palette[i]); } byte[] UnscrambledData = UsesBlocks ? BlockFormat.Decode(C4ImageData, Width, Height, 8, 8) : C4ImageData; int[] ImageData = new int[UnscrambledData.Length]; for (int i = 0; i < ImageData.Length; i++) { ImageData[i] = RGB8Palette[UnscrambledData[i]]; } return(ImageData); }