Skip to content

Instantly share code, notes, and snippets.

@brecert
Created May 3, 2025 04:00
Show Gist options
  • Save brecert/e6cb5204fa4e4979c9041fb75e0c48dd to your computer and use it in GitHub Desktop.
Save brecert/e6cb5204fa4e4979c9041fb75e0c48dd to your computer and use it in GitHub Desktop.
import std.mem;
import hex.dec;
import std.io;
using int = s32;
enum TextureFormat : u16 {
Unknown = 0,
Alpha8 = 1,
R8 = 2,
RGB24 = 16,
ARGB32 = 17,
RGBA32 = 18,
BGRA32 = 19,
RGB565 = 24,
RGBAHalf = 32,
ARGBHalf = 33,
RHalf = 34,
RGHalf = 35,
RGBAFloat = 48,
ARGBFloat = 49,
RFloat = 50,
RGFloat = 51,
BC1 = 64,
BC2 = 65,
BC3 = 66,
BC4 = 67,
BC5 = 68,
BC6H = 69,
BC7 = 70,
ETC2_RGB = 96,
ETC2_RGBA1 = 97,
ETC2_RGBA8 = 98,
ASTC_4x4 = 128,
ASTC_5x5 = 129,
ASTC_6x6 = 130,
ASTC_8x8 = 131,
ASTC_10x10 = 132,
ASTC_12x12 = 133
};
enum RawBitmapEncoding : u8 {
Uncompressed,
LZMA
};
bitfield Flags {
HasMipMaps : 1;
};
struct int2 {
int x;
int y;
};
struct String {
u8 size;
char name[size];
};
struct Header {
String name;
int version;
int2 size;
TextureFormat format;
Flags flags;
RawBitmapEncoding encoding;
String profile;
match (encoding) {
(RawBitmapEncoding::Uncompressed): {
int size;
u8 byte[size];
}
(RawBitmapEncoding::LZMA): {
u8 compressed[while(!std::mem::eof())];
std::mem::Section decompressed = std::mem::create_section("decompressed");
bool ok = hex::dec::lzma_decompress(compressed, decompressed);
std::print("ok={}", ok);
}
}
};
struct BmpCube {
Header header;
};
BmpCube file @ 0x00;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment