[gimp/blend-tool-fun: 60/163] plug-ins: Fix generation of the AND mask for 32-bit ICO images
- From: Michael Henning <mhenning src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/blend-tool-fun: 60/163] plug-ins: Fix generation of the AND mask for 32-bit ICO images
- Date: Mon, 26 Oct 2015 02:23:15 +0000 (UTC)
commit f89302ce42022fbe92325d6219018e61f2b942d4
Author: Matt Giuca <mgiuca chromium org>
Date: Fri Sep 18 18:58:12 2015 +0200
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.
plug-ins/file-ico/ico-save.c | 15 ++++++++++++++-
1 files changed, 14 insertions(+), 1 deletions(-)
---
diff --git a/plug-ins/file-ico/ico-save.c b/plug-ins/file-ico/ico-save.c
index add4a32..9d90c67 100644
--- a/plug-ins/file-ico/ico-save.c
+++ b/plug-ins/file-ico/ico-save.c
@@ -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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]