private void Parse(BinaryReader reader) { DDSStruct header = new DDSStruct(); Utils.PixelFormat pixelFormat = Utils.PixelFormat.UNKNOWN; byte[] data = null; if (ReadHeader(reader, ref header)) { _isValid = true; // patches for stuff if (header.depth == 0) { header.depth = 1; } uint blocksize = 0; pixelFormat = GetFormat(header, ref blocksize); if (pixelFormat == Utils.PixelFormat.UNKNOWN) { throw new InvalidFileHeaderException(); } data = ReadData(reader, header); if (data != null) { byte[] rawData = DDSDecompressor.Expand(header, data, pixelFormat); _bitmap = CreateBitmap((int)header.width, (int)header.height, rawData); } } }
public DDSImage(CR2WBinaryReader reader, DDSStruct header, bool alpha) { Utils.PixelFormat pixelFormat = Utils.PixelFormat.UNKNOWN; byte[] data = null; if (header.depth == 0) { header.depth = 1; } _isValid = true; _alpha = alpha; uint blocksize = 0; pixelFormat = GetFormat(header, ref blocksize); if (pixelFormat == Utils.PixelFormat.UNKNOWN) { throw new InvalidFileHeaderException(); } data = ReadData(reader, header); if (data != null) { byte[] rawData = DDSDecompressor.Expand(header, data, pixelFormat); _bitmap = CreateBitmap((int)header.width, (int)header.height, rawData); } }