Support loading 2bpp .bmp files

main
Cameron Cawley 2022-09-17 21:45:08 +01:00 committed by Sam Lantinga
parent 1f7a7fd931
commit 8598f05b47
1 changed files with 7 additions and 2 deletions

View File

@ -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);