Class Bc1MipChain
- Namespace
- LansMap.Core.TileCodecs.Bc1
CPU mip-chain arithmetic and 2x2 box downsampling for block-compressed tiles, floored at 1x1.
public static class Bc1MipChain
- Inheritance
-
objectBc1MipChain
Remarks
Compressed formats cannot generate mips on the GPU. The floor is 1x1 so the level count matches LevelCount(int); a 4x4 floor would desync from the uncompressed chain. Levels below 4x4 are legal in BC1 and still occupy one whole block.
Fields
MinDimension
Smallest mip edge in texels, 1.
public const int MinDimension = 1
Field Value
Methods
Downsample(byte[], int, int, byte[], int, int)
Downsamples RGBA8888 with a 2x2 box filter into a caller-owned buffer.
public static void Downsample(byte[] src, int srcW, int srcH, byte[] dst, int dstW, int dstH)
Parameters
srcbyte[]Source RGBA8888, srcWsrcH4 bytes row-major.
srcWintSource width in texels.
srcHintSource height in texels.
dstbyte[]Destination, dstWdstH4 bytes row-major.
dstWintDestination width in texels.
dstHintDestination height in texels.
Remarks
A source edge is clamped rather than read out of bounds, so dstW*2 can exceed srcW by one texel without crashing.
LevelCount(int, int)
Levels in a full chain from the given base size down to 1x1.
public static int LevelCount(int width, int height)
Parameters
widthintBase-level width in texels, greater than 0.
heightintBase-level height in texels, greater than 0.
Returns
- int
Level count, 1 when both axes are already 1.
LevelDimensions(int, int, int, out int, out int)
Texel size of one mip level, floored at MinDimension.
public static void LevelDimensions(int width, int height, int level, out int w, out int h)