SharpAstro.Tga 3.41.2071

This package has a SemVer 2.0.0 package version: 3.41.2071+9b6555f0a2b61ce7bf5f250f3486656bb7b52a52.
There is a newer version of this package available.
See the version list below for details.
dotnet add package SharpAstro.Tga --version 3.41.2071
                    
NuGet\Install-Package SharpAstro.Tga -Version 3.41.2071
                    
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.41.2071" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SharpAstro.Tga" Version="3.41.2071" />
                    
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.41.2071
                    
#r "nuget: SharpAstro.Tga, 3.41.2071"
                    
#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.41.2071
                    
#: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.41.2071
                    
Install as a Cake Addin
#tool nuget:?package=SharpAstro.Tga&version=3.41.2071
                    
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.41.2361 0 11/22/2026
3.41.2331 0 11/22/2026
3.41.2301 0 11/21/2026
3.41.2281 0 11/21/2026
3.41.2261 0 11/21/2026
3.41.2231 1,312 11/21/2026
3.41.2161 461 11/21/2026
3.41.2131 52 11/21/2026
3.41.2071 29 11/20/2026
3.40.2051 30 11/20/2026
3.40.2031 28 11/20/2026
3.40.2011 36 11/20/2026
3.40.1991 37 11/18/2026
3.39.1951 39 11/17/2026
3.36.1911 35 11/16/2026
3.36.1891 37 11/16/2026
3.35.1841 40 11/16/2026
3.34.1811 7,096 11/10/2026
3.33.1751 39 11/10/2026
3.33.1711 39 11/10/2026
Loading failed