Пример #1
0
 public override ImageData Read(Stream stream, ImageMetaData info)
 {
     using (var reader = new AgfReader(stream, (AgfMetaData)info))
     {
         reader.Unpack();
         return(ImageData.Create(info, reader.Format, null, reader.Data));
     }
 }
Пример #2
0
 public override ImageData Read(Stream stream, ImageMetaData info)
 {
     using (var reader = new AgfReader (stream, (AgfMetaData)info))
     {
         reader.Unpack();
         return ImageData.Create (info, reader.Format, null, reader.Data);
     }
 }
Пример #3
0
        public override ImageMetaData ReadMetaData(Stream stream)
        {
            var header = new byte[0x20];

            if (0x18 != stream.Read(header, 0, 0x18))
            {
                return(null);
            }
            uint id = LittleEndian.ToUInt32(header, 0);

            if (Signature != id && 0 != id)
            {
                return(null);
            }
            int type = LittleEndian.ToInt32(header, 4);

            if (type != 1 && type != 2)
            {
                return(null);
            }
            int unpacked_size = LittleEndian.ToInt32(header, 0x10);
            int packed_size   = LittleEndian.ToInt32(header, 0x14);

            using (var unpacked = AgfReader.OpenSection(stream, unpacked_size, packed_size))
                using (var reader = new BinaryReader(unpacked))
                {
                    if (0x20 != reader.Read(header, 0, 0x20))
                    {
                        return(null);
                    }
                    var info = new AgfMetaData
                    {
                        Width      = LittleEndian.ToUInt32(header, 0x14),
                        Height     = LittleEndian.ToUInt32(header, 0x18),
                        BPP        = 1 == type ? 24 : 32,
                        SourceBPP  = LittleEndian.ToInt16(header, 0x1E),
                        DataOffset = 0x18 + (uint)packed_size,
                    };
                    if (0 == info.SourceBPP)
                    {
                        return(null);
                    }
                    if (8 == info.SourceBPP)
                    {
                        reader.Read(header, 0, 0x18); // skip rest of the header
                        info.Palette = ReadPalette(reader.BaseStream);
                    }
                    return(info);
                }
        }