mirror of
https://github.com/Relintai/sdl2_frt.git
synced 2024-12-16 11:06:49 +01:00
Fixed bug 2219 - BMP loader do not handle big BITMAPINFOHEADER structure
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.
This commit is contained in:
parent
48e44f7fcb
commit
95c67ed9a7
@ -150,6 +150,8 @@ SDL_LoadBMP_RW(SDL_RWops * src, int freesrc)
|
|||||||
biBitCount = SDL_ReadLE16(src);
|
biBitCount = SDL_ReadLE16(src);
|
||||||
biCompression = BI_RGB;
|
biCompression = BI_RGB;
|
||||||
} else {
|
} else {
|
||||||
|
const int headerSize = 40;
|
||||||
|
|
||||||
biWidth = SDL_ReadLE32(src);
|
biWidth = SDL_ReadLE32(src);
|
||||||
biHeight = SDL_ReadLE32(src);
|
biHeight = SDL_ReadLE32(src);
|
||||||
/* biPlanes = */ SDL_ReadLE16(src);
|
/* biPlanes = */ SDL_ReadLE16(src);
|
||||||
@ -160,6 +162,10 @@ SDL_LoadBMP_RW(SDL_RWops * src, int freesrc)
|
|||||||
/* biYPelsPerMeter = */ SDL_ReadLE32(src);
|
/* biYPelsPerMeter = */ SDL_ReadLE32(src);
|
||||||
biClrUsed = SDL_ReadLE32(src);
|
biClrUsed = SDL_ReadLE32(src);
|
||||||
/* biClrImportant = */ SDL_ReadLE32(src);
|
/* biClrImportant = */ SDL_ReadLE32(src);
|
||||||
|
|
||||||
|
if (biSize > headerSize) {
|
||||||
|
SDL_RWseek(src, (biSize - headerSize), RW_SEEK_CUR);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (biHeight < 0) {
|
if (biHeight < 0) {
|
||||||
topDown = SDL_TRUE;
|
topDown = SDL_TRUE;
|
||||||
|
Loading…
Reference in New Issue
Block a user