Jump to content
Setting up an AI agent? ReverseEngineering.wiki skill (works from the command line, no configuration): https://reverseengineering.wiki/skill/rewiki/SKILL.md · setup for every client, including MCP: https://reverseengineering.wiki/llms.txt · REWiki:Connect

Format:CLIM and FLIM (BCLIM, BFLIM)

From ReverseEngineering.wiki
Format
Magic CLIM or FLIM (ASCII) 0x28 bytes before the end of the file
Extensions .bclim, .bflim
Endianness little (byte-order mark bytes FF FE)
On this wiki Facts · Code · Notes · Topics

3DS texture images .bclim and .bflim: the pixel data comes first and a 40-byte header with magic CLIM or FLIM sits at the END of the file.

Footer instead of header

Tools such as pk3DS read a BCLIM or BFLIM by taking the last 0x28 bytes as the header and everything before it as pixel data (Fact:CLIM and FLIM (BCLIM, BFLIM)/struct/Footer). So the magic is not at offset 0: look at the last 40 bytes for CLIM or FLIM followed by the byte-order mark FF FE.

Footer (40 bytes): magic; u16 byte-order mark; header length 0x14; for FLIM a u32 version, for CLIM two bytes with tile width and height exponents (1 shifted by n) in the same place; u32 total file length; u32 block count (1); then the imag block: tag imag, u32 block length 0x10, u16 width, u16 height, a u16 alignment, one byte format id, one byte orientation, u32 pixel data size. The alignment word comes after the orientation in CLIM and before the format in FLIM, as pk3DS declares the two structs.

Pixel formats

Format numbers used by pk3DS's BCLIM writer (Fact:CLIM and FLIM (BCLIM, BFLIM)/enum/Format ids): 0 L8, 1 A8, 2 LA4, 3 LA8, 4 HILO8, 5 RGB565, 6 RGB8, 7 RGBA5551, 8 RGBA4444, 9 RGBA8888, 10 ETC1, 11 ETC1A4, 12 L4, 13 A4. The pk3DS reader treats an RGB5A1 image whose first u16 is 2 as a palette image.

Unverified: whether the FLIM format ids equal the CLIM ones (I read only the BCLIM writer), that pixels are stored in 8x8 tiles (the writer loops over tiles; I did not read the ordering code), and the meaning of the orientation byte.

Code & repositories

  • https://github.com/kwsch/pk3DS @ 6daaca934ca2284a73ab743bf89c848c57cd9de1 · license: GPL-3.0 (declared by the contributor; GitHub's detector did not recognize LICENSE.md)
    pk3DS: pk3DS.Core/CTR/Images/BCLIM.cs, BFLIM.cs, CLIMHeader.cs, FLIMHeader.cs read BCLIM and BFLIM files. Read for format facts only.
    Tested on: source read, not run · checked 2026-10-18; last activity 2026-02-27