Beispiel #1
0
 public SgRgbReader(IBinaryStream input, SgMetaData info)
 {
     if (info.Type != SgType.cRGB || !(0x18 == info.BPP || 0x20 == info.BPP))
     {
         throw new InvalidFormatException();
     }
     m_input    = input;
     m_info     = info;
     m_width    = (int)info.Width;
     m_height   = (int)info.Height;
     m_stride   = m_width * 4;
     m_channels = m_info.BPP / 8;
 }
Beispiel #2
0
        ImageData ReadJpeg(IBinaryStream stream, SgMetaData info)
        {
            stream.Position = info.DataOffset;
            var input = stream.ReadBytes(info.DataSize);

            if (input.Length != info.DataSize)
            {
                throw new EndOfStreamException();
            }
            PakOpener.Decrypt(input, info.JpegKey);
            using (var img = new MemoryStream(input))
            {
                var decoder = new JpegBitmapDecoder(img, BitmapCreateOptions.None, BitmapCacheOption.OnLoad);
                var frame   = decoder.Frames[0];
                frame.Freeze();
                return(new ImageData(frame, info));
            }
        }