public void EncodeFourBlocksPureBlackRGBThenDecodeIt() { // Arrange const int width = 8; // One block is 4x4, so 8x8 is 4 blocks const int height = 8; const int channelsPerPixel = 3; byte[] blackRGB = new byte[] { 0, 0, 0 }; byte[,,] pixels = new byte[width, height, channelsPerPixel] { { { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 } }, { { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 } }, { { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 } }, { { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 } }, { { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 } }, { { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 } }, { { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 } }, { { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 } }, }; TempByteImageFormat image = new TempByteImageFormat(pixels); // Act byte[] encodedBytes = PvrtcCompress.EncodeRgb4Bpp(image); TempByteImageFormat decoded = PvrtcDecompress.DecodeRgb4Bpp(encodedBytes, width); byte[] firstPixel = decoded.GetPixelChannels(0, 0); // Assert Assert.AreEqual(32, encodedBytes.Length); Assert.AreEqual(width, decoded.GetWidth()); Assert.AreEqual(height, decoded.GetHeight()); Assert.AreEqual(channelsPerPixel, decoded.GetChannelsPerPixel()); CollectionAssert.AreEqual(blackRGB, firstPixel); }
public void EncodeOneBlockPureWhiteRGBThenDecodeIt() { // Arrange const int width = 4; // One block is 4x4 const int height = 4; const int channelsPerPixel = 3; byte[] whiteRGB = new byte[] { 255, 255, 255 }; byte[,,] pixels = new byte[width, height, channelsPerPixel] { { { 255, 255, 255 }, { 255, 255, 255 }, { 255, 255, 255 }, { 255, 255, 255 } }, { { 255, 255, 255 }, { 255, 255, 255 }, { 255, 255, 255 }, { 255, 255, 255 } }, { { 255, 255, 255 }, { 255, 255, 255 }, { 255, 255, 255 }, { 255, 255, 255 } }, { { 255, 255, 255 }, { 255, 255, 255 }, { 255, 255, 255 }, { 255, 255, 255 } }, }; TempByteImageFormat image = new TempByteImageFormat(pixels); // Act byte[] encodedBytes = PvrtcCompress.EncodeRgb4Bpp(image); TempByteImageFormat decoded = PvrtcDecompress.DecodeRgb4Bpp(encodedBytes, width); byte[] firstPixel = decoded.GetPixelChannels(0, 0); // Assert Assert.AreEqual(8, encodedBytes.Length); Assert.AreEqual(width, decoded.GetWidth()); Assert.AreEqual(height, decoded.GetHeight()); Assert.AreEqual(channelsPerPixel, decoded.GetChannelsPerPixel()); CollectionAssert.AreEqual(whiteRGB, firstPixel); }
public void DecodeFile() { // Arrange FileStream pvrStream = new FileStream("hotair.4bpp.pvr", FileMode.Open, FileAccess.Read); byte[] array = new byte[512 * 512 / 2]; // Act pvrStream.Seek(0x44, SeekOrigin.Begin); pvrStream.Read(array, 0, array.Length); TempByteImageFormat temp = PvrtcDecompress.DecodeRgb4Bpp(array, 512); // Assert }
public void DecodeRGBTextureFromByteArray() { // Arrange byte[] input = new byte[8] { 0, 0, 0, 0, 254, 255, 255, 255 }; int width = 4; byte[] whiteRGB = new byte[] { 255, 255, 255 }; // Act TempByteImageFormat temp = PvrtcDecompress.DecodeRgb4Bpp(input, width); byte[] firstPixel = temp.GetPixelChannels(0, 0); // Assert CollectionAssert.AreEqual(whiteRGB, firstPixel); }