示例#1
0
        public override byte[] GetBytes()
        {
            byte[] bytes = new byte[13];
            ByteUtils.GetBytes(Width).CopyTo(bytes, 0);
            ByteUtils.GetBytes(Height).CopyTo(bytes, 4);
            bytes[8]  = BitDepth;
            bytes[9]  = ColourType;
            bytes[10] = CompressionMethod;
            bytes[11] = FilterMethod;
            bytes[12] = InterlaceMethod;

            return(bytes);
        }
示例#2
0
        /// <summary>
        /// Return chunk as a byte array
        /// </summary>
        /// <returns>whole data chunk, as byte array</returns>
        public byte[] GetBytes()
        {
            UpdateData();
            UpdateLength();
            UpdateCrc();

            byte[] bytes = new byte[Length + 12];
            Array.Copy(ByteUtils.GetBytes(Length), 0, bytes, 0, 4);
            Array.Copy(Type.Type, 0, bytes, 4, 4);
            Array.Copy(data, 0, bytes, 8, Length);
            Array.Copy(ByteUtils.GetBytes(CRC), 0, bytes, Length + 8, 4);

            return(bytes);
        }
示例#3
0
        public override string ToString()
        {
            StringBuilder ret = new StringBuilder();

            ret.Append(Length);
            ret.Append(' ');
            foreach (byte b in Type.Type)
            {
                ret.Append((char)b);
            }
            ret.Append(' ');
            foreach (byte b in Data)
            {
                ret.Append(b);
            }
            ret.Append(' ');
            foreach (byte b in ByteUtils.GetBytes(CRC))
            {
                ret.Append(b.ToString("X2"));
            }

            return(ret.ToString());
        }
示例#4
0
 public override byte[] GetBytes()
 {
     return(ByteUtils.GetBytes(gamma));
 }