Ejemplo n.º 1
0
        }                                                                  // 'GGPF'

        public override ImageMetaData ReadMetaData(Stream stream)
        {
            var header = new byte[0x24];

            if (header.Length != stream.Read(header, 0, header.Length))
            {
                return(null);
            }
            if (!Binary.AsciiEqual(header, 0, "GGPFAIKE"))
            {
                return(null);
            }
            var info = new GgpMetaData
            {
                Offset = LittleEndian.ToUInt32(header, 0x14),
                Length = LittleEndian.ToUInt32(header, 0x18),
            };

            for (int i = 0; i < 8; ++i)
            {
                info.Key[i] = (byte)(header[i] ^ header[i + 0xC]);
            }
            stream.Position = info.Offset;
            using (var png = new EncryptedStream(stream, info.Key, true))
            {
                var png_info = base.ReadMetaData(png);
                info.Width   = png_info.Width;
                info.Height  = png_info.Height;
                info.BPP     = png_info.BPP;
                info.OffsetX = png_info.OffsetX;
                info.OffsetY = png_info.OffsetY;
                return(info);
            }
        }
Ejemplo n.º 2
0
        public override ImageMetaData ReadMetaData(IBinaryStream stream)
        {
            var header = stream.ReadHeader(0x24);

            if (!header.AsciiEqual("GGPFAIKE"))
            {
                return(null);
            }
            var info = new GgpMetaData
            {
                Offset = header.ToUInt32(0x14),
                Length = header.ToUInt32(0x18),
            };

            for (int i = 0; i < 8; ++i)
            {
                info.Key[i] = (byte)(header[i] ^ header[i + 0xC]);
            }
            stream.Position = info.Offset;
            using (var enc = new EncryptedStream(stream.AsStream, info.Key, true))
                using (var png = new BinaryStream(enc, stream.Name))
                {
                    var png_info = base.ReadMetaData(png);
                    info.Width   = png_info.Width;
                    info.Height  = png_info.Height;
                    info.BPP     = png_info.BPP;
                    info.OffsetX = png_info.OffsetX;
                    info.OffsetY = png_info.OffsetY;
                    return(info);
                }
        }