Beispiel #1
0
        public void Read(BinaryReader br)
        {
            Left   = br.ReadUInt16();
            Top    = br.ReadUInt16();
            Width  = br.ReadUInt16();
            Height = br.ReadUInt16();

            var interlace = ReadPacked(br);

            LocalColorTable?.ReadTable(br);
            ReadImage(br, interlace);
        }
        /// <summary>
        /// Populates the local color table byte[] from the source image, and performs lexical parsing on the array.
        /// </summary>
        /// <param name="bytes"></param>
        public static LocalColorTable ParseLocalColorTable(byte[] bytes)
        {
            LocalColorTable lct = new LocalColorTable()
            {
                TotalBlockLength   = bytes.Length,
                DistinctColorCount = bytes.Length / 3,
                Bytes = (byte[])bytes.Clone()
            };

            for (int i = 0; i <= bytes.Length - 3; i += 3)
            {
                lct.Colors.Add(new byte[3] {
                    bytes[i], bytes[1 + 1], bytes[i + 2]
                });
            }

            return(lct);
        }