Gorgon
Show / Hide Table of Contents

Class GorgonCodecGif

A codec to handle reading/writing GIF files.

Inheritance
object
GorgonImageCodec<GorgonGifEncodingOptions, GorgonGifDecodingOptions>
GorgonCodecWic<GorgonGifEncodingOptions, GorgonGifDecodingOptions>
GorgonCodecGif
Implements
IGorgonImageCodec
IGorgonNamedObject
Inherited Members
GorgonCodecWic<GorgonGifEncodingOptions, GorgonGifDecodingOptions>.Codec
GorgonCodecWic<GorgonGifEncodingOptions, GorgonGifDecodingOptions>.CodecDescription
GorgonCodecWic<GorgonGifEncodingOptions, GorgonGifDecodingOptions>.SupportsBlockCompression
GorgonCodecWic<GorgonGifEncodingOptions, GorgonGifDecodingOptions>.SupportsMipMaps
GorgonCodecWic<GorgonGifEncodingOptions, GorgonGifDecodingOptions>.SupportsDepth
GorgonCodecWic<GorgonGifEncodingOptions, GorgonGifDecodingOptions>.SupportedPixelFormats
GorgonCodecWic<GorgonGifEncodingOptions, GorgonGifDecodingOptions>.Save(IGorgonImage, Stream)
GorgonCodecWic<GorgonGifEncodingOptions, GorgonGifDecodingOptions>.GetMetaData(Stream)
GorgonCodecWic<GorgonGifEncodingOptions, GorgonGifDecodingOptions>.GetMetaData(Stream, IGorgonWicDecodingOptions)
GorgonCodecWic<GorgonGifEncodingOptions, GorgonGifDecodingOptions>.GetFrameOffsets(string)
GorgonCodecWic<GorgonGifEncodingOptions, GorgonGifDecodingOptions>.GetFrameOffsets(Stream)
GorgonCodecWic<GorgonGifEncodingOptions, GorgonGifDecodingOptions>.IsReadable(Stream)
GorgonImageCodec<GorgonGifEncodingOptions, GorgonGifDecodingOptions>.SupportsMultipleFrames
GorgonImageCodec<GorgonGifEncodingOptions, GorgonGifDecodingOptions>.CanEncode
GorgonImageCodec<GorgonGifEncodingOptions, GorgonGifDecodingOptions>.CanDecode
GorgonImageCodec<GorgonGifEncodingOptions, GorgonGifDecodingOptions>.CodecCommonExtensions
GorgonImageCodec<GorgonGifEncodingOptions, GorgonGifDecodingOptions>.FromStream(Stream, long?)
GorgonImageCodec<GorgonGifEncodingOptions, GorgonGifDecodingOptions>.FromFile(string)
GorgonImageCodec<GorgonGifEncodingOptions, GorgonGifDecodingOptions>.Save(IGorgonImage, string)
GorgonImageCodec<GorgonGifEncodingOptions, GorgonGifDecodingOptions>.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 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 Source

GorgonCodecGif(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 Source

FrameOffsetMetadataNames

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
GorgonCodecWic<GorgonGifEncodingOptions, GorgonGifDecodingOptions>.FrameOffsetMetadataNames
Remarks

Implementors must put the horizontal offset name first, and the vertical name second. Failure to do so will lead to incorrect offsets.

| 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<GorgonGifEncodingOptions, GorgonGifDecodingOptions>.SupportsMultipleFrames

Methods

| Edit this page View Source

GetCustomEncodingMetadata(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
GorgonCodecWic<GorgonGifEncodingOptions, GorgonGifDecodingOptions>.GetCustomEncodingMetadata(int, IGorgonImageInfo)
| Edit this page View Source

GetFrameDelays(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 stream parameter is null.

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.

| Edit this page View Source

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 filePath parameter is null.

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.

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