private void WriteFirstChunks()
{
int nw = 0;
CurrentChunkGroup = ChunksList.CHUNK_GROUP_1_AFTERIDHR;
nw = chunksList.writeChunks(outputStream, CurrentChunkGroup);
CurrentChunkGroup = ChunksList.CHUNK_GROUP_2_PLTE;
nw = chunksList.writeChunks(outputStream, CurrentChunkGroup);
if (nw > 0 && ImgInfo.Greyscale)
throw new PngjOutputException("cannot write palette for this format");
if (nw == 0 && ImgInfo.Indexed)
throw new PngjOutputException("missing palette");
CurrentChunkGroup = ChunksList.CHUNK_GROUP_3_AFTERPLTE;
nw = chunksList.writeChunks(outputStream, CurrentChunkGroup);
CurrentChunkGroup = ChunksList.CHUNK_GROUP_4_IDAT;
}