/// <summary>Queues the chunk at the writer</summary> /// <param name="chunk">Chunk, ready for write</param> /// <param name="lazyOverwrite">Ovewrite lazily equivalent chunks</param> /// <remarks>Warning: the overwriting applies to equivalent chunks, see <c>ChunkPredicateEquiv</c> /// and will only make sense for queued (not yet writen) chunks /// </remarks> public void QueueChunk(PngChunk chunk, bool lazyOverwrite) { ChunksListForWrite cl = GetChunkListW(); if (ReadOnly) { throw new PngjException("cannot set chunk : readonly metadata"); } if (lazyOverwrite) { ChunkHelper.TrimList(cl.GetQueuedChunks(), new ChunkPredicateEquiv(chunk)); } cl.Queue(chunk); }
public PngWriter(Stream outputStream, ImageInfo imgInfo, string filename) { this.filename = ((filename == null) ? "" : filename); this.outputStream = outputStream; ImgInfo = imgInfo; CompLevel = 6; ShouldCloseStream = true; IdatMaxSize = 0; CompressionStrategy = EDeflateCompressStrategy.Filtered; rowb = new byte[imgInfo.BytesPerRow + 1]; rowbprev = new byte[rowb.Length]; rowbfilter = new byte[rowb.Length]; chunksList = new ChunksListForWrite(ImgInfo); metadata = new PngMetadata(chunksList); filterStrat = new FilterWriteStrategy(ImgInfo, FilterType.FILTER_DEFAULT); unpackedMode = false; needsPack = (unpackedMode && imgInfo.Packed); }
public PngWriter( Stream outputStream, ImageInfo imgInfo, String filename ) { this.filename = ( filename == null ) ? "" : filename; this.outputStream = outputStream; this.ImgInfo = imgInfo; this.CompLevel = 6; this.ShouldCloseStream = true; this.IdatMaxSize = 0; this.CompressionStrategy = EDeflateCompressStrategy.Filtered; rowb = new byte [ imgInfo.BytesPerRow + 1 ]; rowbprev = new byte [ rowb.Length ]; rowbfilter = new byte [ rowb.Length ]; chunksList = new ChunksListForWrite ( ImgInfo ); metadata = new PngMetadata ( chunksList ); filterStrat = new FilterWriteStrategy ( ImgInfo, FilterType.FILTER_DEFAULT ); unpackedMode = false; needsPack = unpackedMode && imgInfo.Packed; }
/// <summary> /// Constructs a PngWriter from a outputStream, with optional filename or description /// </summary> /// <remarks> /// After construction nothing is writen yet. You still can set some /// parameters (compression, filters) and queue chunks before start writing the pixels. /// /// See also <c>FileHelper.createPngWriter()</c> /// </remarks> /// <param name="outputStream">Opened stream for binary writing</param> /// <param name="imgInfo">Basic image parameters</param> /// <param name="filename">Optional, can be the filename or a description.</param> public PngWriter(Stream outputStream, ImageInfo imgInfo, String filename) { this.filename = filename == null ? "" : filename; this.outputStream = outputStream; ImgInfo = imgInfo; // defaults settings CompLevel = 6; ShouldCloseStream = true; IdatMaxSize = 0; // use default CompressionStrategy = EDeflateCompressStrategy.Filtered; // prealloc //scanline = new int[imgInfo.SamplesPerRowPacked]; rowb = new byte[imgInfo.BytesPerRow + 1]; rowbprev = new byte[rowb.Length]; rowbfilter = new byte[rowb.Length]; chunksList = new ChunksListForWrite(ImgInfo); metadata = new PngMetadata(chunksList); filterStrat = new FilterWriteStrategy(ImgInfo, FilterType.FILTER_DEFAULT); unpackedMode = false; needsPack = unpackedMode && imgInfo.Packed; }