diff options
author | Daniel Stenberg <daniel@haxx.se> | 2004-12-20 09:09:49 +0000 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2004-12-20 09:09:49 +0000 |
commit | 463e329d0879446be0a48c0669a01b24a682c397 (patch) | |
tree | 29f8aca7b4e30244736f41f2abf5fba8062d5459 /tools | |
parent | 78cf6aa6dc763c425788b614b2a099eef6839fba (diff) |
Fixed to allow conversions of 160x128 pictures too.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@5498 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'tools')
-rw-r--r-- | tools/bmp2rb.c | 36 |
1 files changed, 27 insertions, 9 deletions
diff --git a/tools/bmp2rb.c b/tools/bmp2rb.c index 18b37f9cf6..f874fed677 100644 --- a/tools/bmp2rb.c +++ b/tools/bmp2rb.c @@ -104,10 +104,12 @@ int read_bmp_file(char* filename, int background; int fd = open(filename, O_RDONLY); long size; + long allocsize; unsigned int row, col; int l; unsigned char *bmp; int width; + int height; int depth; if(fd == -1) @@ -136,22 +138,30 @@ int read_bmp_file(char* filename, } /* Exit if too wide */ - if(readlong(&fh.Width) > 112) + if(readlong(&fh.Width) > 160) { - debugf("error - Bitmap is too wide (%d pixels, max is 112)\n", + debugf("error - Bitmap is too wide for iRiver models (%d pixels, max is 160)\n", readlong(&fh.Width)); - close(fd); return 3; } + if(readlong(&fh.Width) > 112) + { + debugf("info - Bitmap is too wide for Archos models (%d pixels, max is 112)\n", + readlong(&fh.Width)); + } /* Exit if too high */ - if(readlong(&fh.Height) > 64) + if(readlong(&fh.Height) > 128) { - debugf("error - Bitmap is too high (%d pixels, max is 64)\n", + debugf("error - Bitmap is too high for iRiver models (%d pixels, max is 128)\n", readlong(&fh.Height)); - close(fd); return 4; } + if(readlong(&fh.Height) > 64) + { + debugf("info - Bitmap is too high for Archos models (%d pixels, max is 64)\n", + readlong(&fh.Height)); + } for(l=0;l < 2;l++) { @@ -191,10 +201,18 @@ int read_bmp_file(char* filename, else PaddedWidth = ((width+31)&(~0x1f))/8; - size = PaddedWidth*readlong(&fh.Height); - + height = readlong(&fh.Height); + + allocsize = size = PaddedWidth*height; /* read this many bytes */ bmp = (unsigned char *)malloc(size); - *bitmap = (unsigned char *)malloc(size); + + if(height%8) { + /* not even 8 bytes, add up to a full 8 pixels boundary */ + height += 8-(height%8); + allocsize = PaddedWidth*height; /* bytes to alloc */ + } + + *bitmap = (unsigned char *)malloc(allocsize); if(bmp == NULL) { |