X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=common%2Freadpng.c;h=c93b36fd86a5b12965407e68fa4e7ac3c797c839;hb=4b8126a4967bcd525336010a66a25f953fd4ff43;hp=2a7466882edcabfd2b1ff0aad38e18098657a35d;hpb=c7a4ff64287b12487c7e9cc13ce3b7d2aa6e1f06;p=libpicofe.git diff --git a/common/readpng.c b/common/readpng.c index 2a74668..c93b36f 100644 --- a/common/readpng.c +++ b/common/readpng.c @@ -4,6 +4,14 @@ #include "readpng.h" #include "lprintf.h" +#ifdef PSP +#define BG_WIDTH 480 +#define BG_HEIGHT 272 +#else +#define BG_WIDTH 320 +#define BG_HEIGHT 240 +#endif + void readpng(void *dest, const char *fname, readpng_what what) { FILE *fp; @@ -62,9 +70,9 @@ void readpng(void *dest, const char *fname, readpng_what what) break; } height = info_ptr->height; - if (height > 240) height = 240; + if (height > BG_HEIGHT) height = BG_HEIGHT; width = info_ptr->width; - if (width > 320) width = 320; + if (width > BG_WIDTH) width = BG_WIDTH; for (h = 0; h < height; h++) { @@ -72,10 +80,14 @@ void readpng(void *dest, const char *fname, readpng_what what) int len = width; while (len--) { - *dst++ = ((src[0]&0xf8)<<8) | ((src[1]&0xf8)<<3) | (src[2] >> 3); +#ifdef PSP + *dst++ = ((src[2]&0xf8)<<8) | ((src[1]&0xf8)<<3) | (src[0] >> 3); // BGR +#else + *dst++ = ((src[0]&0xf8)<<8) | ((src[1]&0xf8)<<3) | (src[2] >> 3); // RGB +#endif src += 3; } - dst += 320 - width; + dst += BG_WIDTH - width; } break; }