protected override Bitmap OnGetBitmap(int imageIndex, int paletteIndex) { ImageBinary imageBinary = new ImageBinary(); imageBinary.Width = (int)Width; imageBinary.Height = (int)Height; imageBinary.InputEndianness = Endian.LittleEndian; if (PaletteData != null) { imageBinary.InputPaletteFormat = PixelDataFormat.FormatAbgr8888; imageBinary.AddInputPalette(PaletteData); } switch (PixelFormat) { case TxgPixelFormat.Abgr8888: imageBinary.InputPixelFormat = PixelDataFormat.FormatAbgr8888 | PixelDataFormat.PixelOrderingSwizzledPSP; break; case TxgPixelFormat.Bgr565: imageBinary.InputPixelFormat = PixelDataFormat.FormatBgr565 | PixelDataFormat.PixelOrderingTiled; break; case TxgPixelFormat.Indexed8bpp: imageBinary.InputPixelFormat = PixelDataFormat.FormatIndexed8 | PixelDataFormat.PixelOrderingSwizzledPSP; break; default: throw new NotImplementedException(); } imageBinary.AddInputPixels(PixelData); return(imageBinary.GetBitmap()); }
protected override Bitmap OnGetBitmap(int imageIndex, int paletteIndex) { ImageBinary imageBinary = new ImageBinary(); PixelDataFormat pixelDataFormat = PixelDataFormat.Undefined; switch (PixelFormat) { case NmtPixelFormat.Indexed4bpp: pixelDataFormat = PixelDataFormat.FormatIndexed4; break; case NmtPixelFormat.Indexed8bpp: pixelDataFormat = PixelDataFormat.FormatIndexed8; break; case NmtPixelFormat.Argb8888: pixelDataFormat = PixelDataFormat.FormatArgb8888; break; } imageBinary.Width = Width; imageBinary.Height = Height; imageBinary.InputPaletteFormat = PixelDataFormat.FormatArgb8888; imageBinary.InputPixelFormat = pixelDataFormat; imageBinary.InputEndianness = Endian.LittleEndian; foreach (byte[] palette in PaletteData) { imageBinary.AddInputPalette(palette); } imageBinary.AddInputPixels(PixelData); return(imageBinary.GetBitmap()); }
protected override Bitmap OnGetBitmap(int imageIndex, int paletteIndex) { ImageBinary imageBinary = new ImageBinary(); PixelDataFormat pixelDataFormat = PixelDataFormat.Undefined; switch (Header.PixelFormat) { case TxfPixelFormat.Argb8888: pixelDataFormat = PixelDataFormat.FormatArgb8888; break; case TxfPixelFormat.RgbaDxt1: pixelDataFormat = PixelDataFormat.FormatDXT1Rgba; break; case TxfPixelFormat.RgbaDxt3: pixelDataFormat = PixelDataFormat.FormatDXT3; break; case TxfPixelFormat.RgbaDxt5: pixelDataFormat = PixelDataFormat.FormatDXT5; break; case TxfPixelFormat.Argb1555: pixelDataFormat = PixelDataFormat.FormatArgb1555; break; case TxfPixelFormat.Argb4444: pixelDataFormat = PixelDataFormat.FormatArgb4444; break; case TxfPixelFormat.Rgb565: pixelDataFormat = PixelDataFormat.FormatRgb565; break; } imageBinary.Width = Header.Width; imageBinary.Height = Header.Height; //imageBinary.InputPaletteFormat = PixelDataFormat.FormatArgb8888; imageBinary.InputPixelFormat = pixelDataFormat; imageBinary.InputEndianness = Endian.BigEndian; //imageBinary.AddInputPalette(PaletteData); imageBinary.AddInputPixels(PixelData); return(imageBinary.GetBitmap()); }
protected override void OnOpen(EndianBinaryReader reader) { ImageWidth = reader.ReadUInt16(); ImageHeight = reader.ReadUInt16(); ColorCount = reader.ReadUInt16(); Unknown0x06 = reader.ReadUInt16(); PaletteWidth = reader.ReadUInt16(); PaletteHeight = reader.ReadUInt16(); Padding = reader.ReadUInt32(); PaletteData = new byte[PaletteHeight][]; for (int py = 0; py < PaletteHeight; py++) { PaletteData[py] = PS2.ReadPaletteData(reader, (ColorCount == 256 ? PS2PixelFormat.PSMT8 : PS2PixelFormat.PSMT4), PS2PixelFormat.PSMCT32); } PixelData = reader.ReadBytes((ImageWidth * ImageHeight) / (ColorCount == 256 ? 1 : 2)); /* Initialize ImageBinary */ imageBinary = new ImageBinary(); imageBinary.Width = ImageWidth; imageBinary.Height = ImageHeight; imageBinary.InputPaletteFormat = PixelDataFormat.FormatBgra8888; imageBinary.InputPixelFormat = (ColorCount == 256 ? PixelDataFormat.FormatIndexed8 : PixelDataFormat.FormatIndexed4); imageBinary.InputEndianness = Endian.LittleEndian; foreach (byte[] palette in PaletteData) { imageBinary.AddInputPalette(palette); } imageBinary.AddInputPixels(PixelData); }
protected override Bitmap OnGetBitmap(int imageIndex, int paletteIndex) { VtxpImageHeader imageHeader = ImageHeaders[imageIndex]; bool isIndexed = (imageHeader.PaletteOffset != 0); ImageBinary imageBinary = new ImageBinary(); imageBinary.Width = imageHeader.Width; imageBinary.Height = imageHeader.Height; imageBinary.InputEndianness = Endian.LittleEndian; if (isIndexed) { imageBinary.InputPaletteFormat = PSVita.GetPaletteFormat(imageHeader.TextureFormat); imageBinary.AddInputPalette(imageHeader.PaletteData); } imageBinary.InputPixelFormat = PSVita.GetPixelDataFormat(imageHeader.TextureFormat); imageBinary.AddInputPixels(imageHeader.PixelData); if (imageHeader.TextureType == VtxpTextureType.Swizzled) { imageBinary.InputPixelFormat |= PixelDataFormat.PixelOrderingSwizzledVita; } return(imageBinary.GetBitmap()); }
protected override Bitmap OnGetBitmap(int imageIndex, int paletteIndex) { List <PSSGNode> allTextures = RootNode.FindNodes("TEXTURE"); PSSGNode texNode = allTextures[imageIndex]; Int32 width = Convert.ToInt32(texNode.Attributes["width"].Value); Int32 height = Convert.ToInt32(texNode.Attributes["height"].Value); Int32 numBlocks = Convert.ToInt32(texNode.Attributes["imageBlockCount"].Value); string texelFormat = texNode.Attributes["texelFormat"].Value; PixelDataFormat pixelFormat = PixelDataFormat.Undefined; bool flipY = false; List <PSSGNode> texImageBlocks = texNode.FindNodes("TEXTUREIMAGEBLOCK"); switch (texelFormat) { case "ui8x4": pixelFormat = PixelDataFormat.FormatArgb8888 | PixelDataFormat.PixelOrderingLinear; flipY = true; break; case "u8x4": pixelFormat = PixelDataFormat.FormatAbgr8888 | PixelDataFormat.PixelOrderingLinear; flipY = true; break; case "dxt1": pixelFormat = PixelDataFormat.FormatDXT1Rgba; flipY = true; break; case "dxt5": pixelFormat = PixelDataFormat.FormatDXT5; flipY = true; break; default: throw new NotSupportedException(String.Format("Unsupported PSSG texel Format: {0}", texelFormat)); } /* find out how many raw data blocks there are */ if (numBlocks > 1) { throw new NotSupportedException("Loading PSSG cube maps is not yet supported"); } else { /* we only have a single block. use that */ ImageBinary imgbin = new ImageBinary(); imgbin.Width = width; imgbin.Height = height; imgbin.InputPixelFormat = pixelFormat; imgbin.InputEndianness = Endian.LittleEndian; imgbin.AddInputPixels(texImageBlocks[0].FindNodes("TEXTUREIMAGEBLOCKDATA")[0].Data); Bitmap bmp = imgbin.GetBitmap(); if (flipY) { bmp.RotateFlip(RotateFlipType.RotateNoneFlipY); } return(bmp); } }
protected override Bitmap OnGetBitmap(int imageIndex, int paletteIndex) { PixelDataFormat inputPixelFormat = PixelDataFormat.Undefined; int physicalWidth, physicalHeight; if (DDSHeader.PixelFormat.Flags.HasFlag(DDPF.FourCC)) { switch (DDSHeader.PixelFormat.FourCC) { case "DXT1": inputPixelFormat = PixelDataFormat.FormatDXT1Rgba; break; case "DXT3": inputPixelFormat = PixelDataFormat.FormatDXT3; break; case "DXT5": inputPixelFormat = PixelDataFormat.FormatDXT5; break; case "PVR3": inputPixelFormat = PixelDataFormat.FormatPVRT4_Vita; break; // TODO: verify, probably not quite like PVRT4? case "PVR4": inputPixelFormat = PixelDataFormat.FormatPVRT4_Vita; break; } physicalWidth = physicalHeight = 1; while (physicalWidth < DDSHeader.Width) { physicalWidth *= 2; } while (physicalHeight < DDSHeader.Height) { physicalHeight *= 2; } } else { physicalWidth = (int)DDSHeader.Width; physicalHeight = (int)DDSHeader.Height; } if (inputPixelFormat == PixelDataFormat.Undefined) { throw new NotImplementedException("DDS pixel format not implemented"); } // TODO: total guesswork, verify me! if (DDSHeader.Reserved1[0x0A] == 0x00020008) { inputPixelFormat |= PixelDataFormat.PixelOrderingSwizzledVita; } ImageBinary imageBinary = new ImageBinary(); imageBinary.Width = (int)DDSHeader.Width; imageBinary.Height = (int)DDSHeader.Height; imageBinary.PhysicalWidth = physicalWidth; imageBinary.PhysicalHeight = physicalHeight; imageBinary.InputPixelFormat = inputPixelFormat; imageBinary.InputEndianness = Endian.LittleEndian; imageBinary.AddInputPixels(PixelData); return(imageBinary.GetBitmap()); }
protected override Bitmap OnGetBitmap(int imageIndex, int paletteIndex) { KsltImageData imageData = ImageData[imageIndex]; ImageBinary imageBinary = new ImageBinary(); imageBinary.Width = imageData.Width; imageBinary.Height = imageData.Height; imageBinary.InputEndianness = Endian.LittleEndian; switch (imageData.PixelFormat) { case KsltPixelFormat.Argb8888: imageBinary.InputPixelFormat = PixelDataFormat.FormatArgb8888; break; case KsltPixelFormat.DXT5: imageBinary.InputPixelFormat = PixelDataFormat.FormatDXT5; imageBinary.InputPixelFormat |= PixelDataFormat.PixelOrderingSwizzledVita; break; default: throw new NotImplementedException(string.Format("KSLT format 0x{0:X8}", (uint)imageData.PixelFormat)); } imageBinary.AddInputPixels(imageData.PixelData); return(imageBinary.GetBitmap()); }
protected override Bitmap OnGetBitmap(int imageIndex, int paletteIndex) { ImageBinary imageBinary = new ImageBinary(); PixelDataFormat pixelDataFormat = PixelDataFormat.Undefined; switch (PixelFormat) { case DMPBMPixelFormat.Alpha8: pixelDataFormat = PixelDataFormat.FormatAlpha8; break; case DMPBMPixelFormat.Rgba4444: pixelDataFormat = PixelDataFormat.FormatRgba4444; break; case DMPBMPixelFormat.Rgba5551: pixelDataFormat = PixelDataFormat.FormatRgba5551; break; case DMPBMPixelFormat.Rgba8888: pixelDataFormat = PixelDataFormat.FormatRgba8888; break; default: throw new NotImplementedException(string.Format("DMPBM format 0x{0:X}", PixelFormat)); } pixelDataFormat |= PixelDataFormat.PixelOrderingTiled3DS; imageBinary.Width = (int)Width; imageBinary.Height = (int)Height; imageBinary.InputPixelFormat = pixelDataFormat; imageBinary.InputEndianness = Endian.LittleEndian; imageBinary.AddInputPixels(PixelData); Bitmap bitmap = imageBinary.GetBitmap(); bitmap.RotateFlip(RotateFlipType.RotateNoneFlipY); return(bitmap); }
protected override Bitmap OnGetBitmap(int imageIndex, int paletteIndex) { G1TGImageDataShim imageDataShim = imageDataShims[imageIndex]; imageBinary = new ImageBinary(); imageBinary.AddInputPixels(imageDataShim.Data); imageBinary.InputPixelFormat = imageDataShim.Format; imageBinary.Width = imageDataShim.Width; imageBinary.Height = imageDataShim.Height; return(imageBinary.GetBitmap(0, 0)); }
protected override Bitmap OnGetBitmap(int imageIndex, int paletteIndex) { ImageBinary imageBinary = new ImageBinary(); imageBinary.Width = mipmapData[imageIndex].Width; imageBinary.Height = mipmapData[imageIndex].Height; imageBinary.InputPixelFormat = (mappingInfo.Item1 /*| PixelDataFormat.PixelOrderingSwizzledSwitch*/); imageBinary.InputEndianness = Endian.LittleEndian; imageBinary.AddInputPixels(mipmapData[imageIndex].PixelData); return(imageBinary.GetBitmap(0, 0)); }
protected override Bitmap OnGetBitmap(int imageIndex, int paletteIndex) { ImageBinary imageBinary = new ImageBinary(); imageBinary.Width = (int)Width; imageBinary.Height = (int)Height; imageBinary.InputPixelFormat = pixelDataFormat; imageBinary.InputEndianness = Endian.LittleEndian; imageBinary.AddInputPixels(PixelData); return(imageBinary.GetBitmap()); }
protected override Bitmap OnGetBitmap(int imageIndex, int paletteIndex) { ImageBinary imageBinary = new ImageBinary { Width = mipmapData[imageIndex].Width, Height = mipmapData[imageIndex].Height, InputPixelFormat = pixelDataFormat }; imageBinary.AddInputPixels(mipmapData[imageIndex].PixelData); return(imageBinary.GetBitmap(0, 0)); }
protected override Bitmap OnGetBitmap(int imageIndex, int paletteIndex) { ImageBinary imageBinary = new ImageBinary(); PixelDataFormat pixelDataFormat = PixelDataFormat.Undefined; switch (PixelFormat) { case DMPBMPixelFormat.Alpha8: pixelDataFormat = PixelDataFormat.FormatAlpha8; break; case DMPBMPixelFormat.Rgba4444: pixelDataFormat = PixelDataFormat.FormatRgba4444; break; case DMPBMPixelFormat.Rgba5551: pixelDataFormat = PixelDataFormat.FormatRgba5551; break; case DMPBMPixelFormat.Rgba8888: pixelDataFormat = PixelDataFormat.FormatRgba8888; break; case DMPBMPixelFormat.Indexed8: pixelDataFormat = PixelDataFormat.FormatIndexed8; break; default: throw new NotImplementedException(string.Format("DMPBM format 0x{0:X}", PixelFormat)); } pixelDataFormat |= PixelDataFormat.PixelOrderingTiled3DS; imageBinary.Width = (int)Width; imageBinary.Height = (int)Height; imageBinary.InputPixelFormat = pixelDataFormat; imageBinary.InputEndianness = Endian.LittleEndian; imageBinary.AddInputPixels(PixelData); if (PaletteData != null) { switch (PixelFormat) { // XBGR1555 ? case DMPBMPixelFormat.Indexed8: imageBinary.InputPaletteFormat = (PixelDataFormat.Bpp16 | PixelDataFormat.ChannelsXbgr | PixelDataFormat.RedBits5 | PixelDataFormat.GreenBits5 | PixelDataFormat.BlueBits5 | PixelDataFormat.AlphaBits1); break; default: throw new NotImplementedException(string.Format("DMPBM palette for format 0x{0:X}", PixelFormat)); } imageBinary.AddInputPalette(PaletteData); } Bitmap bitmap = imageBinary.GetBitmap(); bitmap.RotateFlip(RotateFlipType.RotateNoneFlipY); return(bitmap); }
protected override Bitmap OnGetBitmap(int imageIndex, int paletteIndex) { ImageBinary imageBinary = new ImageBinary { PhysicalWidth = PhysicalWidth, PhysicalHeight = PhysicalHeight, Width = VirtualWidth, Height = VirtualHeight, InputPixelFormat = pixelDataFormat, InputEndianness = Endian.LittleEndian }; imageBinary.AddInputPixels(PixelData); return(imageBinary.GetBitmap(imageIndex, paletteIndex)); }
protected override Bitmap OnGetBitmap(int imageIndex, int paletteIndex) { ImageBinary imageBinary = new ImageBinary(); PixelDataFormat pixelDataFormat, paletteDataFormat; if (Format == 0x8602) { pixelDataFormat = PixelDataFormat.FormatIndexed4 | PixelDataFormat.PixelOrderingSwizzledPSP; paletteDataFormat = PixelDataFormat.FormatAbgr4444; } else if (Format == 0x8803) { pixelDataFormat = PixelDataFormat.FormatIndexed4 | PixelDataFormat.PixelOrderingSwizzledPSP; paletteDataFormat = PixelDataFormat.FormatAbgr8888; } else if (Format == 0x8A02) { pixelDataFormat = PixelDataFormat.FormatIndexed8 | PixelDataFormat.PixelOrderingSwizzledPSP; paletteDataFormat = PixelDataFormat.FormatAbgr4444; } else if (Format == 0x8C03) { pixelDataFormat = PixelDataFormat.FormatIndexed8 | PixelDataFormat.PixelOrderingSwizzledPSP; paletteDataFormat = PixelDataFormat.FormatAbgr8888; } else if (Format == 0x800A) { pixelDataFormat = PixelDataFormat.FormatDXT1Rgba_PSP; paletteDataFormat = PixelDataFormat.Undefined; } else { throw new NotImplementedException(); } imageBinary.Width = Width; imageBinary.Height = Height; imageBinary.InputPaletteFormat = paletteDataFormat; imageBinary.InputPixelFormat = pixelDataFormat; imageBinary.InputEndianness = Endian.LittleEndian; imageBinary.AddInputPalette(PaletteData); imageBinary.AddInputPixels(PixelData); return(imageBinary.GetBitmap()); }
protected override void OnOpen(EndianBinaryReader reader) { MagicNumber = Encoding.ASCII.GetString(reader.ReadBytes(4), 0, 4); Unknown0x04 = reader.ReadUInt32(); Constant3553 = reader.ReadUInt32(); Width = reader.ReadUInt32(); Height = reader.ReadUInt32(); DataType = (PicaDataType)reader.ReadUInt32(); PixelFormat = (PicaPixelFormat)reader.ReadUInt32(); NumImageBytes = reader.ReadUInt32(); /* Disclaimer: Hacky as hell! I almost want to hope that Atlus someday leaves their internal STEX creator tool inside one of these games, maybe that'll help with figuring this out <.< */ /* ...now at offset 0x20, assume here's the pointer to image data */ ImageOffset = reader.ReadUInt32(); /* ...now assume said pointer is 0x80 */ if (ImageOffset == 0x80) { /* Read "well-formed" STEX (but really, who knows how the header's supposed to be) */ Unknown0x24 = reader.ReadUInt32(); Name = Encoding.ASCII.GetString(reader.ReadBytes(0x58), 0, 0x58).TrimEnd('\0'); /* ...but as image datasize is also unreliable, do some additional sanity checking on that, too! */ reader.BaseStream.Seek(ImageOffset, SeekOrigin.Begin); PixelData = reader.ReadBytes((int)(NumImageBytes > reader.BaseStream.Length ? reader.BaseStream.Length - ImageOffset : NumImageBytes)); } else /* ...otherwise... */ { /* Seek back, then just assume image data starts right here at 0x20, and that the image is as many bytes long as are left in the file */ reader.BaseStream.Seek(-4, SeekOrigin.Current); ImageOffset = (uint)reader.BaseStream.Position; Unknown0x24 = uint.MaxValue; Name = string.Empty; PixelData = reader.ReadBytes((int)(reader.BaseStream.Length - reader.BaseStream.Position)); } /* Initialize ImageBinary */ imageBinary = new ImageBinary(); imageBinary.Width = (int)Width; imageBinary.Height = (int)Height; imageBinary.InputPixelFormat = N3DS.GetPixelDataFormat(DataType, PixelFormat); imageBinary.InputEndianness = Endian.LittleEndian; imageBinary.AddInputPixels(PixelData); }
protected override Bitmap OnGetBitmap(int imageIndex, int paletteIndex) { CTXBTexture texture = Textures[imageIndex]; PicaPixelFormat pixelFormat = texture.PixelFormat; PicaDataType dataType = ((pixelFormat == PicaPixelFormat.ETC1RGB8NativeDMP || pixelFormat == PicaPixelFormat.ETC1AlphaRGB8A4NativeDMP) ? PicaDataType.UnsignedByte : texture.DataType); ImageBinary imageBinary = new ImageBinary(); imageBinary.Width = texture.Width; imageBinary.Height = texture.Height; imageBinary.InputPixelFormat = N3DS.GetPixelDataFormat(dataType, pixelFormat); imageBinary.InputEndianness = Endian.LittleEndian; imageBinary.AddInputPixels(pixelData[imageIndex]); return(imageBinary.GetBitmap(0, 0)); }
protected override Bitmap OnGetBitmap(int imageIndex, int paletteIndex) { #if DEBUG // DEBUG: if Scarlet format isn't set, return empty image if (pixelDataFormat == PixelDataFormat.Undefined) { return(new Bitmap(mipmapLevels[imageIndex].Width, mipmapLevels[imageIndex].Height)); } #endif ImageBinary imageBinary = new ImageBinary(); imageBinary.Width = mipmapLevels[imageIndex].Width; imageBinary.Height = mipmapLevels[imageIndex].Height; imageBinary.InputPixelFormat = pixelDataFormat; imageBinary.InputEndianness = Endian.LittleEndian; // ???? imageBinary.AddInputPixels(mipmapLevels[imageIndex].PixelData); return(imageBinary.GetBitmap(0, 0)); }
protected override Bitmap OnGetBitmap(int imageIndex, int paletteIndex) { ImageBinary imageBinary = new ImageBinary(); imageBinary = new ImageBinary(); imageBinary.Width = mipmapData[imageIndex].Width; imageBinary.Height = mipmapData[imageIndex].Height; imageBinary.InputPixelFormat = N3DS.GetPixelDataFormat(header.PixelFormat); imageBinary.InputEndianness = Endian.LittleEndian; imageBinary.AddInputPixels(mipmapData[imageIndex].PixelData); // Don't pass in original imageIndex and paletteIndex; Scarlet can't handle multiple widths/heights per ImageBinary, so we have to recreate it every time // TODO: uh, verify the whole Y flipping business here... //return imageBinary.GetBitmap(0, 0); Bitmap bitmap = imageBinary.GetBitmap(0, 0); bitmap.RotateFlip(RotateFlipType.RotateNoneFlipY); return(bitmap); }
protected override void OnOpen(EndianBinaryReader reader) { ImageWidth = reader.ReadUInt16(); ImageHeight = reader.ReadUInt16(); ColorCount = reader.ReadUInt16(); Unknown0x06 = reader.ReadUInt16(); PaletteWidth = reader.ReadUInt16(); PaletteHeight = reader.ReadUInt16(); SwizzleFlag = reader.ReadUInt16(); Unknown0x0E = reader.ReadUInt16(); PaletteData = new byte[PaletteHeight][]; for (int py = 0; py < PaletteHeight; py++) { PaletteData[py] = new byte[ColorCount * 4]; for (int px = 0; px < PaletteWidth; px++) { Buffer.BlockCopy(reader.ReadBytes(4), 0, PaletteData[py], px * 4, 4); } } PixelData = reader.ReadBytes((ImageWidth * ImageHeight) / (ColorCount == 256 ? 1 : 2)); imageBinary = new ImageBinary(); imageBinary.Width = ImageWidth; imageBinary.Height = ImageHeight; imageBinary.InputPaletteFormat = PixelDataFormat.FormatAbgr8888; imageBinary.InputPixelFormat = (ColorCount == 256 ? PixelDataFormat.FormatIndexed8 : PixelDataFormat.FormatIndexed4); if (SwizzleFlag != 0) { imageBinary.InputPixelFormat |= PixelDataFormat.PixelOrderingSwizzledPSP; } imageBinary.InputEndianness = Endian.LittleEndian; foreach (byte[] palette in PaletteData) { imageBinary.AddInputPalette(palette); } imageBinary.AddInputPixels(PixelData); }
protected override void OnOpen(EndianBinaryReader reader) { Tag = Encoding.ASCII.GetString(reader.ReadBytes(6)); Width = reader.ReadUInt16(); Height = reader.ReadUInt16(); Unknown0x0A = reader.ReadByte(); Unknown0x0B = reader.ReadByte(); PaletteData = reader.ReadBytes(256 * 4); PixelData = reader.ReadBytes(Width * Height); /* Initialize ImageBinary */ imageBinary = new ImageBinary(); imageBinary.Width = Width; imageBinary.Height = Height; imageBinary.InputPaletteFormat = PixelDataFormat.FormatAbgr8888; imageBinary.InputPixelFormat = PixelDataFormat.FormatIndexed8; imageBinary.InputEndianness = Endian.LittleEndian; imageBinary.AddInputPalette(PaletteData); imageBinary.AddInputPixels(PixelData); }
protected override void OnOpen(EndianBinaryReader reader) { Unknown0x00 = reader.ReadUInt16(); ID = reader.ReadUInt16(); FileSize = reader.ReadUInt32(); MagicNumber = Encoding.ASCII.GetString(reader.ReadBytes(4), 0, 4); Unknown0x0C = reader.ReadUInt32(); Unknown0x10 = reader.ReadByte(); PaletteFormat = (PS2PixelFormat)reader.ReadByte(); Width = reader.ReadUInt16(); Height = reader.ReadUInt16(); PixelFormat = (PS2PixelFormat)reader.ReadByte(); MipmapCount = reader.ReadByte(); MipmapKValue = reader.ReadByte(); MipmapLValue = reader.ReadByte(); TextureWrap = (PS2WrapMode)reader.ReadUInt16(); TextureID = reader.ReadUInt32(); CLUTID = reader.ReadUInt32(); Comment = Encoding.ASCII.GetString(reader.ReadBytes(0x1C), 0, 0x1C); if (PS2.IsFormatIndexed(PixelFormat)) { PaletteData = PS2.ReadPaletteData(reader, PixelFormat, PaletteFormat); } PixelData = reader.ReadBytes(CalculatePixelDataSize(Width, Height, PixelFormat)); imageBinary = new ImageBinary(); imageBinary.Width = (int)Width; imageBinary.Height = (int)Height; imageBinary.InputPaletteFormat = PS2.GetPixelDataFormat(PaletteFormat); imageBinary.InputPixelFormat = PS2.GetPixelDataFormat(PixelFormat); imageBinary.InputEndianness = Endian.LittleEndian; imageBinary.AddInputPalette(PaletteData); imageBinary.AddInputPixels(PixelData); }
protected override void OnOpen(EndianBinaryReader reader) { MagicNumber = Encoding.ASCII.GetString(reader.ReadBytes(3)); PixelFormat = reader.ReadByte(); FileSize = reader.ReadUInt32(); ImageDataOffset = reader.ReadUInt32(); Unknown0x0C = reader.ReadUInt32(); Unknown0x10 = reader.ReadUInt32(); Unknown0x14 = reader.ReadUInt32(); Unknown0x18 = reader.ReadUInt32(); Unknown0x1C = reader.ReadUInt32(); FileName = Encoding.ASCII.GetString(reader.ReadBytes(0x20)).TrimEnd('\0'); Unknown0x40 = reader.ReadUInt32(); Width = reader.ReadUInt32(); Height = reader.ReadUInt32(); BitsPerPixel = reader.ReadUInt32(); Unknown0x50 = reader.ReadUInt16(); Unknown0x52 = reader.ReadUInt16(); PaletteDataSize = reader.ReadUInt32(); ImageDataSize = reader.ReadUInt32(); Unknown0x5C = reader.ReadUInt32(); Unknown0x60 = reader.ReadUInt32(); CompressionFourCC = Encoding.ASCII.GetString(reader.ReadBytes(4)).TrimEnd('\0'); Unknown0x68 = reader.ReadUInt32(); Unknown0x6C = reader.ReadUInt32(); Unknown0x70 = reader.ReadUInt32(); Unknown0x74 = reader.ReadUInt32(); Unknown0x78 = reader.ReadByte(); Unknown0x79 = reader.ReadByte(); Unknown0x7A = reader.ReadUInt16(); Unknown0x7C = reader.ReadUInt16(); Unknown0x7E = reader.ReadUInt16(); if (reader.BaseStream.Position != 0x80) { throw new Exception("TID stream position mismatch"); } PaletteData = reader.ReadBytes((int)PaletteDataSize); reader.BaseStream.Seek(ImageDataOffset, SeekOrigin.Begin); PixelData = reader.ReadBytes((int)ImageDataSize); TidFormatChannelOrder pixelChannelOrder = ((TidFormatChannelOrder)PixelFormat & TidFormatChannelOrder.Argb); TidFormatCompressionFlag pixelCompression = ((TidFormatCompressionFlag)PixelFormat & TidFormatCompressionFlag.Compressed); bool pixelUnknownBit0 = (((TidFormatUnknownBit0)PixelFormat & TidFormatUnknownBit0.Set) == TidFormatUnknownBit0.Set); bool pixelUnknownBit3 = (((TidFormatUnknownBit3)PixelFormat & TidFormatUnknownBit3.Set) == TidFormatUnknownBit3.Set); bool pixelUnknownBit4 = (((TidFormatUnknownBit4)PixelFormat & TidFormatUnknownBit4.Set) == TidFormatUnknownBit4.Set); // TODO: vertical flip according to some docs, verify bool pixelUnknownBit5 = (((TidFormatUnknownBit5)PixelFormat & TidFormatUnknownBit5.Set) == TidFormatUnknownBit5.Set); bool pixelUnknownBit6 = (((TidFormatUnknownBit6)PixelFormat & TidFormatUnknownBit6.Set) == TidFormatUnknownBit6.Set); bool pixelUnknownBit7 = (((TidFormatUnknownBit7)PixelFormat & TidFormatUnknownBit7.Set) == TidFormatUnknownBit7.Set); PixelDataFormat pixelFormat, paletteFormat = PixelDataFormat.Undefined; if (pixelCompression == TidFormatCompressionFlag.Compressed) { switch (CompressionFourCC) { case "DXT1": pixelFormat = PixelDataFormat.FormatDXT1Rgba; break; case "DXT3": pixelFormat = PixelDataFormat.FormatDXT3; break; case "DXT5": pixelFormat = PixelDataFormat.FormatDXT5; break; default: throw new Exception(string.Format("Unimplemented TID compression format '{0}'", CompressionFourCC)); } } else if (pixelCompression == TidFormatCompressionFlag.NotCompressed) { if (PaletteDataSize != 0) { if (pixelChannelOrder == TidFormatChannelOrder.Rgba) { paletteFormat = PixelDataFormat.FormatRgba8888; } else if (pixelChannelOrder == TidFormatChannelOrder.Argb) { paletteFormat = PixelDataFormat.FormatArgb8888; } else { throw new Exception("Invalid TID channel order; should not be reached?!"); } if (BitsPerPixel == 8) { pixelFormat = PixelDataFormat.FormatIndexed8; } else { throw new Exception("Invalid or unsupported TID bits per pixel in indexed mode"); } } else { if (BitsPerPixel == 32) { if (pixelChannelOrder == TidFormatChannelOrder.Rgba) { pixelFormat = PixelDataFormat.FormatRgba8888; } else if (pixelChannelOrder == TidFormatChannelOrder.Argb) { pixelFormat = PixelDataFormat.FormatArgb8888; } else { throw new Exception("Invalid TID channel order; should not be reached?!"); } } else { throw new Exception("Invalid or unsupported TID bits per pixel in non-indexed mode"); } } } else { throw new Exception("Invalid TID compression flag; should not be reached?!"); } // TODO: verify if [Compressed == Swizzled] is correct, or if swizzling depends on other factors if (pixelCompression == TidFormatCompressionFlag.Compressed) { pixelFormat |= PixelDataFormat.PixelOrderingSwizzledVita; } imageBinary = new ImageBinary(); imageBinary.Width = (int)Width; imageBinary.Height = (int)Height; imageBinary.InputPixelFormat = pixelFormat; imageBinary.InputPaletteFormat = paletteFormat; imageBinary.InputEndianness = Endian.BigEndian; imageBinary.AddInputPixels(PixelData); imageBinary.AddInputPalette(PaletteData); }
private Bitmap CreateBitmap(int infoIdx, int forcePaletteIdx = -1) { SceGxtTextureInfo info = TextureInfos[infoIdx]; ImageBinary imageBinary = new ImageBinary(); imageBinary.Width = info.GetWidth(); imageBinary.Height = info.GetHeight(); imageBinary.InputPixelFormat = PSVita.GetPixelDataFormat(info.GetTextureFormat()); imageBinary.InputEndianness = Endian.LittleEndian; imageBinary.AddInputPixels(PixelData[infoIdx]); // TODO: verify all this crap, GXT conversion wrt image [dimension/format/type] is fragile as all hell SceGxmTextureBaseFormat textureBaseFormat = info.GetTextureBaseFormat(); SceGxmTextureType textureType = info.GetTextureType(); if (textureType == SceGxmTextureType.Linear && textureBaseFormat != SceGxmTextureBaseFormat.UBC1 && textureBaseFormat != SceGxmTextureBaseFormat.UBC2 && textureBaseFormat != SceGxmTextureBaseFormat.UBC3 && textureBaseFormat != SceGxmTextureBaseFormat.PVRT2BPP && textureBaseFormat != SceGxmTextureBaseFormat.PVRT4BPP && textureBaseFormat != SceGxmTextureBaseFormat.PVRTII2BPP && textureBaseFormat != SceGxmTextureBaseFormat.PVRTII4BPP) { imageBinary.PhysicalWidth = (int)(((info.DataSize / imageBinary.Height) * 8) / PSVita.GetBitsPerPixel(textureBaseFormat)); imageBinary.PhysicalHeight = info.GetHeight(); } else { imageBinary.PhysicalWidth = info.GetWidthRounded(); imageBinary.PhysicalHeight = info.GetHeightRounded(); } if (textureBaseFormat != SceGxmTextureBaseFormat.PVRT2BPP && textureBaseFormat != SceGxmTextureBaseFormat.PVRT4BPP) { switch (textureType) { case SceGxmTextureType.Linear: // Nothing to be done! break; case SceGxmTextureType.Tiled: // TODO: verify me! imageBinary.InputPixelFormat |= PixelDataFormat.PixelOrderingTiled3DS; break; case SceGxmTextureType.Swizzled: case SceGxmTextureType.Cube: // TODO: is cube really the same as swizzled? seems that way from CS' *env* files... imageBinary.InputPixelFormat |= PixelDataFormat.PixelOrderingSwizzledVita; break; case (SceGxmTextureType)0xA0000000: // TODO: this is odd and needs investigation, found ex. in Odin Sphere, Puyo Puyo Tetris, ... imageBinary.InputPixelFormat |= PixelDataFormat.PixelOrderingSwizzledVita; break; } } if (textureBaseFormat == SceGxmTextureBaseFormat.P4 || textureBaseFormat == SceGxmTextureBaseFormat.P8) { imageBinary.InputPaletteFormat = PSVita.GetPaletteFormat(info.GetTextureFormat()); if (textureBaseFormat == SceGxmTextureBaseFormat.P4) { foreach (byte[] paletteData in P4Palettes) { imageBinary.AddInputPalette(paletteData); } } else if (textureBaseFormat == SceGxmTextureBaseFormat.P8) { foreach (byte[] paletteData in P8Palettes) { imageBinary.AddInputPalette(paletteData); } } } return(imageBinary.GetBitmap(0, forcePaletteIdx != -1 ? forcePaletteIdx : info.PaletteIndex)); }
protected override void OnOpen(EndianBinaryReader reader) { /* Read header(?) */ Unknown0x00 = reader.ReadUInt32(); Unknown0x04 = reader.ReadUInt32(); FrameDataOffset = reader.ReadUInt32(); PixelDataOffset = reader.ReadUInt32(); RawImageWidth = reader.ReadUInt16(); RawImageHeight = reader.ReadUInt16(); NumImageInformation = reader.ReadUInt16(); BlockWidth = reader.ReadByte(); BlockHeight = reader.ReadByte(); Unknown0x18 = reader.ReadUInt16(); Unknown0x1A = reader.ReadUInt16(); Unknown0x1C = reader.ReadUInt32(); Unknown0x20 = reader.ReadUInt32(); Unknown0x24 = reader.ReadUInt32(); Unknown0x28 = reader.ReadUInt32(); Unknown0x2C = reader.ReadUInt32(); Unknown0x30 = reader.ReadUInt32(); Unknown0x34 = reader.ReadUInt32(); Unknown0x38 = reader.ReadUInt32(); Unknown0x3C = reader.ReadUInt32(); /* Get image information */ ImageInfos = new TIPSImageInfo[NumImageInformation]; for (int i = 0; i < NumImageInformation; i++) { ImageInfos[i] = new TIPSImageInfo(reader); } /* Get rect information */ RectInfos = new Dictionary <TIPSImageInfo, TIPSRectangleInfo[]>(); for (int i = 0; i < NumImageInformation; i++) { TIPSImageInfo imageInfo = ImageInfos[i]; long position = reader.BaseStream.Position; reader.BaseStream.Seek(imageInfo.RectOffset, SeekOrigin.Begin); RectInfos.Add(imageInfo, new TIPSRectangleInfo[imageInfo.NumRects]); for (int j = 0; j < imageInfo.NumRects; j++) { RectInfos[imageInfo][j] = new TIPSRectangleInfo(reader); } reader.BaseStream.Seek(position, SeekOrigin.Begin); } /* Get all image permutations (eyes, mouths, etc) */ ImagePermutations = new List <int[]>(); int maxType = (int)(ImageInfos.Max(x => x.Index) + 1); int[] indices = new int[maxType]; for (int t = maxType - 1; t >= 0; t--) { GetImagePermutations(ref indices, t); } /* Get pixel data */ reader.BaseStream.Seek(PixelDataOffset, SeekOrigin.Begin); PixelData = reader.ReadBytes((int)(reader.BaseStream.Length - PixelDataOffset)); /* Scale alpha */ for (int i = 0; i < PixelData.Length; i += 4) { PixelData[i + 3] = PS2.ScaleAlpha(PixelData[i + 3]); } /* Create raw image bitmap */ ImageBinary rawImageBinary = new ImageBinary(); if (RawImageWidth != 0 && RawImageHeight != 0) { rawImageBinary.Width = RawImageWidth; rawImageBinary.Height = RawImageHeight; rawImageBinary.InputPixelFormat = PixelDataFormat.FormatAbgr8888; rawImageBinary.AddInputPixels(PixelData); rawImage = rawImageBinary.GetBitmap(); } }
protected override Bitmap OnGetBitmap(int imageIndex, int paletteIndex) { PixelDataFormat inputPixelFormat = PixelDataFormat.Undefined; int physicalWidth, physicalHeight; if (DDSHeader.PixelFormat.Flags.HasFlag(DDPF.FourCC)) { switch (DDSHeader.PixelFormat.FourCC) { case "DXT1": inputPixelFormat = PixelDataFormat.FormatDXT1Rgba; break; case "DXT3": inputPixelFormat = PixelDataFormat.FormatDXT3; break; case "DXT5": inputPixelFormat = PixelDataFormat.FormatDXT5; break; case "PVR3": inputPixelFormat = PixelDataFormat.FormatPVRT4_Vita; break; // TODO: verify, probably not quite like PVRT4? case "PVR4": inputPixelFormat = PixelDataFormat.FormatPVRT4_Vita; break; } physicalWidth = physicalHeight = 1; while (physicalWidth < DDSHeader.Width) { physicalWidth *= 2; } while (physicalHeight < DDSHeader.Height) { physicalHeight *= 2; } } else { // TODO: actually implement uncompressed DDS formats...? PixelDataFormat alphaFormat = PixelDataFormat.Undefined, colorFormat = PixelDataFormat.Undefined; if (DDSHeader.PixelFormat.Flags.HasFlag(DDPF.AlphaPixels)) { switch (DDSHeader.PixelFormat.ABitMask) { case 0xFF000000: alphaFormat |= PixelDataFormat.AlphaBits8; break; default: throw new NotImplementedException("DDS alpha bit mask not implemented"); } } if (DDSHeader.PixelFormat.Flags.HasFlag(DDPF.RGB)) { switch (DDSHeader.PixelFormat.RBitMask) { case 0x00FF0000: colorFormat |= PixelDataFormat.RedBits8; break; default: throw new NotImplementedException("DDS red bit mask not implemented"); } switch (DDSHeader.PixelFormat.GBitMask) { case 0x0000FF00: colorFormat |= PixelDataFormat.GreenBits8; break; default: throw new NotImplementedException("DDS green bit mask not implemented"); } switch (DDSHeader.PixelFormat.BBitMask) { case 0x000000FF: colorFormat |= PixelDataFormat.BlueBits8; break; default: throw new NotImplementedException("DDS blue bit mask not implemented"); } } if (DDSHeader.PixelFormat.RBitMask != 0 && DDSHeader.PixelFormat.GBitMask != 0 && DDSHeader.PixelFormat.BBitMask != 0 && DDSHeader.PixelFormat.ABitMask != 0) { inputPixelFormat |= PixelDataFormat.ChannelsArgb; } else { throw new NotImplementedException("DDS channel setup not implemented"); } if (DDSHeader.PixelFormat.RGBBitCount == 32) { inputPixelFormat |= PixelDataFormat.Bpp32; } else { throw new NotImplementedException("DDS bits per pixel not implemented"); } inputPixelFormat |= colorFormat; inputPixelFormat |= alphaFormat; physicalWidth = (int)DDSHeader.Width; physicalHeight = (int)DDSHeader.Height; } if (inputPixelFormat == PixelDataFormat.Undefined) { throw new NotImplementedException("DDS pixel format not implemented"); } if (DDSHeader.Reserved1[0x0A] == 0x00020008) { // TODO: total guesswork, verify me! inputPixelFormat |= PixelDataFormat.PixelOrderingSwizzledVita; } ImageBinary imageBinary = new ImageBinary(); imageBinary.Width = (int)DDSHeader.Width; imageBinary.Height = (int)DDSHeader.Height; imageBinary.PhysicalWidth = physicalWidth; imageBinary.PhysicalHeight = physicalHeight; imageBinary.InputPixelFormat = inputPixelFormat; imageBinary.InputEndianness = Endian.LittleEndian; imageBinary.AddInputPixels(PixelData); return(imageBinary.GetBitmap()); }
protected override Bitmap OnGetBitmap(int imageIndex, int paletteIndex) { ImageBinary imageBinary = new ImageBinary(); PixelDataFormat pixelDataFormat, paletteDataFormat; switch (ImageType) { // Non-indexed image case GbixImageType.Linear: case GbixImageType.LinearMipmaps: if (!dataTypeFormatMap.ContainsKey(DataType)) { throw new NotImplementedException(string.Format("GBIX: unimplemented pixel data type {0} (0x{1:X2})", DataType, (byte)DataType)); } pixelDataFormat = dataTypeFormatMap[DataType]; if (!isCompressed) { pixelDataFormat |= PixelDataFormat.PixelOrderingSwizzledPSP; } paletteDataFormat = PixelDataFormat.Undefined; break; // Indexed image (4-bit) case GbixImageType.Indexed4: case GbixImageType.Indexed4_Alt: if (!dataTypeFormatMap.ContainsKey(DataType)) { throw new NotImplementedException(string.Format("GBIX: unimplemented palette data type {0} (0x{1:X2})", DataType, (byte)DataType)); } pixelDataFormat = PixelDataFormat.FormatIndexed4 | PixelDataFormat.PixelOrderingSwizzledPSP; paletteDataFormat = dataTypeFormatMap[DataType]; break; // Indexed image (8-bit) case GbixImageType.Indexed8: case GbixImageType.Indexed8_Alt: if (!dataTypeFormatMap.ContainsKey(DataType)) { throw new NotImplementedException(string.Format("GBIX: unimplemented palette data type {0} (0x{1:X2})", DataType, (byte)DataType)); } pixelDataFormat = PixelDataFormat.FormatIndexed8 | PixelDataFormat.PixelOrderingSwizzledPSP; paletteDataFormat = dataTypeFormatMap[DataType]; break; default: throw new NotImplementedException(string.Format("GBIX: unimplemented image type {0} (0x{1:X2})", ImageType, (byte)ImageType)); } imageBinary.Width = mipmapData[imageIndex].Width; imageBinary.Height = mipmapData[imageIndex].Height; imageBinary.InputPaletteFormat = paletteDataFormat; imageBinary.InputPixelFormat = pixelDataFormat; imageBinary.InputEndianness = Endian.LittleEndian; imageBinary.AddInputPalette(PaletteData); imageBinary.AddInputPixels(mipmapData[imageIndex].PixelData); return(imageBinary.GetBitmap(0, 0)); }
protected override void OnOpen(EndianBinaryReader reader) { MagicNumber = Encoding.ASCII.GetString(reader.ReadBytes(4), 0, 4); Unknown0x04 = reader.ReadUInt32(); Unknown0x08 = reader.ReadUInt32(); FileSize = reader.ReadUInt32(); Unknown0x10 = reader.ReadUInt32(); ImageInformation1 = reader.ReadUInt32(); ImageInformation2 = reader.ReadUInt32(); ImageInformation3 = reader.ReadUInt32(); ImageInformation4 = reader.ReadUInt32(); Unknown0x24 = reader.ReadUInt32(); Unknown0x28 = reader.ReadUInt32(); DataSize = reader.ReadUInt32(); UserMagicNumber = Encoding.ASCII.GetString(reader.ReadBytes(4), 0, 4); Unknown0x34 = new uint[0x33]; for (int i = 0; i < Unknown0x34.Length; i++) { Unknown0x34[i] = reader.ReadUInt32(); } PixelData = reader.ReadBytes((int)DataSize); /* Extract formats and dimensions (thanks bonaire.rai!) */ dataFormat = (GnfDataFormat)ExtractData(ImageInformation1, 20, 25); numFormat = (GnfNumFormat)ExtractData(ImageInformation1, 26, 29); width = (int)(ExtractData(ImageInformation2, 0, 13) + 1); height = (int)(ExtractData(ImageInformation2, 14, 27) + 1); depth = (int)(ExtractData(ImageInformation4, 0, 12)); pitch = (int)(ExtractData(ImageInformation4, 13, 26) + 1); destX = (GnfSqSel)ExtractData(ImageInformation3, 0, 2); destY = (GnfSqSel)ExtractData(ImageInformation3, 3, 5); destZ = (GnfSqSel)ExtractData(ImageInformation3, 6, 8); destW = (GnfSqSel)ExtractData(ImageInformation3, 9, 11); /* Figure out channel order from destX/Y/Z/W values */ PixelDataFormat channelOrder; if (destX == GnfSqSel.SelX && destY == GnfSqSel.SelY && destZ == GnfSqSel.SelZ && destW == GnfSqSel.SelW) { channelOrder = PixelDataFormat.ChannelsAbgr; } else if (destX == GnfSqSel.SelZ && destY == GnfSqSel.SelY && destZ == GnfSqSel.SelX && destW == GnfSqSel.SelW) { channelOrder = PixelDataFormat.ChannelsArgb; } else { throw new Exception($"Unhandled GNF channel destinations (X={destX}, Y={destY}, Z={destZ}, W={destW})"); } /* Initialize ImageBinary */ imageBinary = new ImageBinary(); imageBinary.Width = width; imageBinary.Height = height; imageBinary.PhysicalWidth = pitch; imageBinary.PhysicalHeight = height; byte[] preparedPixelData = PixelData; // TODO: stupid formats Scarlet can't support yet, like stuff with 16bits per channel, verify BC6, Format32... if (dataFormat == GnfDataFormat.Format16_16_16_16) { preparedPixelData = new byte[PixelData.Length / 2]; for (int i = 0, j = 0; i < PixelData.Length; i += 2, j++) { preparedPixelData[j] = PixelData[i]; } } else if (dataFormat == GnfDataFormat.Format32) { preparedPixelData = new byte[PixelData.Length / 4]; for (int i = 0, j = 0; i < PixelData.Length; i += 4, j++) { float value = BitConverter.ToSingle(PixelData, i); if (numFormat == GnfNumFormat.FormatFloat) { preparedPixelData[j] = (byte)(value + 128.0f); } else { preparedPixelData[j] = (byte)(value * 255); } } } else if (dataFormat == GnfDataFormat.Format32_32_32_32) { preparedPixelData = new byte[PixelData.Length / 4]; for (int i = 0, j = 0; i < PixelData.Length; i += 4, j++) { float value = BitConverter.ToSingle(PixelData, i); preparedPixelData[j] = (byte)(value * 255); } } switch (dataFormat) { case GnfDataFormat.Format8_8_8_8: imageBinary.InputPixelFormat = (PixelDataFormat.Bpp32 | channelOrder | PixelDataFormat.RedBits8 | PixelDataFormat.GreenBits8 | PixelDataFormat.BlueBits8 | PixelDataFormat.AlphaBits8); break; case GnfDataFormat.FormatBC1: imageBinary.InputPixelFormat = PixelDataFormat.FormatDXT1Rgba; break; case GnfDataFormat.FormatBC2: imageBinary.InputPixelFormat = PixelDataFormat.FormatDXT3; break; case GnfDataFormat.FormatBC3: imageBinary.InputPixelFormat = PixelDataFormat.FormatDXT5; break; case GnfDataFormat.FormatBC4: imageBinary.InputPixelFormat = (numFormat == GnfNumFormat.FormatSNorm ? PixelDataFormat.FormatRGTC1_Signed : PixelDataFormat.FormatRGTC1); break; case GnfDataFormat.FormatBC5: imageBinary.InputPixelFormat = (numFormat == GnfNumFormat.FormatSNorm ? PixelDataFormat.FormatRGTC2_Signed : PixelDataFormat.FormatRGTC2); break; //case GnfDataFormat.FormatBC6: imageBinary.InputPixelFormat = PixelDataFormat.FormatBPTC_Float;/*(numFormat == GnfNumFormat.FormatSNorm ? PixelDataFormat.FormatBPTC_SignedFloat : PixelDataFormat.FormatBPTC_Float);*/ break; // TODO: fixme!! case GnfDataFormat.FormatBC7: imageBinary.InputPixelFormat = PixelDataFormat.FormatBPTC; break; // TODO //case GnfDataFormat.Format16_16_16_16: imageBinary.InputPixelFormat = PixelDataFormat.FormatAbgr8888; break; //case GnfDataFormat.Format32: imageBinary.InputPixelFormat = PixelDataFormat.FormatLuminance8; break; //case GnfDataFormat.Format32_32_32_32: imageBinary.InputPixelFormat = PixelDataFormat.FormatAbgr8888; break; // WRONG //case GnfDataFormat.Format8: imageBinary.InputPixelFormat = PixelDataFormat.FormatLuminance8; break; //case GnfDataFormat.Format8_8: imageBinary.InputPixelFormat = PixelDataFormat.FormatLuminance8; break; default: throw new Exception($"Unimplemented GNF data format {dataFormat}"); } imageBinary.InputPixelFormat |= PixelDataFormat.PixelOrderingTiled3DS; imageBinary.AddInputPixels(preparedPixelData); }