Table of Contents

Class TileRgb565Packer

Packs decoded RGBA8 tile pixels into RGB565 on a worker thread, so residency conversion does not cost main-thread per-pixel work.

public static class TileRgb565Packer
Inheritance
object
TileRgb565Packer

Remarks

Channels use the documented R5G6B5 bit positions and truncate to the available precision. A GPU upload path that rounds instead of truncating can differ by one least-significant bit.

Fields

BytesPerPixel

Packed RGB565 size, 2 bytes per pixel.

public const int BytesPerPixel = 2

Field Value

int

Methods

PackBuffer(byte[], int, int, byte[], int)

Packs RGBA8 pixels into RGB565, 2 bytes per pixel, little-endian.

public static void PackBuffer(byte[] src, int srcOffset, int pixelCount, byte[] dest, int destOffset)

Parameters

src byte[]

RGBA8 source, 4 bytes per pixel; alpha ignored.

srcOffset int

Index of the first pixel's R in src.

pixelCount int

Pixels to pack.

dest byte[]

Caller-owned destination, at least pixelCount*2 bytes from destOffset.

destOffset int

Start write index in dest, in bytes.

PackPixel(byte, byte, byte)

Packs one pixel: 8-bit channels in, one 16-bit RGB565 value out.

public static ushort PackPixel(byte r, byte g, byte b)

Parameters

r byte

Red, 0 to 255; top 5 bits kept.

g byte

Green, 0 to 255; top 6 bits kept.

b byte

Blue, 0 to 255; top 5 bits kept.

Returns

ushort

Packed 16-bit RGB565. Alpha is dropped; RGB565 carries none.