diff options
Diffstat (limited to 'src/main.c')
-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); |