Gorgon
Show / Hide Table of Contents

Class SpriteExtractorService

The service used to retrieve sprite data from a texture atlas.

Inheritance
object
SpriteExtractorService
Implements
ISpriteExtractorService
Inherited Members
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
Namespace: Gorgon.Editor.Services
Assembly: Gorgon.Editor.API.dll
Syntax
public class SpriteExtractorService : ISpriteExtractorService
Remarks

Developers can use this to extract sprite information using a fixed size grid to retrieve texture coordinates from a texture passed to the service.

Constructors

| Edit this page View Source

SpriteExtractorService(Gorgon2D, IContentFileManager, IGorgonSpriteCodec)

Initializes a new instance of the SpriteExtractorService class.

Declaration
public SpriteExtractorService(Gorgon2D renderer, IContentFileManager fileManager, IGorgonSpriteCodec defaultCodec)
Parameters
Type Name Description
Gorgon2D renderer

The application 2D renderer.

IContentFileManager fileManager

The file manager for the project files.

IGorgonSpriteCodec defaultCodec

The default sprite codec.

Methods

| Edit this page View Source

ExtractSprites(SpriteExtractionData, IGorgonImage, Action<ProgressData>, CancellationToken)

Function to retrieve the sprites from the texture atlas.

Declaration
public IReadOnlyList<GorgonSprite> ExtractSprites(SpriteExtractionData data, IGorgonImage imageData, Action<ProgressData> progressCallback, CancellationToken cancelToken)
Parameters
Type Name Description
SpriteExtractionData data

The data used to extract the sprites.

IGorgonImage imageData

The system memory version of the texture.

Action<ProgressData> progressCallback

A callback method used to report on progress of the operation.

CancellationToken cancelToken

The token used to cancel the operation.

Returns
Type Description
IReadOnlyList<GorgonSprite>

A list of sprites generated by this method.

| Edit this page View Source

GetSpriteTextureImageDataAsync(SpriteExtractionData)

Function to retrieve the image data for a sprite texture as a 32 bit RGBA pixel data.

Declaration
public Task<IGorgonImage> GetSpriteTextureImageDataAsync(SpriteExtractionData data)
Parameters
Type Name Description
SpriteExtractionData data

The data used for sprite extraction.

Returns
Type Description
Task<IGorgonImage>

The image data for the texture.

| Edit this page View Source

SaveSprites(string, string, IEnumerable<GorgonSprite>, IContentFile)

Function to save the sprites to the file system.

Declaration
public void SaveSprites(string path, string baseFileName, IEnumerable<GorgonSprite> sprites, IContentFile textureFile)
Parameters
Type Name Description
string path

The path to save the sprites into.

string baseFileName

The base file name.

IEnumerable<GorgonSprite> sprites

The sprites to save.

IContentFile textureFile

The texture file associated with the sprites.

Exceptions
Type Condition
IOException

Thrown when the file system is locked by another thread (after 10 seconds).

Implements

ISpriteExtractorService

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