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. The index used for alpha is also updated to adjust to the number of channels, since GimpRGB previously always used index 3 for both RGB and Grayscale images.
This commit is contained in:
parent
5a3d7f1005
commit
344be9337a
1 changed files with 12 additions and 8 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -445,9 +449,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 +462,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:
|
||||
|
|
|
|||
Loading…
Reference in a new issue