Class Astc4x4Encoder
- Namespace
- LansMap.Core.TileCodecs.Astc4x4
Encodes RGBA8888 into ASTC 4x4 blocks (16 bytes per 4x4 texels, 8 bpp), the preferred mobile GPU format.
public static class Astc4x4Encoder
- Inheritance
-
objectAstc4x4Encoder
Remarks
Emits exactly two legal LDR shapes: a void-extent block for a uniform 4x4, and one partition with CEM 12 and QUANT_4 weights. Not a production-quality ASTC encoder; correctness over iterative fit.
Fields
BlockBytes
ASTC 4x4 block size, 16 bytes.
public const int BlockBytes = 16
Field Value
BlockPixels
Texels along one edge of a block, 4.
public const int BlockPixels = 4
Field Value
Methods
BlockSpan(int)
Blocks along one axis, rounding a tail smaller than 4 texels up to one block.
public static int BlockSpan(int pixels)
Parameters
pixelsintAxis length in texels.
Returns
- int
Block count along that axis.
Encode(byte[], int, int, byte[], int)
Encodes a whole mip level whose edges are positive multiples of 4 into ASTC 4x4 blocks.
public static void Encode(byte[] rgba, int width, int height, byte[] outBlocks, int outOffset)
Parameters
rgbabyte[]widthheight4 RGBA8888 bytes, row-major.
widthintWidth in texels, a positive multiple of 4.
heightintHeight in texels, a positive multiple of 4.
outBlocksbyte[]Caller-owned destination, at least RequiredBlockBufferBytes(int, int) bytes from
outOffset.outOffsetintStart write index in
outBlocks, in bytes.
Remarks
A level smaller than 4x4 on either axis must use EncodeSubBlockLevel(byte[], int, int, byte[], int) instead.
EncodeSubBlockLevel(byte[], int, int, byte[], int)
Encodes a mip tail smaller than one full block into exactly one ASTC 4x4 block, edge-clamped.
public static void EncodeSubBlockLevel(byte[] rgba, int width, int height, byte[] outBlocks, int outOffset)
Parameters
rgbabyte[]widthheight4 RGBA8888 bytes, row-major.
widthintWidth in texels, greater than 0.
heightintHeight in texels, greater than 0.
outBlocksbyte[]Caller-owned destination, at least BlockBytes from
outOffset.outOffsetintStart write index in
outBlocks, in bytes.
Remarks
Only for a level smaller than 4x4 on at least one axis. Missing texels clamp from the level's own edge, so a uniform tail stays uniform rather than smearing adjacent memory.
RequiredBlockBufferBytes(int, int)
Byte count of a tightly packed ASTC 4x4 block grid for the given texel size.
public static int RequiredBlockBufferBytes(int width, int height)
Parameters
Returns
- int
Size in bytes, block-rounded.