diff options
Diffstat (limited to 'tools/gen_test_tga.cc')
| -rw-r--r-- | tools/gen_test_tga.cc | 55 |
1 files changed, 26 insertions, 29 deletions
diff --git a/tools/gen_test_tga.cc b/tools/gen_test_tga.cc index 7414eea..4e029ca 100644 --- a/tools/gen_test_tga.cc +++ b/tools/gen_test_tga.cc @@ -1,35 +1,32 @@ -#include <cstdio> #include <cstdint> +#include <cstdio> int main() { - FILE* f = fopen("assets/final/test_image.tga", "wb"); - if (!f) return 1; + 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); - // 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 - // 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; + 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; } |
