Exemple #1
0
        public AgfReader(Stream input, AgfMetaData info)
        {
            m_input        = new ArcView.Reader(input);
            m_bpp          = info.BPP;
            m_source_bpp   = info.SourceBPP;
            input.Position = info.DataOffset;

            m_width   = (int)info.Width;
            m_height  = (int)info.Height;
            m_output  = new byte[m_height * m_width * m_bpp / 8];
            m_palette = info.Palette;
        }
Exemple #2
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);
                }
        }
Exemple #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;
     }
 }
Exemple #4
0
        public AgfReader(Stream input, AgfMetaData info)
        {
            m_input = new ArcView.Reader (input);
            m_bpp = info.BPP;
            m_source_bpp = info.SourceBPP;
            input.Position = info.DataOffset;

            m_width = (int)info.Width;
            m_height = (int)info.Height;
            m_output = new byte[m_height * m_width * m_bpp / 8];
            m_palette = info.Palette;
        }