public void LoadBitMap(string FileName, BntxFile bntxFile) { DecompressedData.Clear(); TexName = Path.GetFileNameWithoutExtension(FileName); bntx = bntxFile; Format = SurfaceFormat.BC1_SRGB; GenerateMipmaps = true; Bitmap Image = new Bitmap(FileName); Image = TextureData.SwapBlueRedChannels(Image); TexWidth = (uint)Image.Width; TexHeight = (uint)Image.Height; MipCount = (uint)GetTotalMipCount(); DecompressedData.Add(BitmapExtension.ImageToByte(Image)); Image.Dispose(); if (DecompressedData.Count == 0) { throw new Exception("Failed to load " + Format); } }
public Bitmap DisplayImage(int mipLevel = 0, int arrayLevel = 0) { LoadTexture(); Bitmap decomp; if (Format == XTXFormats.XTXImageFormat.BC5S) { return(DDSCompressor.DecompressBC5(mipmaps[0], (int)Width, (int)Height, true)); } byte[] d = null; if (IsCompressedFormat(Format)) { d = DDSCompressor.DecompressBlock(mipmaps[0], (int)Width, (int)Height, GetCompressedDXGI_FORMAT(Format)); } else { d = DDSCompressor.DecodePixelBlock(mipmaps[0], (int)Width, (int)Height, GetUncompressedDXGI_FORMAT(Format)); } if (d != null) { decomp = BitmapExtension.GetBitmap(d, (int)Width, (int)Height); return(TextureData.SwapBlueRedChannels(decomp)); } return(null); }
public static Bitmap DecodeBlock(byte[] data, uint Width, uint Height, NUTEXImageFormat Format) { Bitmap decomp; if (Format == NUTEXImageFormat.BC5_SNORM) { return(DDSCompressor.DecompressBC5(data, (int)Width, (int)Height, true)); } byte[] d = null; if (IsCompressedFormat(Format)) { d = DDSCompressor.DecompressBlock(data, (int)Width, (int)Height, GetCompressedDXGI_FORMAT(Format)); } else { d = DDSCompressor.DecodePixelBlock(data, (int)Width, (int)Height, GetUncompressedDXGI_FORMAT(Format)); } if (d != null) { decomp = BitmapExtension.GetBitmap(d, (int)Width, (int)Height); return(TextureData.SwapBlueRedChannels(decomp)); } return(null); }