stb_image: fix bug where bmp claimed to be 24-bit but also claimed to have an alpha bitfield
This commit is contained in:
parent
61be29d161
commit
26a02f81ca
10
stb_image.h
10
stb_image.h
@ -5237,6 +5237,9 @@ static void *stbi__bmp_load(stbi__context *s, int *x, int *y, int *comp, int req
|
|||||||
psize = (info.offset - 14 - info.hsz) >> 2;
|
psize = (info.offset - 14 - info.hsz) >> 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (info.bpp == 24 && ma == 0xff000000)
|
||||||
|
s->img_n = 3;
|
||||||
|
else
|
||||||
s->img_n = ma ? 4 : 3;
|
s->img_n = ma ? 4 : 3;
|
||||||
if (req_comp && req_comp >= 3) // we can directly decode 3 or 4
|
if (req_comp && req_comp >= 3) // we can directly decode 3 or 4
|
||||||
target = req_comp;
|
target = req_comp;
|
||||||
@ -6936,7 +6939,12 @@ static int stbi__bmp_info(stbi__context *s, int *x, int *y, int *comp)
|
|||||||
return 0;
|
return 0;
|
||||||
if (x) *x = s->img_x;
|
if (x) *x = s->img_x;
|
||||||
if (y) *y = s->img_y;
|
if (y) *y = s->img_y;
|
||||||
if (comp) *comp = info.ma ? 4 : 3;
|
if (comp) {
|
||||||
|
if (info.bpp == 24 && info.ma == 0xff000000)
|
||||||
|
*comp = 3;
|
||||||
|
else
|
||||||
|
*comp = info.ma ? 4 : 3;
|
||||||
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user