diff options
author | kdx <kikoodx@paranoici.org> | 2023-04-15 17:14:51 +0200 |
---|---|---|
committer | kdx <kikoodx@paranoici.org> | 2023-04-15 17:14:51 +0200 |
commit | 7b380e7003ab5ce5d22da4ba79adc12fd3231458 (patch) | |
tree | 4186b13f51ccd4e173e9f2f8be5ff79c5f832cda | |
parent | 213984d4073a14454a72cb4912c61d269ca868c7 (diff) | |
download | orgaset-7b380e7003ab5ce5d22da4ba79adc12fd3231458.tar.gz |
macro for tilesize
-rw-r--r-- | src/main.c | 15 |
1 files changed, 8 insertions, 7 deletions
@@ -2,14 +2,15 @@ #include "stb_image.h" #include <stdio.h> +#define TSIZE 8 #define RGB(r, g, b) (((r) << 11) | ((g) << 5) | (b)) static void output_tile(const uint8_t *data, int x, int y, int w) { - for (int iy = 0; iy < 16; iy += 1) { + for (int iy = 0; iy < TSIZE; iy += 1) { putchar('\t'); - for (int ix = 0; ix < 16; ix += 1) { + for (int ix = 0; ix < TSIZE; ix += 1) { const int i = (ix + x + (iy + y) * w) * 3; const int v = RGB(data[i]/8, data[i+1]/4, data[i+2]/8); printf("%04x ", v); @@ -34,10 +35,10 @@ main(int argc, char **argv) return 1; } - if ((w & 15) || (h & 15)) { + if (w % TSIZE || h % TSIZE) { fprintf(stderr, "invalid dimensions %dx%d, " - "expected dimensions divisible by 16\n", - w, h); + "expected dimensions divisible by %d\n", + w, h, TSIZE); goto panic; } if (chans != 3) { @@ -47,8 +48,8 @@ main(int argc, char **argv) goto panic; } - for (int y = 0; y < h; y += 16) - for (int x = 0; x < w; x += 16) + for (int y = 0; y < h; y += TSIZE) + for (int x = 0; x < w; x += TSIZE) output_tile(data, x, y, w); stbi_image_free(data); |