mirror of
https://gitlab.gnome.org/GNOME/gimp.git
synced 2025-07-03 17:33:25 +00:00
plug-ins: Import legacy PSD Inner Shadow
This patch adds support for loading and applying active legacy Inner Shadow layer styles in PSD images. It uses gegl:inner-glow with certain preset values to replicate the Photoshop filter.
This commit is contained in:
parent
7262faed16
commit
56c83101e9
2 changed files with 95 additions and 78 deletions
|
@ -790,92 +790,53 @@ load_resource_lrfx (const PSDlayerres *res_a,
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (memcmp (effectname, "dsdw", 4) == 0)
|
else if (memcmp (effectname, "dsdw", 4) == 0 ||
|
||||||
|
memcmp (effectname, "isdw", 4) == 0)
|
||||||
{
|
{
|
||||||
gchar bim[4];
|
PSDLayerStyleShadow *shadow;
|
||||||
guint16 temp[8];
|
gchar bim[4];
|
||||||
|
guint16 temp[8];
|
||||||
|
|
||||||
if (psd_read (input, &ls_a->dsdw.size, 4, error) < 4 ||
|
if (memcmp (effectname, "dsdw", 4) == 0)
|
||||||
psd_read (input, &ls_a->dsdw.ver, 4, error) < 4 ||
|
shadow = &ls_a->dsdw;
|
||||||
psd_read (input, &temp, 16, error) < 2 ||
|
else
|
||||||
psd_read (input, &ls_a->dsdw.color[0], 2, error) < 2 ||
|
shadow = &ls_a->isdw;
|
||||||
psd_read (input, &ls_a->dsdw.color[1], 2, error) < 2 ||
|
|
||||||
psd_read (input, &ls_a->dsdw.color[2], 2, error) < 2 ||
|
if (psd_read (input, &shadow->size, 4, error) < 4 ||
|
||||||
psd_read (input, &ls_a->dsdw.color[3], 2, error) < 2 ||
|
psd_read (input, &shadow->ver, 4, error) < 4 ||
|
||||||
psd_read (input, &ls_a->dsdw.color[4], 2, error) < 2 ||
|
psd_read (input, &temp, 16, error) < 2 ||
|
||||||
psd_read (input, &bim, 4, error) < 4 ||
|
psd_read (input, &shadow->color[0], 2, error) < 2 ||
|
||||||
psd_read (input, &ls_a->dsdw.blendsig, 4, error) < 4 ||
|
psd_read (input, &shadow->color[1], 2, error) < 2 ||
|
||||||
psd_read (input, &ls_a->dsdw.effecton, 1, error) < 1 ||
|
psd_read (input, &shadow->color[2], 2, error) < 2 ||
|
||||||
psd_read (input, &ls_a->dsdw.anglefx, 1, error) < 1 ||
|
psd_read (input, &shadow->color[3], 2, error) < 2 ||
|
||||||
psd_read (input, &ls_a->dsdw.opacity, 1, error) < 1)
|
psd_read (input, &shadow->color[4], 2, error) < 2 ||
|
||||||
|
psd_read (input, &bim, 4, error) < 4 ||
|
||||||
|
psd_read (input, &shadow->blendsig, 4, error) < 4 ||
|
||||||
|
psd_read (input, &shadow->effecton, 1, error) < 1 ||
|
||||||
|
psd_read (input, &shadow->anglefx, 1, error) < 1 ||
|
||||||
|
psd_read (input, &shadow->opacity, 1, error) < 1)
|
||||||
{
|
{
|
||||||
psd_set_error (error);
|
psd_set_error (error);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
ls_a->dsdw.size = GUINT32_TO_BE (ls_a->dsdw.size);
|
shadow->size = GUINT32_TO_BE (shadow->size);
|
||||||
ls_a->dsdw.ver = GUINT32_TO_BE (ls_a->dsdw.ver);
|
shadow->ver = GUINT32_TO_BE (shadow->ver);
|
||||||
ls_a->dsdw.blur = FIXED_TO_FLOAT (GUINT16_TO_BE (temp[0]),
|
shadow->blur = FIXED_TO_FLOAT (GUINT16_TO_BE (temp[0]),
|
||||||
GUINT16_TO_BE (temp[1]));
|
GUINT16_TO_BE (temp[1]));
|
||||||
ls_a->dsdw.intensity = FIXED_TO_FLOAT (GUINT16_TO_BE (temp[2]),
|
shadow->intensity = FIXED_TO_FLOAT (GUINT16_TO_BE (temp[2]),
|
||||||
GUINT16_TO_BE (temp[3]));
|
GUINT16_TO_BE (temp[3]));
|
||||||
ls_a->dsdw.angle = FIXED_TO_FLOAT (GUINT16_TO_BE (temp[4]),
|
shadow->angle = FIXED_TO_FLOAT (GUINT16_TO_BE (temp[4]),
|
||||||
GUINT16_TO_BE (temp[5]));
|
GUINT16_TO_BE (temp[5]));
|
||||||
ls_a->dsdw.distance = FIXED_TO_FLOAT (GUINT16_TO_BE (temp[6]),
|
shadow->distance = FIXED_TO_FLOAT (GUINT16_TO_BE (temp[6]),
|
||||||
GUINT16_TO_BE (temp[7]));
|
GUINT16_TO_BE (temp[7]));
|
||||||
|
|
||||||
if (ls_a->dsdw.ver == 2)
|
if (shadow->ver == 2)
|
||||||
{
|
{
|
||||||
if (psd_read (input, &ls_a->dsdw.natcolor[0], 2, error) < 2 ||
|
if (psd_read (input, &shadow->natcolor[0], 2, error) < 2 ||
|
||||||
psd_read (input, &ls_a->dsdw.natcolor[1], 2, error) < 2 ||
|
psd_read (input, &shadow->natcolor[1], 2, error) < 2 ||
|
||||||
psd_read (input, &ls_a->dsdw.natcolor[2], 2, error) < 2 ||
|
psd_read (input, &shadow->natcolor[2], 2, error) < 2 ||
|
||||||
psd_read (input, &ls_a->dsdw.natcolor[3], 2, error) < 2 ||
|
psd_read (input, &shadow->natcolor[3], 2, error) < 2 ||
|
||||||
psd_read (input, &ls_a->dsdw.natcolor[4], 2, error) < 2)
|
psd_read (input, &shadow->natcolor[4], 2, error) < 2)
|
||||||
{
|
|
||||||
psd_set_error (error);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (memcmp (effectname, "isdw", 4) == 0)
|
|
||||||
{
|
|
||||||
gchar bim[4];
|
|
||||||
guint16 temp[8];
|
|
||||||
|
|
||||||
if (psd_read (input, &ls_a->isdw.size, 4, error) < 4 ||
|
|
||||||
psd_read (input, &ls_a->isdw.ver, 4, error) < 4 ||
|
|
||||||
psd_read (input, &temp, 16, error) < 2 ||
|
|
||||||
psd_read (input, &ls_a->isdw.color[0], 2, error) < 2 ||
|
|
||||||
psd_read (input, &ls_a->isdw.color[1], 2, error) < 2 ||
|
|
||||||
psd_read (input, &ls_a->isdw.color[2], 2, error) < 2 ||
|
|
||||||
psd_read (input, &ls_a->isdw.color[3], 2, error) < 2 ||
|
|
||||||
psd_read (input, &ls_a->isdw.color[4], 2, error) < 2 ||
|
|
||||||
psd_read (input, &bim, 4, error) < 4 ||
|
|
||||||
psd_read (input, &ls_a->isdw.blendsig, 4, error) < 4 ||
|
|
||||||
psd_read (input, &ls_a->isdw.effecton, 1, error) < 1 ||
|
|
||||||
psd_read (input, &ls_a->isdw.anglefx, 1, error) < 1 ||
|
|
||||||
psd_read (input, &ls_a->isdw.opacity, 1, error) < 1)
|
|
||||||
{
|
|
||||||
psd_set_error (error);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
ls_a->isdw.size = GUINT32_TO_BE (ls_a->isdw.size);
|
|
||||||
ls_a->isdw.ver = GUINT32_TO_BE (ls_a->isdw.ver);
|
|
||||||
ls_a->isdw.blur = FIXED_TO_FLOAT (GUINT16_TO_BE (temp[0]),
|
|
||||||
GUINT16_TO_BE (temp[1]));
|
|
||||||
ls_a->isdw.intensity = FIXED_TO_FLOAT (GUINT16_TO_BE (temp[2]),
|
|
||||||
GUINT16_TO_BE (temp[3]));
|
|
||||||
ls_a->isdw.angle = FIXED_TO_FLOAT (GUINT16_TO_BE (temp[4]),
|
|
||||||
GUINT16_TO_BE (temp[5]));
|
|
||||||
ls_a->isdw.distance = FIXED_TO_FLOAT (GUINT16_TO_BE (temp[6]),
|
|
||||||
GUINT16_TO_BE (temp[7]));
|
|
||||||
|
|
||||||
if (ls_a->isdw.ver == 2)
|
|
||||||
{
|
|
||||||
if (psd_read (input, &ls_a->isdw.natcolor[0], 2, error) < 2 ||
|
|
||||||
psd_read (input, &ls_a->isdw.natcolor[1], 2, error) < 2 ||
|
|
||||||
psd_read (input, &ls_a->isdw.natcolor[2], 2, error) < 2 ||
|
|
||||||
psd_read (input, &ls_a->isdw.natcolor[3], 2, error) < 2 ||
|
|
||||||
psd_read (input, &ls_a->isdw.natcolor[4], 2, error) < 2)
|
|
||||||
{
|
{
|
||||||
psd_set_error (error);
|
psd_set_error (error);
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -2796,6 +2796,62 @@ add_legacy_layer_effects (GimpLayer *layer,
|
||||||
g_object_unref (color);
|
g_object_unref (color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (lyr_a->layer_styles->isdw.effecton == 1)
|
||||||
|
{
|
||||||
|
PSDLayerStyleShadow isdw;
|
||||||
|
GimpLayerMode mode;
|
||||||
|
GimpDrawableFilter *filter;
|
||||||
|
GeglColor *color = gegl_color_new ("none");
|
||||||
|
gchar *filter_name;
|
||||||
|
gdouble x;
|
||||||
|
gdouble y;
|
||||||
|
gdouble blur;
|
||||||
|
gdouble radians;
|
||||||
|
|
||||||
|
isdw = lyr_a->layer_styles->isdw;
|
||||||
|
|
||||||
|
filter_name = g_strdup_printf ("%s (%s)", _("Inner Shadow"),
|
||||||
|
_("imported"));
|
||||||
|
|
||||||
|
radians = (M_PI / 180) * isdw.angle;
|
||||||
|
x = isdw.distance * cos (radians);
|
||||||
|
y = isdw.distance * sin (radians);
|
||||||
|
|
||||||
|
if (isdw.angle >= 0xFF00)
|
||||||
|
isdw.angle = (isdw.angle - 0xFF00) * -1;
|
||||||
|
|
||||||
|
if (isdw.angle > 90 && isdw.angle < 180)
|
||||||
|
y *= -1;
|
||||||
|
else if (isdw.angle < -90 && isdw.angle > -180)
|
||||||
|
x *= -1;
|
||||||
|
|
||||||
|
blur = (isdw.blur / 250.0) * 50.0;
|
||||||
|
|
||||||
|
if (isdw.ver == 0)
|
||||||
|
convert_legacy_psd_color (color, isdw.color, space, ibm_pc_format);
|
||||||
|
else if (isdw.ver == 2)
|
||||||
|
convert_legacy_psd_color (color, isdw.natcolor, space, ibm_pc_format);
|
||||||
|
|
||||||
|
convert_psd_mode (isdw.blendsig, &mode);
|
||||||
|
|
||||||
|
filter = gimp_drawable_append_new_filter (GIMP_DRAWABLE (layer),
|
||||||
|
"gegl:inner-glow",
|
||||||
|
filter_name,
|
||||||
|
mode,
|
||||||
|
1.0,
|
||||||
|
"x", x,
|
||||||
|
"y", y,
|
||||||
|
"grow-radius", 1.0,
|
||||||
|
"radius", blur,
|
||||||
|
"value", color,
|
||||||
|
"opacity", isdw.opacity / 255.0,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
g_free (filter_name);
|
||||||
|
g_object_unref (filter);
|
||||||
|
g_object_unref (color);
|
||||||
|
}
|
||||||
|
|
||||||
if (lyr_a->layer_styles->dsdw.effecton == 1)
|
if (lyr_a->layer_styles->dsdw.effecton == 1)
|
||||||
{
|
{
|
||||||
PSDLayerStyleShadow dsdw;
|
PSDLayerStyleShadow dsdw;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue