public Bitmap GetBitmap() { if (bitmap == null) { var ddsPF = DDSHelper.ConvertFromDDSAtlus(Header.PixelFormat); if (ddsPF == DDSFourCC.NONE) { var PF = DDSHelper.DDSAtlusToPixelFormat(Header.PixelFormat); bitmap = new Bitmap(Header.Width, Header.Height * Header.TileCount, PF, dataList[0], null); } else { DDSDecompressor.DDSDecompress(Header.Width, Header.Height * Header.TileCount, dataList[0], ddsPF, out byte[] newData); bitmap = new Bitmap(Header.Width, Header.Height * Header.TileCount, PixelFormats.Bgra32, newData, null); } } return(bitmap); }
private static void DecompressDDS(BinaryReader reader, Stream destination, DDSContainerParameters @params) { if (@params.PixelFormatFlags.IsFourCC()) { switch (@params.FourCC) { case DDSFourCCType.DXT1: DDSDecompressor.DecompressDXT1(reader, destination, @params); break; case DDSFourCCType.DXT3: DDSDecompressor.DecompressDXT3(reader, destination, @params); break; case DDSFourCCType.DXT5: DDSDecompressor.DecompressDXT5(reader, destination, @params); break; default: throw new NotImplementedException(@params.FourCC.ToString()); } } else { if (@params.PixelFormatFlags.IsLuminace()) { throw new NotSupportedException("Luminace isn't supported"); } else { if (@params.PixelFormatFlags.IsAlphaPixels()) { DDSDecompressor.DecompressRGBA(reader, destination, @params); } else { DDSDecompressor.DecompressRGB(reader, destination, @params); } } } }