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))); }
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); }
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); }
public static RenderingIntent ConvertSRGB(Chunk chunk) { return (RenderingIntent)chunk.Data[0]; }