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 - Wrong palette loading in bmp files
Summary: Wrong palette loading in bmp files
Status: RESOLVED FIXED
Alias: None
Product: SDL_image
Classification: Unclassified
Component: misc (show other bugs)
Version: unspecified
Hardware: All All
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-05-13 16:06 UTC by Maurizio Monge
Modified: 2006-05-14 16:57 UTC (History)
0 users

See Also:


Attachments
A sample file (35.80 KB, application/octet-stream)
2006-05-13 16:10 UTC, Maurizio Monge
Details

Note You need to log in before you can comment on or make changes to this bug.
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!