Table of Contents

Class AtlasPage

Namespace
KernSmith.Atlas
Assembly
KernSmith.dll

A single texture page in the atlas containing packed glyph pixel data.

public sealed class AtlasPage
Inheritance
AtlasPage
Inherited Members

Properties

Format

Whether the pixel data is grayscale, RGBA, etc.

public required PixelFormat Format { get; init; }

Property Value

PixelFormat

Height

Height in pixels.

public required int Height { get; init; }

Property Value

int

PageIndex

Page number (zero-based).

public required int PageIndex { get; init; }

Property Value

int

PixelData

Raw pixel data in row-major order, top-to-bottom. Format depends on Format:

<ul><li><xref href="KernSmith.PixelFormat.Rgba32" data-throw-if-not-resolved="false"></xref>: 4 bytes per pixel (R, G, B, A), width * height * 4 bytes total.</li><li><xref href="KernSmith.PixelFormat.Grayscale8" data-throw-if-not-resolved="false"></xref>: 1 byte per pixel (alpha/luminance), width * height bytes total.</li></ul>

Suitable for direct upload to GPU textures (e.g., MonoGame Texture2D.SetData).
public required byte[] PixelData { get; init; }

Property Value

byte[]

Width

Width in pixels.

public required int Width { get; init; }

Property Value

int

Methods

GetAlpha8PixelData()

Returns pixel data as 8-bit alpha coverage bytes regardless of the page's native format. RGBA pages collapse to the alpha channel only (one byte per pixel). Grayscale pages return a copy of PixelData unchanged. The returned array is always a fresh buffer owned by the caller; mutating it does not affect PixelData.

public byte[] GetAlpha8PixelData()

Returns

byte[]

A byte array of length Width * Height where each byte is alpha coverage (0..255).

GetPremultipliedRgbaPixelData()

Returns pixel data as premultiplied RGBA32 bytes regardless of the page's native format. Each color channel is scaled by its alpha so the result can be uploaded directly to a GPU texture rendered with a premultiplied-alpha blend state (e.g. MonoGame's default BlendState.AlphaBlend); use this instead of GetRgbaPixelData() when the consumer expects premultiplied textures. Grayscale pages expand to (v, v, v, v) — white coverage premultiplied by the grayscale value. RGBA pages are premultiplied per pixel. The returned array is always a fresh buffer owned by the caller; mutating it does not affect PixelData.

public byte[] GetPremultipliedRgbaPixelData()

Returns

byte[]

A byte array of length Width * Height * 4 in premultiplied RGBA order (R, G, B, A).

GetRgbaPixelData()

Returns pixel data as RGBA32 bytes regardless of the page's native format. Grayscale pages expand each byte to (255, 255, 255, v) — the canonical Angelcode BMFont alpha-coverage layout where RGB is white and the original grayscale value becomes the alpha channel. RGBA pages return a copy of PixelData unchanged. The returned array is always a fresh buffer owned by the caller; mutating it does not affect PixelData.

public byte[] GetRgbaPixelData()

Returns

byte[]

A byte array of length Width * Height * 4 in RGBA order (R, G, B, A).

ToDds()

Encodes this atlas page as a DDS image.

public byte[] ToDds()

Returns

byte[]

The DDS file bytes.

ToPng()

Encodes this page to PNG bytes. Throws if no encoder is configured.

public byte[] ToPng()

Returns

byte[]

PNG-encoded byte array.

ToTga()

Encodes this atlas page as a TGA image.

public byte[] ToTga()

Returns

byte[]

The TGA file bytes.