diff options
| -rw-r--r-- | gentpl/gentpl.c | 26 | ||||
| -rw-r--r-- | testrlyt.py | 6 |
2 files changed, 16 insertions, 16 deletions
diff --git a/gentpl/gentpl.c b/gentpl/gentpl.c index 44370e8..9a55f13 100644 --- a/gentpl/gentpl.c +++ b/gentpl/gentpl.c @@ -51,8 +51,8 @@ int main(int argc, char **argv) { struct texthead h; memset(&h, 0, sizeof(h)); - h.format = htonl(6); - h.offs = htonl(0x14 + sizeof(h)); + h.format = htonl(4); // RGB565 + h.offs = htonl(0x14 + sizeof(h) + 8); printf("%dx%d\n", gdImageSX(im), gdImageSY(im)); h.width = htons(gdImageSX(im)); h.height = htons(gdImageSY(im)); @@ -61,6 +61,8 @@ int main(int argc, char **argv) { fwrite(&h, sizeof(h), 1, out); + for(int i = 0; i < 8; i++) fputc(0, out); + for(int y = 0; y < gdImageSY(im); y += 4) { for(int x = 0; x < gdImageSX(im); x += 4) { for(int y1 = y; y1 < y + 4; y1++) { @@ -68,20 +70,18 @@ int main(int argc, char **argv) { int p = gdImageGetPixel(im, x1, y1); unsigned char a = 254 - 2*((unsigned char) gdImageAlpha(im, p)); if(a == 254) a++; - unsigned char b = (unsigned char) gdImageRed(im, p); - fputc(a, out); - fputc(b, out); } - } - - for(int y1 = y; y1 < y + 4; y1++) { - for(int x1 = x; x1 < x + 4; x1++) { - int p = gdImageGetPixel(im, x1, y1); - unsigned char a = (unsigned char) gdImageGreen(im, p); + unsigned char r = (unsigned char) gdImageRed(im, p); + unsigned char g = (unsigned char) gdImageGreen(im, p); unsigned char b = (unsigned char) gdImageBlue(im, p); - fputc(a, out); - fputc(b, out); + unsigned short s = 0; + s |= (r >> 3) << 11; + s |= (g >> 2) << 5; + s |= (b >> 3); + fputc(s >> 8, out); + fputc(s & 0xff, out); } } + } } diff --git a/testrlyt.py b/testrlyt.py index 98ff520..d9722e4 100644 --- a/testrlyt.py +++ b/testrlyt.py @@ -33,7 +33,7 @@ 'ua7': [], 'ua8': [], 'ua9': [], - 'uaa': [0x77, 0, 0, 0], + 'uaa': [0x77, 0, 0, 0], # was: [0x77, 0, 0, 0] 'uab': None, @@ -111,8 +111,8 @@ 'alpha': 0xff, 'alpha_2': 0x0, 'angle': 0, - 'flags_1': 5, - 'flags_2': 4, + 'flags_1': 1, # Black if omitted + 'flags_2': 4, # "X, Y at center?" 'width': 608, 'height': 456, 'name': 'pic', |
