mirror of https://github.com/GNOME/gimp.git
plug-ins: Fix generation of the AND mask for 32-bit ICO images
Previously, the mask would be transparent if the alpha was <50%. However, this causes pixels to become black in some places in Windows (notably, the taskbar on Windows 10). Therefore, always set the mask to opaque if a pixel is partially or fully opaque.
This commit is contained in:
parent
7f2d5ebbc5
commit
07dfe4a5eb
|
@ -826,6 +826,8 @@ ico_write_icon (FILE *fp,
|
|||
guint32 *palette32 = NULL;
|
||||
gint palette_len = 0;
|
||||
|
||||
guint8 alpha_threshold;
|
||||
|
||||
D(("Creating data structures for icon %i ------------------------\n",
|
||||
num_icon));
|
||||
|
||||
|
@ -873,6 +875,17 @@ ico_write_icon (FILE *fp,
|
|||
/* Create and_map. It's padded out to 32 bits per line: */
|
||||
and_map = ico_alloc_map (width, height, 1, &and_len);
|
||||
|
||||
/* 32-bit bitmaps have an alpha channel as well as a mask. Any partially or
|
||||
* fully opaque pixel should have an opaque mask (some ICO code in Windows
|
||||
* draws pixels as black if they have a transparent mask but a non-transparent
|
||||
* alpha value).
|
||||
*
|
||||
* For bitmaps without an alpha channel, we use the normal threshold to build
|
||||
* the mask, so that the mask is as close as possible to the original alpha
|
||||
* channel.
|
||||
*/
|
||||
alpha_threshold = header.bpp < 32 ? ICO_ALPHA_THRESHOLD : 0;
|
||||
|
||||
for (y = 0; y < height; y++)
|
||||
for (x = 0; x < width; x++)
|
||||
{
|
||||
|
@ -880,7 +893,7 @@ ico_write_icon (FILE *fp,
|
|||
|
||||
ico_set_bit_in_data (and_map, width,
|
||||
(height - y -1) * width + x,
|
||||
(pixel[3] > ICO_ALPHA_THRESHOLD ? 0 : 1));
|
||||
(pixel[3] > alpha_threshold ? 0 : 1));
|
||||
}
|
||||
|
||||
xor_map = ico_alloc_map (width, height, header.bpp, &xor_len);
|
||||
|
|
Loading…
Reference in New Issue