From 05fcd0b0e2958d47f9463dfca978ad904faaa282 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 16 May 2002 12:48:38 +0000 Subject: this works with an 8bit indexed uncompressed BMP git-svn-id: svn://svn.rockbox.org/rockbox/trunk@584 a1c6a512-1295-4272-9138-f99709370657 --- uisimulator/bmp.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'uisimulator/bmp.c') diff --git a/uisimulator/bmp.c b/uisimulator/bmp.c index 5df003a537..404869fcf2 100644 --- a/uisimulator/bmp.c +++ b/uisimulator/bmp.c @@ -107,7 +107,7 @@ int read_bmp_file(char* filename, long size; unsigned int row, col, byte, bit; int l; - char *bmp; + unsigned char *bmp; int width; int height; @@ -179,8 +179,12 @@ int read_bmp_file(char* filename, background = 1; } - width = readlong(fh.Width)*readshort(fh.BitCount); - PaddedWidth = ((width+31)&(~0x1f))/8; + /* width = readlong(fh.Width)*readshort(fh.BitCount); */ + + width = readlong(fh.Width); + + /* PaddedWidth = ((width+31)&(~0x1f))/8; */ + PaddedWidth = ((width+7)&(~0x7)); size = PaddedWidth*readlong(fh.Height); bmp = (unsigned char *)malloc(size); @@ -231,13 +235,14 @@ int read_bmp_file(char* filename, #else /* Now convert the bitmap into an array with 1 byte per pixel, exactly the size of the image */ + for(row = 0;row < bitmap_height;row++) { for(col = 0;col < bitmap_width;col++) { - if(bmp[(bitmap_height - row) * PaddedWidth]) { - bitmap[ (row/8) * bitmap_width + col ] |= 1<<(row&7); + if(bmp[(bitmap_height-1 -row) * PaddedWidth + col]) { + bitmap[ (row/8) * bitmap_width + col ] &= ~ (1<<(row&7)); } else { - bitmap[ (row/8) * bitmap_width + col ] &= ~ 1<<(row&7); + bitmap[ (row/8) * bitmap_width + col ] |= 1<<(row&7); } } } -- cgit v1.2.3