ImageAtlasBuilder

Description

sealed class Tinman.Engine.Drawing.ImageAtlasBuilder

Builds images atlases.

An image atlas contains a number of independent images, possibly of different sizes, arranged in an efficient way. Padding may be used to avoid sampling artefacts (i.e. color-bleeding between images).

To build an image atlas, perform the following steps:

  1. Create an ImageAtlasBuilder object.

  2. Configure the Padding, PowerOfTwo and Trim properties, if necessary.

  3. Add images with Image.

  4. Build the image atlas with BuildColorBuffer.

  5. Use one of the factory methods to create a wrapper object for the image atlas:
    BuildIconAtlas.

See also

IconAtlas

Public / Constructors

ImageAtlasBuilder


public constructor ImageAtlasBuilder → ()

Creates a new instance of ImageAtlasBuilder.

Public / Methods

BuildColorBuffer


public method BuildColorBuffer → ()

returns → ColorBuffer

The image atlas.

Builds an image atlas from the current builder state.

BuildIconAtlas


public method BuildIconAtlas → (1)

image in : IResourceHandle

[not-null]
A resource handle that returns a Bitmap which contains the pixels of the image atlas that has been built with BuildColorBuffer.

returns → IconAtlas

The built icon atlas. Will be null iff no images have been added to the builder.

Builds an IconAtlas object from the current builder state.

Image


public method Image → (2)

name in : string

[not-empty]
The image name. If an image of the same name already exists, it will be replaced.

pixels in : ColorBuffer

[not-null]
The image pixels. When this method returns, the image pixels will have been copied to an internal buffer, so this pixel buffer may be modified without interfering with the image atlas builder.

Adds an image to the atlas.

Public / Attributes

Padding


public attribute Padding → (get,set)

value : int32

[>=0]
the padding amount, in pixels.

The padding between images in the atlas.

Defaults to 1.

PowerOfTwo


public attribute PowerOfTwo → (get,set)

value : bool

true to create power-of-two images, false to create compact images.

Generate image atlases that have power-of-two dimensions?

Defaults to true.

Trim


public attribute Trim → (get,set)

value : bool

true to trim common empty pixels borders,
false to use retain the images as specified with Image.

Trim the images in the atlas when generating a wrapper object?

Trimming will compute the amount of empty pixels at each edge that is common to all images in the atlas and will remove these by modifying the descriptors in the wrapper object accordingly.

Defaults to true.