Gorgon
Show / Hide Table of Contents

Class GorgonV1SpriteBinaryCodec

A codec that can read version 1 sprite data.

Inheritance
object
GorgonSpriteCodecCommon
GorgonV1SpriteBinaryCodec
Implements
IGorgonSpriteCodec
IGorgonGraphicsObject
IGorgonNamedObject
Inherited Members
GorgonSpriteCodecCommon.CurrentFileHeader
GorgonSpriteCodecCommon.CurrentVersion
GorgonSpriteCodecCommon.CodecDescription
GorgonSpriteCodecCommon.Codec
GorgonSpriteCodecCommon.Renderer
GorgonSpriteCodecCommon.Graphics
GorgonSpriteCodecCommon.FileExtensions
GorgonSpriteCodecCommon.GetAssociatedTextureName(Stream)
GorgonSpriteCodecCommon.FromStream(Stream, GorgonTexture2DView, int?)
GorgonSpriteCodecCommon.FromFile(string, GorgonTexture2DView)
GorgonSpriteCodecCommon.Save(GorgonSprite, Stream)
GorgonSpriteCodecCommon.Save(GorgonSprite, string)
GorgonSpriteCodecCommon.IsReadable(Stream)
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 class GorgonV1SpriteBinaryCodec : GorgonSpriteCodecCommon, IGorgonSpriteCodec, IGorgonGraphicsObject, IGorgonNamedObject

Constructors

| Edit this page View Source

GorgonV1SpriteBinaryCodec(Gorgon2D)

Initializes a new instance of the GorgonV1SpriteBinaryCodec class.

Declaration
public GorgonV1SpriteBinaryCodec(Gorgon2D renderer)
Parameters
Type Name Description
Gorgon2D renderer

The renderer used for resource handling.

Exceptions
Type Condition
ArgumentNullException

Thrown when the renderer parameter is null.

Properties

| Edit this page View Source

CanDecode

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

Declaration
public override bool CanDecode { get; }
Property Value
Type Description
bool
Overrides
GorgonSpriteCodecCommon.CanDecode
| Edit this page View Source

CanEncode

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

Declaration
public override bool CanEncode { get; }
Property Value
Type Description
bool
Overrides
GorgonSpriteCodecCommon.CanEncode
| Edit this page View Source

Version

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

Declaration
public override Version Version { get; }
Property Value
Type Description
Version
Overrides
GorgonSpriteCodecCommon.Version

Methods

| Edit this page View Source

GetAnimationCount(Stream)

Function to determine the number of animations in the sprite.

Declaration
public int GetAnimationCount(Stream stream)
Parameters
Type Name Description
Stream stream

The stream containing the sprite data.

Returns
Type Description
int

The number of animations in the sprite.

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.

| Edit this page View Source

LoadAnimationsFromFile(string)

Function to read all of the animations from the v1.x sprite.

Declaration
public IReadOnlyList<IGorgonAnimation> LoadAnimationsFromFile(string filePath)
Parameters
Type Name Description
string filePath

The path to the v1.x sprite file that contains the animations.

Returns
Type Description
IReadOnlyList<IGorgonAnimation>

A list of IGorgonAnimation objects.

Exceptions
Type Condition
ArgumentNullException

Thrown when the filePath parameter is null.

ArgumentEmptyException

Thrown when the filePath parameter is empty.

| Edit this page View Source

LoadAnimationsFromStream(Stream, int?)

Function to read all of the animations from the v1.x sprite.

Declaration
public IReadOnlyList<IGorgonAnimation> LoadAnimationsFromStream(Stream stream, int? size = null)
Parameters
Type Name Description
Stream stream

The stream containing the sprite animation data.

int? size

[Optional] The size of the sprite, in bytes.

Returns
Type Description
IReadOnlyList<IGorgonAnimation>

A list of IGorgonAnimation objects.

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.

| Edit this page View Source

OnGetAssociatedTextureName(Stream)

Function to retrieve the name of the associated texture.

Declaration
protected override string OnGetAssociatedTextureName(Stream stream)
Parameters
Type Name Description
Stream stream

The stream containing the texture data.

Returns
Type Description
string

The name of the texture associated with the sprite, or null if no texture was found.

Overrides
GorgonSpriteCodecCommon.OnGetAssociatedTextureName(Stream)
| Edit this page View Source

OnIsReadable(Stream)

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

Declaration
protected override 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.

Overrides
GorgonSpriteCodecCommon.OnIsReadable(Stream)
| Edit this page View Source

OnReadFromStream(Stream, int, GorgonTexture2DView)

Function to read the sprite data from a stream.

Declaration
protected override GorgonSprite OnReadFromStream(Stream stream, int byteCount, GorgonTexture2DView overrideTexture)
Parameters
Type Name Description
Stream stream

The stream containing the sprite.

int byteCount

The number of bytes to read from the stream.

GorgonTexture2DView overrideTexture

[Optional] The texture to assign to the sprite instead of the texture associated with the name stored in the file.

Returns
Type Description
GorgonSprite

A new GorgonSprite.

Overrides
GorgonSpriteCodecCommon.OnReadFromStream(Stream, int, GorgonTexture2DView)
| Edit this page View Source

OnSaveToStream(GorgonSprite, Stream)

Function to save the sprite data to a stream.

Declaration
protected override void OnSaveToStream(GorgonSprite sprite, Stream stream)
Parameters
Type Name Description
GorgonSprite sprite

The sprite to serialize into the stream.

Stream stream

The stream that will contain the sprite.

Overrides
GorgonSpriteCodecCommon.OnSaveToStream(GorgonSprite, Stream)

Implements

IGorgonSpriteCodec
IGorgonGraphicsObject
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