| Summary: | Wrong palette loading in bmp files | ||
|---|---|---|---|
| Product: | SDL_image | Reporter: | Maurizio Monge <monge> |
| Component: | misc | Assignee: | Sam Lantinga <slouken> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | ||
| Version: | unspecified | ||
| Hardware: | All | ||
| OS: | All | ||
| Attachments: | A sample file | ||
Created attachment 127 [details]
A sample file
This is fixed in subversion, thanks! |
The palette of bmp files is loaded from a wrong offset in the bmp file. I am attaching a test file (it is being loaded correcty by imagemagick, gdk-pixbuf and windows too, but not with current sdl-image). Here is a very little patch to fix the problem: diff -Nurb SDL_image-1.2.4-old/IMG_bmp.c SDL_image-1.2.4-new/IMG_bmp.c --- SDL_image-1.2.4-old/IMG_bmp.c 2004-12-16 05:41:01.000000000 +0100 +++ SDL_image-1.2.4-new/IMG_bmp.c 2006-05-13 04:51:40.000000000 +0200 @@ -301,6 +301,13 @@ /* Load the palette, if any */ palette = (surface->format)->palette; if ( palette ) { + + if ( SDL_RWseek(src, fp_offset+14+biSize, SEEK_SET) < 0 ) { + SDL_Error(SDL_EFSEEK); + was_error = 1; + goto done; + } + /* | guich: always use 1<<bpp b/c some bitmaps can bring wrong information | for colorsUsed