summaryrefslogtreecommitdiff
path: root/tools/gen_test_tga.cc
blob: 7414eea8af1ba9a57f1a118ffefebbec1bb30bc7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <cstdio>
#include <cstdint>

int main() {
    FILE* f = fopen("assets/final/test_image.tga", "wb");
    if (!f) return 1;

    // TGA Header (Uncompressed True-Color, 2x2, 32-bit)
    uint8_t header[18] = {
        0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0,
        2, 0, // Width: 2 (LE)
        2, 0, // Height: 2 (LE)
        32,   // Depth: 32 bit
        0x28  // Descriptor: Top-Left origin, 8-bit alpha
    };
    fwrite(header, 1, 18, f);

    // Pixel Data (BGRA order for TGA usually, but let's see what stbi expects/returns)
    // stbi converts to requested format (RGBA).
    // Let's write BGRA: 
    // Pixel 0 (0,0): Red   -> 00 00 FF FF
    // Pixel 1 (1,0): Green -> 00 FF 00 FF
    // Pixel 2 (0,1): Blue  -> FF 00 00 FF
    // Pixel 3 (1,1): White -> FF FF FF FF
    
    uint8_t pixels[] = {
        0x00, 0x00, 0xFF, 0xFF, // Red
        0x00, 0xFF, 0x00, 0xFF, // Green
        0xFF, 0x00, 0x00, 0xFF, // Blue
        0xFF, 0xFF, 0xFF, 0xFF  // White
    };
    fwrite(pixels, 1, sizeof(pixels), f);
    fclose(f);
    return 0;
}