forked from len0rd/rockbox
this works with an 8bit indexed uncompressed BMP
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@584 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
eae6296b56
commit
05fcd0b0e2
1 changed files with 11 additions and 6 deletions
|
|
@ -107,7 +107,7 @@ int read_bmp_file(char* filename,
|
||||||
long size;
|
long size;
|
||||||
unsigned int row, col, byte, bit;
|
unsigned int row, col, byte, bit;
|
||||||
int l;
|
int l;
|
||||||
char *bmp;
|
unsigned char *bmp;
|
||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
|
|
||||||
|
|
@ -179,8 +179,12 @@ int read_bmp_file(char* filename,
|
||||||
background = 1;
|
background = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
width = readlong(fh.Width)*readshort(fh.BitCount);
|
/* width = readlong(fh.Width)*readshort(fh.BitCount); */
|
||||||
PaddedWidth = ((width+31)&(~0x1f))/8;
|
|
||||||
|
width = readlong(fh.Width);
|
||||||
|
|
||||||
|
/* PaddedWidth = ((width+31)&(~0x1f))/8; */
|
||||||
|
PaddedWidth = ((width+7)&(~0x7));
|
||||||
size = PaddedWidth*readlong(fh.Height);
|
size = PaddedWidth*readlong(fh.Height);
|
||||||
|
|
||||||
bmp = (unsigned char *)malloc(size);
|
bmp = (unsigned char *)malloc(size);
|
||||||
|
|
@ -231,13 +235,14 @@ int read_bmp_file(char* filename,
|
||||||
#else
|
#else
|
||||||
/* Now convert the bitmap into an array with 1 byte per pixel,
|
/* Now convert the bitmap into an array with 1 byte per pixel,
|
||||||
exactly the size of the image */
|
exactly the size of the image */
|
||||||
|
|
||||||
for(row = 0;row < bitmap_height;row++) {
|
for(row = 0;row < bitmap_height;row++) {
|
||||||
for(col = 0;col < bitmap_width;col++) {
|
for(col = 0;col < bitmap_width;col++) {
|
||||||
if(bmp[(bitmap_height - row) * PaddedWidth]) {
|
if(bmp[(bitmap_height-1 -row) * PaddedWidth + col]) {
|
||||||
bitmap[ (row/8) * bitmap_width + col ] |= 1<<(row&7);
|
bitmap[ (row/8) * bitmap_width + col ] &= ~ (1<<(row&7));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
bitmap[ (row/8) * bitmap_width + col ] &= ~ 1<<(row&7);
|
bitmap[ (row/8) * bitmap_width + col ] |= 1<<(row&7);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue