Class Bc1Encoder
- Namespace
- LansMap.Core.TileCodecs.Bc1
Encodes RGBA8888 into BC1 blocks (8 bytes per 4x4 texels, 4 bpp) with a fast range-fit, no iterative refinement.
public static class Bc1Encoder
- Inheritance
-
objectBc1Encoder
Remarks
Every block is forced into four-color (opaque) mode. BC1's three-color plus transparent mode exists for alpha, which tiles never carry.
Fields
BlockBytes
BC1 block size, 8 bytes.
public const int BlockBytes = 8
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 BC1 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 BC1 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. A level below 4x4 is legal in BC1 and still costs one whole block. Missing texels clamp from the level's own edge.
RequiredBlockBufferBytes(int, int)
Byte count of a tightly packed BC1 block grid for the given texel size.
public static int RequiredBlockBufferBytes(int width, int height)
Parameters
Returns
- int
Size in bytes, block-rounded.