plug-ins: Fix defaults for 1/4/8 bpp ICO export

8bpp and below ICO formats use a 1 bit mask for transparency.
When imported the mask is treated as an additional transparent color.
If the icon used the max palette (e.g. 2 colors for a 1bit icon),
the default export format will become larger than necessary.
This checks if the layer still has 1 bit alpha, and subtracts the
mask color from the count.
This commit is contained in:
Alx Sa 2023-06-09 22:12:43 +00:00
parent 317aa803d2
commit 73d5dcecae
1 changed files with 10 additions and 1 deletions

View File

@ -254,7 +254,7 @@ ico_save_init (GimpImage *image,
{
num_colors = ico_get_layer_num_colors (iter->data, &uses_alpha_values);
if (!uses_alpha_values)
if (! uses_alpha_values)
{
if (num_colors <= 2)
{
@ -648,6 +648,15 @@ ico_get_layer_num_colors (GimpLayer *layer,
num_colors = g_hash_table_size (hash);
/* Icons with 1 bit masks are converted to
* full transparency when loaded in GIMP.
* If the layer is not semi-transparent, we
* can subtract the "mask color" out to fix
* the default depth value for 1/4/8 bpp icons.
*/
if (! *uses_alpha_levels)
num_colors--;
g_hash_table_destroy (hash);
g_free (colors);