コード例 #1
0
 /// <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 ?? "";
     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);
     IsUnpackedMode = false;
     needsPack      = IsUnpackedMode && imgInfo.Packed;
 }
コード例 #2
0
 /// <summary> Sets internal prediction filter type, or strategy to choose it. </summary>
 /// <remarks>
 /// This must be called just after constructor, before starting writing.
 /// Recommended values: DEFAULT (default) or AGGRESIVE
 /// </remarks>
 /// <param name="filterType"> One of the five prediction types or strategy to choose it </param>
 public void SetFilterType(FilterType filterType) => filterStrat = new FilterWriteStrategy(ImgInfo, filterType);