diff options
Diffstat (limited to 'uisimulator')
-rw-r--r-- | uisimulator/bmp.c | 17 |
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 | } |