summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2007-11-30 08:51:18 +0000
committerJens Arnold <amiconn@rockbox.org>2007-11-30 08:51:18 +0000
commit89bfb669391da1b6fe031d29cf6deb79cac9d739 (patch)
tree00e3b7ef0cd77f1c40360cc43f7e5ebbc02e56e6 /apps
parent5323fe996b6a62be2201de2b2a5f6917a6040cb1 (diff)
downloadrockbox-89bfb669391da1b6fe031d29cf6deb79cac9d739.zip
rockbox-89bfb669391da1b6fe031d29cf6deb79cac9d739.tar.gz
rockbox-89bfb669391da1b6fe031d29cf6deb79cac9d739.tar.bz2
rockbox-89bfb669391da1b6fe031d29cf6deb79cac9d739.tar.xz
BMP loader: Handle top-down BMP files (height is negative). Note that the e200 example pictures still don't work, as they are larger than the screen (not a loader problem).
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15855 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/recorder/bmp.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/apps/recorder/bmp.c b/apps/recorder/bmp.c
index 6416eb7..7b6f629 100644
--- a/apps/recorder/bmp.c
+++ b/apps/recorder/bmp.c
@@ -59,8 +59,8 @@ struct bmp_header {
uint16_t reserved2; /* 0 */
uint32_t off_bits; /* offset to bitmap */
uint32_t struct_size; /* size of this struct (40) */
- uint32_t width; /* bmap width in pixels */
- uint32_t height; /* bmap height in pixels */
+ int32_t width; /* bmap width in pixels */
+ int32_t height; /* bmap height in pixels */
uint16_t planes; /* num planes - always 1 */
uint16_t bit_count; /* bits per pixel */
uint32_t compression; /* compression flag */
@@ -177,8 +177,9 @@ int read_bmp_fd(int fd,
struct bmp_header bmph;
int width, height, padded_width;
int dst_height, dst_width;
- int row, col, ret;
int depth, numcolors, compression, totalsize;
+ int row, col, ret;
+ int rowstart, rowstop, rowstep;
unsigned char *bitmap = bm->data;
uint32_t bmpbuf[LCD_WIDTH]; /* Buffer for one line */
@@ -230,6 +231,17 @@ int read_bmp_fd(int fd,
}
height = readlong(&bmph.height);
+ if (height < 0) { /* Top-down BMP file */
+ height = -height;
+ rowstart = 0;
+ rowstop = height;
+ rowstep = 1;
+ } else { /* normal BMP */
+ rowstart = height - 1;
+ rowstop = -1;
+ rowstep = -1;
+ }
+
depth = readshort(&bmph.bit_count);
padded_width = ((width * depth + 31) >> 3) & ~3; /* 4-byte boundary aligned */
@@ -346,7 +358,7 @@ int read_bmp_fd(int fd,
memset(bitmap, 0, totalsize);
/* loop to read rows and put them to buffer */
- for (row = height - 1; row >= 0; row--) {
+ for (row = rowstart; row != rowstop; row += rowstep) {
unsigned data, mask;
unsigned char *p;
uint16_t *p2;