Class GorgonPolySpriteCodecCommon
A base class containing common codec functionality.
Inheritance
Inherited Members
Namespace: Gorgon.IO
Assembly: Gorgon.IO.Gorgon2D.dll
Syntax
public abstract class GorgonPolySpriteCodecCommon : IGorgonPolySpriteCodec, IGorgonGraphicsObject, IGorgonNamedObject
Constructors
| Edit this page View SourceGorgonPolySpriteCodecCommon(Gorgon2D, string, string)
Initializes a new instance of the GorgonPolySpriteCodecCommon class.
Declaration
protected GorgonPolySpriteCodecCommon(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 sprite format.
Declaration
public static readonly ulong CurrentFileHeader
Field Value
Type | Description |
---|---|
ulong |
CurrentVersion
The highest currently supported version for sprite 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 sprite data.
Declaration
public abstract bool CanDecode { get; }
Property Value
Type | Description |
---|---|
bool |
CanEncode
Property to return whether or not the codec can encode sprite 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 a polygonal sprite.
Declaration
public IReadOnlyList<GorgonFileExtension> FileExtensions { get; }
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 sprite data that the codec supports.
Declaration
public abstract Version Version { get; }
Property Value
Type | Description |
---|---|
Version |
Methods
| Edit this page View SourceFromFile(string, GorgonTexture2DView)
Function to read the sprite data from a file on the physical file system.
Declaration
public GorgonPolySprite FromFile(string filePath, GorgonTexture2DView overrideTexture = null)
Parameters
Type | Name | Description |
---|---|---|
string | filePath | The path to the file to read. |
GorgonTexture2DView | overrideTexture | [Optional] The texture to use as an override for the sprite. |
Returns
Type | Description |
---|---|
GorgonPolySprite | A new GorgonPolySprite. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when the |
ArgumentEmptyException | Thrown when the |
NotSupportedException | This method is not supported by this codec. |
FromStream(Stream, GorgonTexture2DView, int?)
Function to read the sprite data from a stream.
Declaration
public GorgonPolySprite FromStream(Stream stream, GorgonTexture2DView overrideTexture = null, int? byteCount = null)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream containing the sprite. |
GorgonTexture2DView | overrideTexture | [Optional] The texture to use as an override for the sprite. |
int? | byteCount | [Optional] The number of bytes to read from the stream. |
Returns
Type | Description |
---|---|
GorgonPolySprite | A new GorgonPolySprite. |
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. |
GetAssociatedTextureName(Stream)
Function to retrieve the name of the associated texture.
Declaration
public string GetAssociatedTextureName(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. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if the |
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. |
OnGetAssociatedTextureName(Stream)
Function to retrieve the name of the associated texture.
Declaration
protected abstract 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. |
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(Stream, int, GorgonTexture2DView)
Function to read the sprite data from a stream.
Declaration
protected abstract GorgonPolySprite 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 |
---|---|
GorgonPolySprite | A new GorgonPolySprite. |
OnSaveToStream(GorgonPolySprite, Stream)
Function to save the sprite data to a stream.
Declaration
protected abstract void OnSaveToStream(GorgonPolySprite sprite, Stream stream)
Parameters
Type | Name | Description |
---|---|---|
GorgonPolySprite | sprite | The sprite to serialize into the stream. |
Stream | stream | The stream that will contain the sprite. |
Save(GorgonPolySprite, Stream)
Function to save the sprite data to a stream.
Declaration
public void Save(GorgonPolySprite sprite, Stream stream)
Parameters
Type | Name | Description |
---|---|---|
GorgonPolySprite | sprite | The sprite to serialize into the stream. |
Stream | stream | The stream that will contain the sprite. |
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(GorgonPolySprite, string)
Function to save the sprite data to a file on a physical file system.
Declaration
public void Save(GorgonPolySprite sprite, string filePath)
Parameters
Type | Name | Description |
---|---|---|
GorgonPolySprite | sprite | The sprite 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. |