private ImageData ReadJpeg(Stream file, SpdMetaData info) { file.Position = 0x18; var header = new byte[0x3C]; if (header.Length != file.Read(header, 0, header.Length)) { throw new EndOfStreamException(); } unsafe { fixed(byte *raw = header) { uint *dw = (uint *)raw; for (int i = 0; i < 0xF; ++i) { dw[i] += 0xA8961EF1; } } } using (var rest = new StreamRegion(file, file.Position, true)) using (var jpeg = new PrefixStream(header, rest)) { var decoder = new JpegBitmapDecoder(jpeg, BitmapCreateOptions.None, BitmapCacheOption.OnLoad); var frame = decoder.Frames[0]; frame.Freeze(); return(new ImageData(frame, info)); } }
public SpdReader(Stream input, SpdMetaData info) { m_input = input; m_output = new byte[info.UnpackedSize]; m_info = info; if (24 == info.BPP) { Format = PixelFormats.Bgr24; } else if (32 == info.BPP) { Format = PixelFormats.Bgra32; } else { throw new NotSupportedException("Not supported SPD image bitdepth"); } }