Gorgon
Show / Hide Table of Contents

Class GorgonAnimationCodecCommon

A base class containing common codec functionality.

Inheritance
object
GorgonAnimationCodecCommon
GorgonV1AnimationCodec
GorgonV31AnimationBinaryCodec
GorgonV31AnimationJsonCodec
GorgonV3AnimationBinaryCodec
GorgonV3AnimationJsonCodec
Implements
IGorgonAnimationCodec
IGorgonNamedObject
Inherited Members
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
Namespace: Gorgon.IO
Assembly: Gorgon.IO.Gorgon2D.dll
Syntax
public abstract class GorgonAnimationCodecCommon : IGorgonAnimationCodec, IGorgonNamedObject

Constructors

| Edit this page View Source

GorgonAnimationCodecCommon(Gorgon2D, string, string)

Initializes a new instance of the GorgonAnimationCodecCommon class.

Declaration
protected GorgonAnimationCodecCommon(Gorgon2D renderer, string name, string description)
Parameters
Type Name Description
Gorgon2D renderer

The renderer used for resource handling.

string name

The codec name.

string description

The friendly description for the codec.

Exceptions
Type Condition
ArgumentNullException

Thrown when the renderer, or the name parameter is null.

ArgumentEmptyException

Thrown when the name parameter is empty.

Fields

| Edit this page View Source

CurrentFileHeader

The ID for the file header for the most current version of the animation format.

Declaration
public static readonly ulong CurrentFileHeader
Field Value
Type Description
ulong
| Edit this page View Source

CurrentVersion

The highest currently supported version for animation serialization.

Declaration
public static readonly Version CurrentVersion
Field Value
Type Description
Version

Properties

| Edit this page View Source

CanDecode

Property to return whether or not the codec can decode animation data.

Declaration
public abstract bool CanDecode { get; }
Property Value
Type Description
bool
| Edit this page View Source

CanEncode

Property to return whether or not the codec can encode animation data.

Declaration
public abstract bool CanEncode { get; }
Property Value
Type Description
bool
| Edit this page View Source

Codec

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

Declaration
public string Codec { get; }
Property Value
Type Description
string
| Edit this page View Source

CodecDescription

Property to return the friendly description of the format.

Declaration
public string CodecDescription { get; }
Property Value
Type Description
string
| Edit this page View Source

FileExtensions

Property to return the common file extensions for an animation.

Declaration
public IReadOnlyList<GorgonFileExtension> FileExtensions { get; protected set; }
Property Value
Type Description
IReadOnlyList<GorgonFileExtension>
| Edit this page View Source

Graphics

Property to return the graphics interface that built this object.

Declaration
public GorgonGraphics Graphics { get; }
Property Value
Type Description
GorgonGraphics
| Edit this page View Source

Renderer

Property to return the renderer used to create objects.

Declaration
public Gorgon2D Renderer { get; }
Property Value
Type Description
Gorgon2D
| Edit this page View Source

Version

Property to return the version of animation data that the codec supports.

Declaration
public abstract Version Version { get; }
Property Value
Type Description
Version

Methods

| Edit this page View Source

FromFile(string, string, IEnumerable<GorgonTexture2DView>)

Function to read the animation data from a file on the physical file system.

Declaration
public IGorgonAnimation FromFile(string filePath, string name = null, IEnumerable<GorgonTexture2DView> textureOverrides = null)
Parameters
Type Name Description
string filePath

The path to the file to read.

string name

[Optional] The name of the animation.

IEnumerable<GorgonTexture2DView> textureOverrides

[Optional] Textures to use in a texture animation track.

Returns
Type Description
IGorgonAnimation

A new IGorgonAnimation.

Remarks

When passing in a list of textureOverrides, the texture names should match the expected texture names in the key frame. For example, if the TextureName is "WalkingFrames", then the Name should also be "WalkingFrames".

Exceptions
Type Condition
ArgumentNullException

Thrown when the filePath parameter is null.

ArgumentEmptyException

Thrown when the filePath parameter is empty.

NotSupportedException

This method is not supported by this codec.

| Edit this page View Source

FromStream(Stream, int?, string, IEnumerable<GorgonTexture2DView>)

Function to read the animation data from a stream.

Declaration
public IGorgonAnimation FromStream(Stream stream, int? byteCount = null, string name = null, IEnumerable<GorgonTexture2DView> textureOverrides = null)
Parameters
Type Name Description
Stream stream

The stream containing the animation.

int? byteCount

[Optional] The number of bytes to read from the stream.

string name

[Optional] The name of the animation.

IEnumerable<GorgonTexture2DView> textureOverrides

[Optional] Textures to use in a texture animation track.

Returns
Type Description
IGorgonAnimation

A new IGorgonAnimation.

Remarks

When passing in a list of textureOverrides, the texture names should match the expected texture names in the key frame. For example, if the TextureName is "WalkingFrames", then the Name should also be "WalkingFrames".

Exceptions
Type Condition
GorgonException

Thrown if the stream is write only.

EndOfStreamException

Thrown if the current stream position, plus the size of the data exceeds the length of the stream.

NotSupportedException

This method is not supported by this codec.

| Edit this page View Source

GetAssociatedTextureNames(Stream)

Function to retrieve the names of the associated textures.

Declaration
public IReadOnlyList<string> GetAssociatedTextureNames(Stream stream)
Parameters
Type Name Description
Stream stream

The stream containing the texture data.

Returns
Type Description
IReadOnlyList<string>

The names of the texture associated with the animations, or an empty list if no textures were found.

Exceptions
Type Condition
GorgonException

Thrown if the stream is write only.

EndOfStreamException

Thrown if the current stream position, plus the size of the data exceeds the length of the stream.

NotSupportedException

This method is not supported by this codec.

| Edit this page View Source

IsReadable(Stream)

Function to determine if the data in a stream is readable by this codec.

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

The stream containing the data.

Returns
Type Description
bool

true if the data can be read, or false if not.

Exceptions
Type Condition
ArgumentNullException

Thrown when the stream parameter is null.

GorgonException

Thrown if the stream is write only.

EndOfStreamException

Thrown if the current stream position, plus the size of the data exceeds the length of the stream.

NotSupportedException

This method is not supported by this codec.

| Edit this page View Source

OnGetAssociatedTextureNames(Stream)

Function to retrieve the names of the associated textures.

Declaration
protected abstract IReadOnlyList<string> OnGetAssociatedTextureNames(Stream stream)
Parameters
Type Name Description
Stream stream

The stream containing the texture data.

Returns
Type Description
IReadOnlyList<string>

The names of the texture associated with the animations, or an empty list if no textures were found.

| Edit this page View Source

OnIsReadable(Stream)

Function to determine if the data in a stream is readable by this codec.

Declaration
protected abstract bool OnIsReadable(Stream stream)
Parameters
Type Name Description
Stream stream

The stream containing the data.

Returns
Type Description
bool

true if the data can be read, or false if not.

| Edit this page View Source

OnReadFromStream(string, Stream, int, IEnumerable<GorgonTexture2DView>)

Function to read the animation data from a stream.

Declaration
protected abstract IGorgonAnimation OnReadFromStream(string name, Stream stream, int byteCount, IEnumerable<GorgonTexture2DView> textureOverrides = null)
Parameters
Type Name Description
string name

The name of the animation.

Stream stream

The stream containing the animation.

int byteCount

The number of bytes to read from the stream.

IEnumerable<GorgonTexture2DView> textureOverrides

[Optional] Textures to use in a texture animation track.

Returns
Type Description
IGorgonAnimation

A new IGorgonAnimation.

Remarks

Implementors should handle the textureOverrides parameter by matching the textures by name, and, if the texture is not found in the override list, fall back to whatever scheme is used to retrieve the texture for codec.

| Edit this page View Source

OnSaveToStream(IGorgonAnimation, Stream)

Function to save the animation data to a stream.

Declaration
protected abstract void OnSaveToStream(IGorgonAnimation animation, Stream stream)
Parameters
Type Name Description
IGorgonAnimation animation

The animation to serialize into the stream.

Stream stream

The stream that will contain the animation.

| Edit this page View Source

Save(IGorgonAnimation, Stream)

Function to save the animation data to a stream.

Declaration
public void Save(IGorgonAnimation animation, Stream stream)
Parameters
Type Name Description
IGorgonAnimation animation

The animation to serialize into the stream.

Stream stream

The stream that will contain the animation.

Exceptions
Type Condition
ArgumentNullException

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

GorgonException

Thrown if the stream is read only.

NotSupportedException

This method is not supported by this codec.

| Edit this page View Source

Save(IGorgonAnimation, string)

Function to save the animation data to a file on a physical file system.

Declaration
public void Save(IGorgonAnimation animation, string filePath)
Parameters
Type Name Description
IGorgonAnimation animation

The animation to serialize into the file.

string filePath

The path to the file to write.

Exceptions
Type Condition
ArgumentNullException

Thrown when the filePath parameter is null.

ArgumentEmptyException

Thrown when the filePath parameter is empty.

NotSupportedException

This method is not supported by this codec.

Implements

IGorgonAnimationCodec
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