summaryrefslogtreecommitdiff
path: root/uisimulator/bmp.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2002-05-16 12:48:38 +0000
committerDaniel Stenberg <daniel@haxx.se>2002-05-16 12:48:38 +0000
commit05fcd0b0e2958d47f9463dfca978ad904faaa282 (patch)
tree14f517d7aee8fddcb5aa63a7827cb0375b61befb /uisimulator/bmp.c
parenteae6296b5673705bf49c119b6fa4b456a6909a3b (diff)
downloadrockbox-05fcd0b0e2958d47f9463dfca978ad904faaa282.tar.gz
rockbox-05fcd0b0e2958d47f9463dfca978ad904faaa282.zip
this works with an 8bit indexed uncompressed BMP
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@584 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'uisimulator/bmp.c')
-rw-r--r--uisimulator/bmp.c17
1 files changed, 11 insertions, 6 deletions
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,
107 long size; 107 long size;
108 unsigned int row, col, byte, bit; 108 unsigned int row, col, byte, bit;
109 int l; 109 int l;
110 char *bmp; 110 unsigned char *bmp;
111 int width; 111 int width;
112 int height; 112 int height;
113 113
@@ -179,8 +179,12 @@ int read_bmp_file(char* filename,
179 background = 1; 179 background = 1;
180 } 180 }
181 181
182 width = readlong(fh.Width)*readshort(fh.BitCount); 182 /* width = readlong(fh.Width)*readshort(fh.BitCount); */
183 PaddedWidth = ((width+31)&(~0x1f))/8; 183
184 width = readlong(fh.Width);
185
186 /* PaddedWidth = ((width+31)&(~0x1f))/8; */
187 PaddedWidth = ((width+7)&(~0x7));
184 size = PaddedWidth*readlong(fh.Height); 188 size = PaddedWidth*readlong(fh.Height);
185 189
186 bmp = (unsigned char *)malloc(size); 190 bmp = (unsigned char *)malloc(size);
@@ -231,13 +235,14 @@ int read_bmp_file(char* filename,
231#else 235#else
232 /* Now convert the bitmap into an array with 1 byte per pixel, 236 /* Now convert the bitmap into an array with 1 byte per pixel,
233 exactly the size of the image */ 237 exactly the size of the image */
238
234 for(row = 0;row < bitmap_height;row++) { 239 for(row = 0;row < bitmap_height;row++) {
235 for(col = 0;col < bitmap_width;col++) { 240 for(col = 0;col < bitmap_width;col++) {
236 if(bmp[(bitmap_height - row) * PaddedWidth]) { 241 if(bmp[(bitmap_height-1 -row) * PaddedWidth + col]) {
237 bitmap[ (row/8) * bitmap_width + col ] |= 1<<(row&7); 242 bitmap[ (row/8) * bitmap_width + col ] &= ~ (1<<(row&7));
238 } 243 }
239 else { 244 else {
240 bitmap[ (row/8) * bitmap_width + col ] &= ~ 1<<(row&7); 245 bitmap[ (row/8) * bitmap_width + col ] |= 1<<(row&7);
241 } 246 }
242 } 247 }
243 } 248 }