From db18eb504dfead1803f1ff5695b1b1a8dcebffed Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Tue, 16 Dec 2003 23:25:54 +0000 Subject: [PATCH] * examples/view.c: + Fixed a bug in the loading of 1bpp BMPs. + Commented stuff. --- examples/view.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/examples/view.c b/examples/view.c index fb133db..66aab5c 100644 --- a/examples/view.c +++ b/examples/view.c @@ -523,7 +523,7 @@ static void load_image(const char *name) if(k == 0) bits = freadint(fp); pixels[w * i * depth + j] = - (bits >> ((k & ~0xf) + 0xf - (k & 0xf))) & 0xf; + (bits >> ((k & ~0xf) + 0xf - (k & 0xf))) & 0x1; } break; case 4: @@ -537,9 +537,11 @@ static void load_image(const char *name) } break; default: + /* Works for 8bpp, but also for 16, 24 etc. */ fread(pixels + w * i * depth, w * depth, 1, fp); /* Pad reads to 4 bytes */ - tmp = (4 - (w * depth) % 4) % 4; + tmp = (w * depth) % 4; + tmp = (4 - tmp) % 4; while(tmp--) freadchar(fp); break;