From 105f814de9108470402235f5db45ebd8460d07e7 Mon Sep 17 00:00:00 2001 From: Alx Sa Date: Sat, 19 Oct 2024 20:14:39 +0000 Subject: [PATCH 1/2] plug-ins: Make Legacy Grid colors independent of layer's transparency Per Anders Jonsson, the grid colors can have semi-transparency even if the image itself has no alpha channel. This patch always sets the GeglColor's babl format to contain an Alpha channel, rather than reusing the image's color format. --- plug-ins/common/grid.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/plug-ins/common/grid.c b/plug-ins/common/grid.c index 2a47bcf1c6a..e51ab808110 100644 --- a/plug-ins/common/grid.c +++ b/plug-ins/common/grid.c @@ -445,9 +445,9 @@ render_grid (GimpImage *image, else format = babl_format ("R'G'B' u8"); - gegl_color_get_pixel (hcolor_gegl, format, hcolor); - gegl_color_get_pixel (vcolor_gegl, format, vcolor); - gegl_color_get_pixel (icolor_gegl, format, icolor); + gegl_color_get_pixel (hcolor_gegl, babl_format ("R'G'B'A u8"), hcolor); + gegl_color_get_pixel (vcolor_gegl, babl_format ("R'G'B'A u8"), vcolor); + gegl_color_get_pixel (icolor_gegl, babl_format ("R'G'B'A u8"), icolor); break; case GIMP_GRAY: @@ -458,9 +458,9 @@ render_grid (GimpImage *image, else format = babl_format ("Y' u8"); - gegl_color_get_pixel (hcolor_gegl, format, hcolor); - gegl_color_get_pixel (vcolor_gegl, format, vcolor); - gegl_color_get_pixel (icolor_gegl, format, icolor); + gegl_color_get_pixel (hcolor_gegl, babl_format ("Y'A u8"), hcolor); + gegl_color_get_pixel (vcolor_gegl, babl_format ("Y'A u8"), vcolor); + gegl_color_get_pixel (icolor_gegl, babl_format ("Y'A u8"), icolor); break; case GIMP_INDEXED: -- GitLab From 5eb473f1cd8d68a571a8a534b112416fdb35b433 Mon Sep 17 00:00:00 2001 From: Alx Sa Date: Sat, 19 Oct 2024 23:18:01 +0000 Subject: [PATCH 2/2] Also fix for grayscale --- plug-ins/common/grid.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/plug-ins/common/grid.c b/plug-ins/common/grid.c index e51ab808110..e48ab37fac0 100644 --- a/plug-ins/common/grid.c +++ b/plug-ins/common/grid.c @@ -349,6 +349,9 @@ pix_composite (guchar *p1, gboolean alpha) { gint b; + gint alpha_index; + + alpha_index = alpha ? (bytes - 1) : bytes; if (blend) { @@ -357,7 +360,8 @@ pix_composite (guchar *p1, for (b = 0; b < bytes; b++) { - *p1 = *p1 * (1.0 - p2[3]/255.0) + p2[b] * p2[3]/255.0; + *p1 = *p1 * (1.0 - p2[alpha_index] / 255.0) + + p2[b] * p2[alpha_index] / 255.0; p1++; } } @@ -369,7 +373,7 @@ pix_composite (guchar *p1, if (alpha && *p1 < 255) { - b = *p1 + 255.0 * ((gdouble) p2[3] / (255.0 - *p1)); + b = *p1 + 255.0 * ((gdouble) p2[alpha_index] / (255.0 - *p1)); *p1 = b > 255 ? 255 : b; } -- GitLab