SharpAstro.Tga 3.32.1561

This package has a SemVer 2.0.0 package version: 3.32.1561+25f80f8a848ba90b62c5922e98c826c7181bce96.
dotnet add package SharpAstro.Tga --version 3.32.1561
                    
NuGet\Install-Package SharpAstro.Tga -Version 3.32.1561
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SharpAstro.Tga" Version="3.32.1561" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SharpAstro.Tga" Version="3.32.1561" />
                    
Directory.Packages.props
<PackageReference Include="SharpAstro.Tga" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add SharpAstro.Tga --version 3.32.1561
                    
#r "nuget: SharpAstro.Tga, 3.32.1561"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package SharpAstro.Tga@3.32.1561
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=SharpAstro.Tga&version=3.32.1561
                    
Install as a Cake Addin
#tool nuget:?package=SharpAstro.Tga&version=3.32.1561
                    
Install as a Cake Tool

SharpAstro.Tga

Pure-managed Truevision TGA 2.0 reading for .NET 10, written from the Truevision TGA File Format Specification, plus a writer for 24-bit and 32-bit true colour (see "Writing" below).

Supported: colour-mapped, true-colour and greyscale images (types 1, 2, 3), raw or run-length coded (types 9, 10, 11); 8, 15, 16, 24 and 32-bit pixels; 8, 15, 16, 24 and 32-bit colour-map entries; alpha from 32-bit pixels or from the descriptor's attribute bit on 15/16-bit ones; both vertical origins and both horizontal directions. The image ID is skipped. Output is always tightly packed, top-down RGBA8.

using SharpAstro.Tga;

byte[] data = File.ReadAllBytes("image.tga");
TgaImage image = TgaReader.Decode(data);
Console.WriteLine($"{image.Width} × {image.Height}, alpha: {image.HasAlpha}");
byte[] rgba = image.Rgba;

TgaReader.TryReadInfo checks the header without decoding.

The reader refuses with InvalidDataException rather than guessing: a truncated file, an RLE packet running past the end of the image, an unknown image type or depth, a colour index outside the map, a non-zero interleave field, and more than 67,108,864 declared pixels (checked before anything is allocated). Not read: the extension and developer areas, so the "attributes type" byte is not consulted. 16-bit greyscale (grey + alpha) is refused, because the specification does not define it and ImageMagick reads it differently from stb_image.

Every pixel the reader produces is compared byte for byte against ImageMagick's read of the same file in the test suite.

Writing

byte[] tga = TgaWriter.EncodeRgba8(rgba, width, height, new TgaWriteOptions { Rle = true });
byte[] tga24 = TgaWriter.EncodeRgb8(rgb, width, height);

24-bit (EncodeRgb8) and 32-bit (EncodeRgba8, 8 attribute bits) true colour, raw (type 2) or run-length coded (type 10), top-left origin by default (TopOrigin = false for bottom-left). Every file ends with the TGA 2.0 footer (TRUEVISION-XFILE. and a zero byte). RLE packets never cross a scanline, as the specification asks. A wrong buffer length or a dimension outside 1..65535 is an ArgumentException.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on SharpAstro.Tga:

Package Downloads
SharpAstro.Codecs

Image-codec facade over the SharpAstro codec family: sniff a byte stream's format by its magic-byte signature and dispatch to the matching decoder (PNG, JPEG, TIFF, JPEG XR, OpenEXR, JPEG XL, JBIG2, JPEG 2000, WebP, GIF, Radiance RGBE, Netpbm PBM/PGM/PPM/PAM, BMP, and TGA by its TGA 2.0 footer, since a TGA has no leading magic number), returning a codec-neutral IDecodedImage (fidelity tier: native bit depth + ColorEncoding colour signalling, with a ToFloats() RGBA float32 view) or decoding zero-copy into a caller-provided 8-bit RGBA buffer (display tier, integer-sample formats). AOT-compatible.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.32.1561 0 11/3/2026
3.32.1541 0 11/3/2026
3.31.1511 1 11/3/2026
3.30.1461 25 11/3/2026
3.29.1431 22 11/3/2026
3.29.1401 28 11/3/2026
3.29.1361 29 11/3/2026