Gorgon
Show / Hide Table of Contents

Class GorgonCodecTga

A codec to handle reading/writing Truevision TGA files.

Inheritance
object
GorgonImageCodec<IGorgonImageCodecEncodingOptions, GorgonTgaDecodingOptions>
GorgonCodecTga
Implements
IGorgonImageCodec
IGorgonNamedObject
Inherited Members
GorgonImageCodec<IGorgonImageCodecEncodingOptions, GorgonTgaDecodingOptions>.SupportsMultipleFrames
GorgonImageCodec<IGorgonImageCodecEncodingOptions, GorgonTgaDecodingOptions>.CanEncode
GorgonImageCodec<IGorgonImageCodecEncodingOptions, GorgonTgaDecodingOptions>.CanDecode
GorgonImageCodec<IGorgonImageCodecEncodingOptions, GorgonTgaDecodingOptions>.CodecCommonExtensions
GorgonImageCodec<IGorgonImageCodecEncodingOptions, GorgonTgaDecodingOptions>.CodecDescription
GorgonImageCodec<IGorgonImageCodecEncodingOptions, GorgonTgaDecodingOptions>.Codec
GorgonImageCodec<IGorgonImageCodecEncodingOptions, GorgonTgaDecodingOptions>.SupportedPixelFormats
GorgonImageCodec<IGorgonImageCodecEncodingOptions, GorgonTgaDecodingOptions>.SupportsDepth
GorgonImageCodec<IGorgonImageCodecEncodingOptions, GorgonTgaDecodingOptions>.SupportsMipMaps
GorgonImageCodec<IGorgonImageCodecEncodingOptions, GorgonTgaDecodingOptions>.SupportsBlockCompression
GorgonImageCodec<IGorgonImageCodecEncodingOptions, GorgonTgaDecodingOptions>.FromStream(Stream, long?)
GorgonImageCodec<IGorgonImageCodecEncodingOptions, GorgonTgaDecodingOptions>.FromFile(string)
GorgonImageCodec<IGorgonImageCodecEncodingOptions, GorgonTgaDecodingOptions>.Save(IGorgonImage, Stream)
GorgonImageCodec<IGorgonImageCodecEncodingOptions, GorgonTgaDecodingOptions>.Save(IGorgonImage, string)
GorgonImageCodec<IGorgonImageCodecEncodingOptions, GorgonTgaDecodingOptions>.IsReadable(Stream)
GorgonImageCodec<IGorgonImageCodecEncodingOptions, GorgonTgaDecodingOptions>.GetMetaData(Stream)
GorgonImageCodec<IGorgonImageCodecEncodingOptions, GorgonTgaDecodingOptions>.ToString()
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
object.GetType()
Namespace: Gorgon.Graphics.Imaging.Codecs
Assembly: Gorgon.Graphics.Imaging.dll
Syntax
public sealed class GorgonCodecTga : GorgonImageCodec<IGorgonImageCodecEncodingOptions, GorgonTgaDecodingOptions>, IGorgonImageCodec, IGorgonNamedObject
Remarks

This codec will read RLE compressed and uncompressed files, and write compressed files using the Truevision Targa (TGA) format.

Most 16/24/32 bit TGA files will be readable using this codec, however the following limitations may keep the file from being decoded by this codec:

  • No color map support.
  • Interleaved files are not supported.
  • Supports the following formats: 8 bit grayscale, 16, 24 and 32 bits per pixel images.

Constructors

| Edit this page View Source

GorgonCodecTga(GorgonTgaDecodingOptions)

Initializes a new instance of the GorgonCodecTga class.

Declaration
public GorgonCodecTga(GorgonTgaDecodingOptions decodingOptions = null)
Parameters
Type Name Description
GorgonTgaDecodingOptions decodingOptions

[Optional] Codec specific options to use when decoding image data.

Properties

| Edit this page View Source

Codec

Property to return the abbreviated name of the codec (e.g. PNG).

Declaration
public override string Codec { get; }
Property Value
Type Description
string
Overrides
GorgonImageCodec<IGorgonImageCodecEncodingOptions, GorgonTgaDecodingOptions>.Codec
| Edit this page View Source

CodecDescription

Property to return the friendly description of the format.

Declaration
public override string CodecDescription { get; }
Property Value
Type Description
string
Overrides
GorgonImageCodec<IGorgonImageCodecEncodingOptions, GorgonTgaDecodingOptions>.CodecDescription
| Edit this page View Source

SupportedPixelFormats

Property to return the pixel formats supported by the codec.

Declaration
public override IReadOnlyList<BufferFormat> SupportedPixelFormats { get; }
Property Value
Type Description
IReadOnlyList<BufferFormat>
Overrides
GorgonImageCodec<IGorgonImageCodecEncodingOptions, GorgonTgaDecodingOptions>.SupportedPixelFormats
| Edit this page View Source

SupportsBlockCompression

Property to return whether the image codec supports block compression.

Declaration
public override bool SupportsBlockCompression { get; }
Property Value
Type Description
bool
Overrides
GorgonImageCodec<IGorgonImageCodecEncodingOptions, GorgonTgaDecodingOptions>.SupportsBlockCompression
| Edit this page View Source

SupportsDepth

Property to return whether the image codec supports a depth component for volume textures.

Declaration
public override bool SupportsDepth { get; }
Property Value
Type Description
bool
Overrides
GorgonImageCodec<IGorgonImageCodecEncodingOptions, GorgonTgaDecodingOptions>.SupportsDepth
| Edit this page View Source

SupportsMipMaps

Property to return whether the image codec supports mip maps.

Declaration
public override bool SupportsMipMaps { get; }
Property Value
Type Description
bool
Overrides
GorgonImageCodec<IGorgonImageCodecEncodingOptions, GorgonTgaDecodingOptions>.SupportsMipMaps
| Edit this page View Source

SupportsMultipleFrames

Property to return whether the codec supports decoding/encoding multiple frames or not.

Declaration
public override bool SupportsMultipleFrames { get; }
Property Value
Type Description
bool
Overrides
GorgonImageCodec<IGorgonImageCodecEncodingOptions, GorgonTgaDecodingOptions>.SupportsMultipleFrames

Methods

| Edit this page View Source

GetMetaData(Stream)

Function to read the meta data for image data within a stream.

Declaration
public override IGorgonImageInfo GetMetaData(Stream stream)
Parameters
Type Name Description
Stream stream

The stream containing the metadata to read.

Returns
Type Description
IGorgonImageInfo

The image meta data as a IGorgonImageInfo value.

Overrides
GorgonImageCodec<IGorgonImageCodecEncodingOptions, GorgonTgaDecodingOptions>.GetMetaData(Stream)
Remarks

Ensure that the file can be read by calling the IsReadable(Stream) method prior to calling this method.

Exceptions
Type Condition
IOException

Thrown when the stream is write-only or if the stream cannot perform seek operations.

-or-

Thrown if the file is corrupt or can't be read by the codec.

ArgumentNullException

Thrown when the stream parameter is null.

IOException

Thrown when the stream is write-only or if the stream cannot perform seek operations.

EndOfStreamException

Thrown when an attempt to read beyond the end of the stream is made.

See Also
IsReadable(Stream)
| Edit this page View Source

IsReadable(Stream)

Function to determine if this codec can read the image data within the stream or not.

Declaration
public override bool IsReadable(Stream stream)
Parameters
Type Name Description
Stream stream

The stream that is used to read the image data.

Returns
Type Description
bool

true if the codec can read the file, false if not.

Overrides
GorgonImageCodec<IGorgonImageCodecEncodingOptions, GorgonTgaDecodingOptions>.IsReadable(Stream)
Exceptions
Type Condition
ArgumentNullException

Thrown when the stream parameter is null.

IOException

Thrown when the stream is write-only or if the stream cannot perform seek operations.

| Edit this page View Source

OnDecodeFromStream(Stream, long)

Function to load an image from a stream.

Declaration
protected override IGorgonImage OnDecodeFromStream(Stream stream, long size)
Parameters
Type Name Description
Stream stream

The stream containing the image data to read.

long size

The size of the image within the stream, in bytes.

Returns
Type Description
IGorgonImage

A IGorgonImage containing the image data from the stream.

Overrides
GorgonImageCodec<IGorgonImageCodecEncodingOptions, GorgonTgaDecodingOptions>.OnDecodeFromStream(Stream, long)
Exceptions
Type Condition
GorgonException

Thrown when the image data in the stream has a pixel format that is unsupported.

| Edit this page View Source

Save(IGorgonImage, Stream)

Function to persist a IGorgonImage to a stream.

Declaration
public override void Save(IGorgonImage imageData, Stream stream)
Parameters
Type Name Description
IGorgonImage imageData

A IGorgonImage to persist to the stream.

Stream stream

The stream that will receive the image data.

Overrides
GorgonImageCodec<IGorgonImageCodecEncodingOptions, GorgonTgaDecodingOptions>.Save(IGorgonImage, Stream)
Remarks

When persisting image data via a codec, the image must have a format that the codec can recognize. This list of supported formats is provided by the SupportedPixelFormats property. Applications may convert their image data a supported format before saving the data using a codec.

Exceptions
Type Condition
ArgumentNullException

Thrown when the stream, or the imageData parameter is null.

ArgumentEmptyException

Thrown when the stream is read only.

NotSupportedException

Thrown when the image data in the stream has a pixel format that is unsupported by the codec.

Implements

IGorgonImageCodec
IGorgonNamedObject

Extension Methods

GorgonDebugExtensions.ValidateObject<T>(T, string)
GorgonNullExtensions.AsNullable<T>(object)
GorgonNullExtensions.IfNull<T>(object, T)
GorgonNullExtensions.IsNull(object)
  • Edit this page
  • View Source
In this article
Back to top Copyright 2023 - Licensed under the MIT license by Michael Winsor (Tape_Worm).
Send comments on this topic to the author