Class GorgonCodecGif
A codec to handle reading/writing GIF files.
Inheritance
Inherited Members
Namespace: Gorgon.Graphics.Imaging.Codecs
Assembly: Gorgon.Graphics.Imaging.dll
Syntax
public sealed class GorgonCodecGif : GorgonCodecWic<GorgonGifEncodingOptions, GorgonGifDecodingOptions>, IGorgonImageCodec, IGorgonNamedObject
Remarks
This codec will read and write lossless compressed files using the Graphics Interchange Format (GIF).
This codec only supports 1, 4, and 8 bit indexed pixel formats, and uses a palette to define the actual colors at the indices for each pixel. All data decoded will be encoded using the 32 bit R8G8B8A8_UNorm pixel format. Data encoded with this codec will be downsampled to 8 bit indexed data.
Constructors
| Edit this page View SourceGorgonCodecGif(GorgonGifEncodingOptions, GorgonGifDecodingOptions)
Initializes a new instance of the GorgonCodecGif class.
Declaration
public GorgonCodecGif(GorgonGifEncodingOptions encodingOptions = null, GorgonGifDecodingOptions decodingOptions = null)
Parameters
Type | Name | Description |
---|---|---|
GorgonGifEncodingOptions | encodingOptions | [Optional] Options to use when encoding a GIF file. |
GorgonGifDecodingOptions | decodingOptions | [Optional] Options to use when decoding a GIF file. |
Properties
| Edit this page View SourceFrameOffsetMetadataNames
Property to return the list of names used to locate frame offsets in metadata.
Declaration
protected override IReadOnlyList<string> FrameOffsetMetadataNames { get; }
Property Value
Type | Description |
---|---|
IReadOnlyList<string> |
Overrides
Remarks
Implementors must put the horizontal offset name first, and the vertical name second. Failure to do so will lead to incorrect offsets.
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
Methods
| Edit this page View SourceGetCustomEncodingMetadata(int, IGorgonImageInfo)
Function to retrieve custom metadata when encoding an image frame.
Declaration
protected override IReadOnlyDictionary<string, object> GetCustomEncodingMetadata(int frameIndex, IGorgonImageInfo settings)
Parameters
Type | Name | Description |
---|---|---|
int | frameIndex | The index of the frame being encoded. |
IGorgonImageInfo | settings | The settings for the image being encoded. |
Returns
Type | Description |
---|---|
IReadOnlyDictionary<string, object> | A dictionary containing the key/value pair describing the metadata to write to the frame, or null if the frame contains no metadata. |
Overrides
| Edit this page View SourceGetFrameDelays(Stream)
Function to retrieve a list of frame delays for each frame in an animated GIF.
Declaration
public IReadOnlyList<int> GetFrameDelays(Stream stream)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | Stream containing the animated GIF. |
Returns
Type | Description |
---|---|
IReadOnlyList<int> | An array of frame delays (1/100th of a second), or an empty array if the image is not an animated GIF. |
Remarks
This will return the delay (in 1/100ths of a second) between each frame in a multi-frame animated GIF. If the GIF file only has a single frame, then an empty array is returned.
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when the |
IOException | Thrown when the stream parameter is write-only. -or- The data in the stream could not be decoded as GIF file. -or- The stream cannot perform seek operations. |
EndOfStreamException | Thrown when an attempt to read beyond the end of the stream is made. |
GetFrameDelays(string)
Function to retrieve a list of frame delays for each frame in an animated GIF.
Declaration
public IReadOnlyList<int> GetFrameDelays(string filePath)
Parameters
Type | Name | Description |
---|---|---|
string | filePath | Path to the animated GIF file. |
Returns
Type | Description |
---|---|
IReadOnlyList<int> | An array of frame delays (1/100th of a second), or an empty array if the image is not an animated GIF. |
Remarks
This will return the delay (in 1/100ths of a second) between each frame in a multi-frame animated GIF. If the GIF file only has a single frame, then an empty array is returned.
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when the |
ArgumentException | Thown when the filePath parameter is empty. |
IOException | Thrown when the stream parameter is write-only. -or- The data in the stream could not be decoded as GIF file. -or- The stream cannot perform seek operations. |
EndOfStreamException | Thrown when an attempt to read beyond the end of the stream is made. |