Example #1
0
 /// <inheritdoc/>
 public async Task EncodeAsync <TPixel>(Image <TPixel> image, Stream stream, CancellationToken cancellationToken) where TPixel : unmanaged, IPixel <TPixel>
 {
     // The introduction of a local variable that refers to an object the implements
     // IDisposable means you must use async/await, where the compiler generates the
     // state machine and a continuation.
     using var encoder = new PictEncoderCore(image.GetConfiguration().MemoryAllocator, image.GetConfiguration(), new PictEncodingOptions(this));
     await encoder.EncodeAsync(image, stream, cancellationToken).ConfigureAwait(false);
 }
Example #2
0
 /// <inheritdoc/>
 public void Encode <TPixel>(Image <TPixel> image, Stream stream) where TPixel : unmanaged, IPixel <TPixel>
 {
     using var encoder = new PictEncoderCore(image.GetConfiguration().MemoryAllocator, image.GetConfiguration(), new PictEncodingOptions(this));
     encoder.Encode(image, stream);
 }