Class GorgonAnimationCodecCommon
A base class containing common codec functionality.
Inheritance
Inherited Members
Namespace: Gorgon.IO
Assembly: Gorgon.IO.Gorgon2D.dll
Syntax
public abstract class GorgonAnimationCodecCommon : IGorgonAnimationCodec, IGorgonNamedObject
Constructors
| Edit this page View SourceGorgonAnimationCodecCommon(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 |
ArgumentEmptyException | Thrown when the |
Fields
| Edit this page View SourceCurrentFileHeader
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 |
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 SourceCanDecode
Property to return whether or not the codec can decode animation data.
Declaration
public abstract bool CanDecode { get; }
Property Value
Type | Description |
---|---|
bool |
CanEncode
Property to return whether or not the codec can encode animation data.
Declaration
public abstract bool CanEncode { get; }
Property Value
Type | Description |
---|---|
bool |
Codec
Property to return the abbreviated name of the codec (e.g. PNG).
Declaration
public string Codec { get; }
Property Value
Type | Description |
---|---|
string |
CodecDescription
Property to return the friendly description of the format.
Declaration
public string CodecDescription { get; }
Property Value
Type | Description |
---|---|
string |
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> |
Graphics
Property to return the graphics interface that built this object.
Declaration
public GorgonGraphics Graphics { get; }
Property Value
Type | Description |
---|---|
GorgonGraphics |
Renderer
Property to return the renderer used to create objects.
Declaration
public Gorgon2D Renderer { get; }
Property Value
Type | Description |
---|---|
Gorgon2D |
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 SourceFromFile(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 |
ArgumentEmptyException | Thrown when the |
NotSupportedException | This method is not supported by this codec. |
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 |
EndOfStreamException | Thrown if the current |
NotSupportedException | This method is not supported by this codec. |
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 |
EndOfStreamException | Thrown if the current |
NotSupportedException | This method is not supported by this codec. |
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 |
GorgonException | Thrown if the |
EndOfStreamException | Thrown if the current |
NotSupportedException | This method is not supported by this codec. |
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. |
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. |
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.
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. |
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 |
GorgonException | Thrown if the stream is read only. |
NotSupportedException | This method is not supported by this codec. |
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 |
ArgumentEmptyException | Thrown when the |
NotSupportedException | This method is not supported by this codec. |