This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project gfxprim.git.
The branch, master has been updated via 2452f86d8fc399fb31bc2688a1c1f0cdea4c4156 (commit) from 1bd709f7b02e6cf8c47318125d75d21092a8bcd9 (commit)
Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below.
- Log ----------------------------------------------------------------- http://repo.or.cz/w/gfxprim.git/commit/2452f86d8fc399fb31bc2688a1c1f0cdea4c4...
commit 2452f86d8fc399fb31bc2688a1c1f0cdea4c4156 Author: Cyril Hrubis metan@ucw.cz Date: Mon Jan 9 19:11:50 2012 +0100
loaders: BMP loader, fix 24 BPP, add 1 BPP todo: palettes
diff --git a/libs/loaders/GP_BMP.c b/libs/loaders/GP_BMP.c index b820dc8..d6e514d 100644 --- a/libs/loaders/GP_BMP.c +++ b/libs/loaders/GP_BMP.c @@ -148,8 +148,8 @@ static GP_RetCode read_bitmap_info_header(FILE *f, return 1; }
- header->h = buf[0] + (buf[1]<<8) + (buf[2]<<16) + (buf[3]<<24); - header->w = buf[4] + (buf[5]<<8) + (buf[6]<<16) + (buf[7]<<24); + header->w = buf[0] + (buf[1]<<8) + (buf[2]<<16) + (buf[3]<<24); + header->h = buf[4] + (buf[5]<<8) + (buf[6]<<16) + (buf[7]<<24); header->bpp = buf[10] + (buf[11]<<8); @@ -191,6 +191,9 @@ GP_RetCode read_pixels_offset(FILE *f, uint32_t *offset) GP_PixelType match_pixel_type(struct bitmap_info_header *header) { switch (header->bpp) { + case 1: + /* context->bitendian = 1 */ + return GP_PIXEL_G1; case 24: return GP_PIXEL_RGB888; } @@ -198,6 +201,43 @@ GP_PixelType match_pixel_type(struct bitmap_info_header *header) return GP_PIXEL_UNKNOWN; }
+GP_RetCode read_g1(FILE *f, struct bitmap_info_header *header, + GP_Context *context, GP_ProgressCallback *callback) +{ + int32_t y; + uint32_t row_size = header->w / 8 + !!(header->w%8); + + context->bit_endian = 1; + + for (y = header->h - 1; y >= 0; y--) { + uint8_t *row = GP_PIXEL_ADDR(context, 0, y); + + if (fread(row, 1, row_size, f) != row_size) + return GP_EBADFILE; + + /* Rows are four byte aligned */ + switch (row_size % 4) { + case 1: + fgetc(f); + case 2: + fgetc(f); + case 3: + fgetc(f); + case 0: + break; + } + + if (GP_ProgressCallbackReport(callback, header->h - y -1, + context->h, context->w)) { + GP_DEBUG(1, "Operation aborted"); + return GP_EINTR; + } + } + + GP_ProgressCallbackDone(callback); + return GP_ESUCCESS; +} + GP_RetCode read_rgb888(FILE *f, struct bitmap_info_header *header, GP_Context *context, GP_ProgressCallback *callback) { @@ -212,11 +252,11 @@ GP_RetCode read_rgb888(FILE *f, struct bitmap_info_header *header, /* Rows are four byte aligned */ switch (row_size % 4) { - case 3: + case 1: fgetc(f); case 2: fgetc(f); - case 1: + case 3: fgetc(f); case 0: break; @@ -252,6 +292,8 @@ GP_RetCode read_bitmap_pixels(FILE *f, struct bitmap_info_header *header, }
switch (header->bpp) { + case 1: + return read_g1(f, header, context, callback); case 24: return read_rgb888(f, header, context, callback); } @@ -352,4 +394,3 @@ GP_RetCode GP_LoadBMP(const char *src_path, GP_Context **res,
return GP_ReadBMP(f, res, callback); } -
-----------------------------------------------------------------------
Summary of changes: libs/loaders/GP_BMP.c | 51 ++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 46 insertions(+), 5 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos@gmail.com if you want to unsubscribe, or site admin admin@repo.or.cz if you receive no reply.