Skip to content

Commit

Permalink
Set the alpha channel for less than 32-bit ICO/CUR images
Browse files Browse the repository at this point in the history
Fixes #532

(cherry picked from commit d415332)
  • Loading branch information
slouken committed Mar 3, 2025
1 parent b146dff commit f1e4fff
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
2.8.8:
* Fixed alpha in less than 32-bit ICO and CUR images

2.8.6:
* Fixed partial alpha in ICO and CUR images

Expand Down
7 changes: 6 additions & 1 deletion src/IMG_bmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,11 @@ LoadICOCUR_RW(SDL_RWops * src, int type, int freesrc)
}
for (i = 0; i < (int) biClrUsed; ++i) {
SDL_RWread(src, &palette[i], 4, 1);

/* Since biSize == 40, we know alpha is reserved and should be zero, meaning opaque */
if ((palette[i] & 0xFF000000) == 0) {
palette[i] |= 0xFF000000;
}
}
}

Expand Down Expand Up @@ -361,7 +366,7 @@ LoadICOCUR_RW(SDL_RWops * src, int type, int freesrc)
Uint32 pixel;
Uint8 channel;
for (i = 0; i < surface->w; ++i) {
pixel = 0;
pixel = 0xFF000000;
for (j = 0; j < 3; ++j) {
/* Load each color channel into pixel */
if (!SDL_RWread(src, &channel, 1, 1)) {
Expand Down

0 comments on commit f1e4fff

Please sign in to comment.