Support loading 2bpp .bmp files
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
diff --git a/src/video/SDL_bmp.c b/src/video/SDL_bmp.c
index cb22044..d52d6e8 100644
--- a/src/video/SDL_bmp.c
+++ b/src/video/SDL_bmp.c
@@ -328,15 +328,15 @@ SDL_LoadBMP_RW(SDL_RWops * src, int freesrc)
goto done;
}
- /* Expand 1 and 4 bit bitmaps to 8 bits per pixel */
+ /* Expand 1, 2 and 4 bit bitmaps to 8 bits per pixel */
switch (biBitCount) {
case 1:
+ case 2:
case 4:
ExpandBMP = biBitCount;
biBitCount = 8;
break;
case 0:
- case 2:
case 3:
case 5:
case 6:
@@ -473,6 +473,10 @@ SDL_LoadBMP_RW(SDL_RWops * src, int freesrc)
bmpPitch = (biWidth + 7) >> 3;
pad = (((bmpPitch) % 4) ? (4 - ((bmpPitch) % 4)) : 0);
break;
+ case 2:
+ bmpPitch = (biWidth + 3) >> 2;
+ pad = (((bmpPitch) % 4) ? (4 - ((bmpPitch) % 4)) : 0);
+ break;
case 4:
bmpPitch = (biWidth + 1) >> 1;
pad = (((bmpPitch) % 4) ? (4 - ((bmpPitch) % 4)) : 0);
@@ -489,6 +493,7 @@ SDL_LoadBMP_RW(SDL_RWops * src, int freesrc)
while (bits >= top && bits < end) {
switch (ExpandBMP) {
case 1:
+ case 2:
case 4:{
Uint8 pixel = 0;
int shift = (8 - ExpandBMP);