Beispiel #1
0
 public CandyDecoder(IBinaryStream input, CandyMetaData info)
 {
     m_input  = input;
     m_info   = info;
     m_width  = (int)info.Width;
     m_height = (int)info.Height;
     m_colors = info.Colors;
     if (24 == info.BPP || (32 == info.BPP && 1 == info.Version))
     {
         m_pixel_size = 3;
         m_stride     = m_width * 3;
         Format       = PixelFormats.Bgr24;
     }
     else if (32 == info.BPP)
     {
         m_pixel_size = 4;
         m_stride     = m_width * 4;
         Format       = PixelFormats.Bgra32;
     }
     else
     {
         m_pixel_size = 1;
         m_stride     = m_width;
         Format       = PixelFormats.Indexed8;
     }
     m_output = new byte[m_stride * m_height];
 }
Beispiel #2
0
 public CandyDecoder(IBinaryStream input, CandyMetaData info)
 {
     m_input  = input;
     m_width  = (int)info.Width;
     m_height = (int)info.Height;
     m_colors = info.Colors;
     if (32 == info.BPP)
     {
         m_stride = (int)m_width * 3;
         Format   = PixelFormats.Bgr24;
     }
     else
     {
         m_stride = (int)m_width;
         Format   = PixelFormats.Indexed8;
     }
     m_output = new byte[m_stride * m_height];
 }
Beispiel #3
0
        public override ImageMetaData ReadMetaData(IBinaryStream file)
        {
            var           header      = file.ReadHeader(14);
            int           header_size = BigEndian.ToUInt16(header, 0);
            CandyMetaData info;

            if (14 == header_size)
            {
                info = new CandyMetaData {
                    OffsetX    = BigEndian.ToInt16(header, 2),
                    OffsetY    = BigEndian.ToInt16(header, 4),
                    Width      = BigEndian.ToUInt16(header, 6),
                    Height     = BigEndian.ToUInt16(header, 8),
                    BPP        = header[0xA],
                    Colors     = BigEndian.ToUInt16(header, 0xC),
                    Version    = header[0xB],
                    HeaderSize = header_size,
                };
            }
            else if (10 == header_size)
            {
                info = new CandyMetaData {
                    Width      = BigEndian.ToUInt16(header, 2),
                    Height     = BigEndian.ToUInt16(header, 4),
                    BPP        = header[6],
                    Colors     = BigEndian.ToUInt16(header, 8),
                    Version    = header[7],
                    HeaderSize = header_size,
                };
            }
            else
            {
                return(null);
            }
            if (info.Version != 1 && info.Version != 2 || info.BPP < 8 || info.BPP > 32)
            {
                return(null);
            }
            return(info);
        }