We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 228

Summary: Wrong palette loading in bmp files
Product: SDL_image Reporter: Maurizio Monge <monge>
Component: miscAssignee: 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

Description Maurizio Monge 2006-05-13 16:06:32 UTC
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
Comment 1 Maurizio Monge 2006-05-13 16:10:24 UTC
Created attachment 127 [details]
A sample file
Comment 2 Sam Lantinga 2006-05-14 16:57:21 UTC
This is fixed in subversion, thanks!