/// <summary> /// Write id signature and also "IHDR" chunk /// </summary> /// private void WriteSignatureAndIHDR() { CurrentChunkGroup = ChunksList.CHUNK_GROUP_0_IDHR; PngHelperInternal.WriteBytes(outputStream, Hjg.Pngcs.PngHelperInternal.PNG_ID_SIGNATURE); // signature PngChunkIHDR ihdr = new PngChunkIHDR(ImgInfo); // http://www.libpng.org/pub/png/spec/1.2/PNG-Chunks.html ihdr.Cols = ImgInfo.Cols; ihdr.Rows = ImgInfo.Rows; ihdr.Bitspc = ImgInfo.BitDepth; int colormodel = 0; if (ImgInfo.Alpha) { colormodel += 0x04; } if (ImgInfo.Indexed) { colormodel += 0x01; } if (!ImgInfo.Greyscale) { colormodel += 0x02; } ihdr.Colormodel = colormodel; ihdr.Compmeth = 0; // compression method 0=deflate ihdr.Filmeth = 0; // filter method (0) ihdr.Interlaced = 0; // never interlace ihdr.CreateRawChunk().WriteChunk(outputStream); }
public void WriteSignatureAndIHDR() { CurrentChunkGroup = 0; PngHelperInternal.WriteBytes(outputStream, PngHelperInternal.PNG_ID_SIGNATURE); PngChunkIHDR obj = new PngChunkIHDR(ImgInfo) { Cols = ImgInfo.Cols, Rows = ImgInfo.Rows, Bitspc = ImgInfo.BitDepth }; int num = 0; if (ImgInfo.Alpha) { num += 4; } if (ImgInfo.Indexed) { num++; } if (!ImgInfo.Greyscale) { num += 2; } obj.Colormodel = num; obj.Compmeth = 0; obj.Filmeth = 0; obj.Interlaced = 0; obj.CreateRawChunk().WriteChunk(outputStream); }