Skip to content

Commit f1e4fff

Browse files
committed
Set the alpha channel for less than 32-bit ICO/CUR images
Fixes #532 (cherry picked from commit d415332)
1 parent b146dff commit f1e4fff

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+
2.8.8:
2+
* Fixed alpha in less than 32-bit ICO and CUR images
3+
14
2.8.6:
25
* Fixed partial alpha in ICO and CUR images
36

src/IMG_bmp.c

+6-1
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,11 @@ LoadICOCUR_RW(SDL_RWops * src, int type, int freesrc)
307307
}
308308
for (i = 0; i < (int) biClrUsed; ++i) {
309309
SDL_RWread(src, &palette[i], 4, 1);
310+
311+
/* Since biSize == 40, we know alpha is reserved and should be zero, meaning opaque */
312+
if ((palette[i] & 0xFF000000) == 0) {
313+
palette[i] |= 0xFF000000;
314+
}
310315
}
311316
}
312317

@@ -361,7 +366,7 @@ LoadICOCUR_RW(SDL_RWops * src, int type, int freesrc)
361366
Uint32 pixel;
362367
Uint8 channel;
363368
for (i = 0; i < surface->w; ++i) {
364-
pixel = 0;
369+
pixel = 0xFF000000;
365370
for (j = 0; j < 3; ++j) {
366371
/* Load each color channel into pixel */
367372
if (!SDL_RWread(src, &channel, 1, 1)) {

0 commit comments

Comments
 (0)