public void ConvertFromAl(AlImage image, Stream destStream) { List <byte[]> mips; if (image.PixelFormat == "ETC1") { mips = image.Mipmaps; } else if (image.PixelFormat == "EC1A") { // Give first half of the mips mips = new List <byte[]>(); foreach (var mip in image.Mipmaps) { byte[] newMip = new byte[mip.Length / 2]; Buffer.BlockCopy(mip, 0, newMip, 0, newMip.Length); mips.Add(newMip); } } else { throw new ArgumentException("Pixel format not supported.", nameof(image)); } var ktx = KtxCreator.Create(GlDataType.Compressed, GlPixelFormat.GL_RGB, GlInternalFormat.GL_ETC1_RGB8_OES, image.Width, image.Height, mips, new Dictionary <string, MetadataValue>()); KtxWriter.WriteTo(ktx, destStream); }
public void KtxCreatorValidInputTest() { // Arange byte[] textureLevel0 = new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }; // Not a valid ATSC block most likely! List <byte[]> textureDatas = new List <byte[]>() { textureLevel0 }; // Act // Assert Assert.DoesNotThrow(() => KtxCreator.Create(GlDataType.Compressed, GlPixelFormat.GL_RGBA, GlInternalFormat.GL_COMPRESSED_RGBA_ASTC_8x8_KHR, 8, 8, textureDatas, new System.Collections.Generic.Dictionary <string, MetadataValue>())); }
public void ConvertFromAlAlt(AlImage image, Stream destStream) { if (image.PixelFormat != "EC1A") { throw new ArgumentException("Pixel format does not have alternate representation.", nameof(image)); } // Give second half of the mips var mips = new List <byte[]>(); foreach (var mip in image.Mipmaps) { byte[] newMip = new byte[mip.Length / 2]; Buffer.BlockCopy(mip, newMip.Length, newMip, 0, newMip.Length); mips.Add(newMip); } var ktx = KtxCreator.Create(GlDataType.Compressed, GlPixelFormat.GL_RGB, GlInternalFormat.GL_ETC1_RGB8_OES, image.Width, image.Height, mips, new Dictionary <string, MetadataValue>()); KtxWriter.WriteTo(ktx, destStream); }