Skip to content

Commit

Permalink
Fixed bug 2219 - BMP loader do not handle big BITMAPINFOHEADER structure
Browse files Browse the repository at this point in the history
Patrice Mandin

I encountered a problem trying to load a 8-bit paletted BMP file using SDL. This file was generated using GIMP 2.8. It has a big BITMAPINFOHEADER (0x6c bytes for biSize field), and thus the palette is incorrectly setup.
  • Loading branch information
slouken committed Nov 8, 2013
1 parent 7a91853 commit e77932c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions IMG_bmp.c
Expand Up @@ -296,6 +296,8 @@ static SDL_Surface *LoadBMP_RW (SDL_RWops *src, int freesrc)
biClrUsed = 0;
biClrImportant = 0;
} else {
const int headerSize = 40;

biWidth = SDL_ReadLE32(src);
biHeight = SDL_ReadLE32(src);
biPlanes = SDL_ReadLE16(src);
Expand All @@ -306,6 +308,10 @@ static SDL_Surface *LoadBMP_RW (SDL_RWops *src, int freesrc)
biYPelsPerMeter = SDL_ReadLE32(src);
biClrUsed = SDL_ReadLE32(src);
biClrImportant = SDL_ReadLE32(src);

if (biSize > headerSize) {
SDL_RWseek(src, (biSize - headerSize), RW_SEEK_CUR);
}
}
if (biHeight < 0) {
topDown = SDL_TRUE;
Expand Down

0 comments on commit e77932c

Please sign in to comment.