Skip to content

Commit d415332

Browse files
committed
Set the alpha channel for less than 32-bit ICO/CUR images
Fixes #532
1 parent 54d879b commit d415332

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

CHANGES.txt

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
3.2.4:
2+
* Fixed alpha in less than 32-bit ICO and CUR images
3+
14
3.2.2:
25
* Fixed partial alpha in ICO and CUR images
36
* Set the cursor hotspot properties when loading CUR images

src/IMG_bmp.c

+6-1
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,11 @@ static SDL_Surface *LoadICOCUR_IO(SDL_IOStream * src, int type, bool closeio)
313313
if (SDL_ReadIO(src, &palette[i], 4) != 4) {
314314
goto done;
315315
}
316+
317+
/* Since biSize == 40, we know alpha is reserved and should be zero, meaning opaque */
318+
if ((palette[i] & 0xFF000000) == 0) {
319+
palette[i] |= 0xFF000000;
320+
}
316321
}
317322
}
318323

@@ -365,7 +370,7 @@ static SDL_Surface *LoadICOCUR_IO(SDL_IOStream * src, int type, bool closeio)
365370
Uint32 pixel;
366371
Uint8 channel;
367372
for (i = 0; i < surface->w; ++i) {
368-
pixel = 0;
373+
pixel = 0xFF000000;
369374
for (j = 0; j < 3; ++j) {
370375
/* Load each color channel into pixel */
371376
if (SDL_ReadIO(src, &channel, 1) != 1) {

0 commit comments

Comments
 (0)