Example #1
0
 public void Write(Chunk chunk)
 {
     Write(PngHelper.DWordToInt(chunk.Length));
     Write(chunk.Type);
     Write(chunk.Data,0,chunk.Data.Length);
     Write(PngHelper.DWordToInt((int)Crc32.Calc(chunk.Type,chunk.Data)));
 }
Example #2
0
        public static DateTime ConvertTIME(Chunk chunk)
        {
            byte[] data = chunk.Data;

            int ofs = 0;
            int year = WordToInt(BitConverter.ToUInt16(data,ofs)); ofs+=sizeof(Int16);
            byte month = data[ofs++];
            byte day = data[ofs++];
            byte hour = data[ofs++];
            byte min = data[ofs++];
            byte sec = data[ofs++];

            return new DateTime(year,month,day,hour,min,sec);
        }
Example #3
0
        public static PngHeader ConvertIHDR(Chunk chunk)
        {
            byte[] data = chunk.Data;

            int ofs = 0;
            int columns = DWordToInt(BitConverter.ToInt32(data,ofs)); ofs += 4;
            int rows = DWordToInt(BitConverter.ToInt32(data,ofs)); ofs += 4;

            // bit depth: number of bits per channel
            byte bitdepth = data[ofs++];
            byte colormodel = data[ofs++];

            byte compmeth = data[ofs++];
            byte filmeth = data[ofs++];

            byte interlaced = data[ofs++];
            if(interlaced>0)
                throw new NotSupportedException("interlaced png");

            return new PngHeader(columns,rows,bitdepth,(ColorModel)colormodel);
        }
Example #4
0
 public static RenderingIntent ConvertSRGB(Chunk chunk)
 {
     return (RenderingIntent)chunk.Data[0];
 }