/
TgaEncoder.cs
27 lines (23 loc) · 925 Bytes
/
TgaEncoder.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.
namespace SixLabors.ImageSharp.Formats.Tga;
/// <summary>
/// Image encoder for writing an image to a stream as a Targa true-vision image.
/// </summary>
public sealed class TgaEncoder : ImageEncoder
{
/// <summary>
/// Gets the number of bits per pixel.
/// </summary>
public TgaBitsPerPixel? BitsPerPixel { get; init; }
/// <summary>
/// Gets a value indicating whether no compression or run length compression should be used.
/// </summary>
public TgaCompression Compression { get; init; } = TgaCompression.RunLength;
/// <inheritdoc/>
protected override void Encode<TPixel>(Image<TPixel> image, Stream stream, CancellationToken cancellationToken)
{
TgaEncoderCore encoder = new(this, image.Configuration.MemoryAllocator);
encoder.Encode(image, stream, cancellationToken);
}
}