plug-ins: Import legacy PSD Outer Glow
This patch adds support for loading and applying active legacy Outer Glow layer styles in PSD images. It uses gegl:dropshadow with certain preset values to replicate the Photoshop filter.
This commit is contained in:
parent
046c8f2745
commit
993d8b7e4f
2 changed files with 60 additions and 16 deletions
|
|
@ -802,18 +802,18 @@ load_resource_lrfx (const PSDlayerres *res_a,
|
|||
else
|
||||
shadow = &ls_a->isdw;
|
||||
|
||||
if (psd_read (input, &shadow->size, 4, error) < 4 ||
|
||||
psd_read (input, &shadow->ver, 4, error) < 4 ||
|
||||
psd_read (input, &temp, 16, error) < 2 ||
|
||||
psd_read (input, &shadow->color[0], 2, error) < 2 ||
|
||||
psd_read (input, &shadow->color[1], 2, error) < 2 ||
|
||||
psd_read (input, &shadow->color[2], 2, error) < 2 ||
|
||||
psd_read (input, &shadow->color[3], 2, error) < 2 ||
|
||||
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 ||
|
||||
if (psd_read (input, &shadow->size, 4, error) < 4 ||
|
||||
psd_read (input, &shadow->ver, 4, error) < 4 ||
|
||||
psd_read (input, &temp, 16, error) < 16 ||
|
||||
psd_read (input, &shadow->color[0], 2, error) < 2 ||
|
||||
psd_read (input, &shadow->color[1], 2, error) < 2 ||
|
||||
psd_read (input, &shadow->color[2], 2, error) < 2 ||
|
||||
psd_read (input, &shadow->color[3], 2, error) < 2 ||
|
||||
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);
|
||||
|
|
@ -845,18 +845,19 @@ load_resource_lrfx (const PSDlayerres *res_a,
|
|||
}
|
||||
else if (memcmp (effectname, "oglw", 4) == 0)
|
||||
{
|
||||
gchar bim[4];
|
||||
guint16 temp[4];
|
||||
|
||||
if (psd_read (input, &ls_a->oglw.size, 4, error) < 4 ||
|
||||
psd_read (input, &ls_a->oglw.ver, 4, error) < 4 ||
|
||||
psd_read (input, &ls_a->oglw.blur, 4, error) < 4 ||
|
||||
psd_read (input, &ls_a->oglw.intensity, 4, error) < 4 ||
|
||||
psd_read (input, &temp, 8, error) < 8 ||
|
||||
psd_read (input, &ls_a->oglw.color[0], 2, error) < 2 ||
|
||||
psd_read (input, &ls_a->oglw.color[1], 2, error) < 2 ||
|
||||
psd_read (input, &ls_a->oglw.color[2], 2, error) < 2 ||
|
||||
psd_read (input, &ls_a->oglw.color[3], 2, error) < 2 ||
|
||||
psd_read (input, &ls_a->oglw.color[4], 2, error) < 2 ||
|
||||
psd_read (input, &bim, 4, error) < 4 ||
|
||||
psd_read (input, &ls_a->oglw.blendsig, 4, error) < 4 ||
|
||||
psd_read (input, &ls_a->oglw.effect, 4, error) < 4 ||
|
||||
psd_read (input, &ls_a->oglw.effecton, 1, error) < 1 ||
|
||||
psd_read (input, &ls_a->oglw.opacity, 1, error) < 1)
|
||||
{
|
||||
|
|
@ -864,7 +865,13 @@ load_resource_lrfx (const PSDlayerres *res_a,
|
|||
return -1;
|
||||
}
|
||||
|
||||
ls_a->oglw.size = GUINT32_TO_BE (ls_a->oglw.size);
|
||||
ls_a->oglw.size = GUINT32_TO_BE (ls_a->oglw.size);
|
||||
ls_a->oglw.ver = GUINT32_TO_BE (ls_a->oglw.ver);
|
||||
ls_a->oglw.blur = FIXED_TO_FLOAT (GUINT16_TO_BE (temp[0]),
|
||||
GUINT16_TO_BE (temp[1]));
|
||||
ls_a->oglw.intensity = FIXED_TO_FLOAT (GUINT16_TO_BE (temp[2]),
|
||||
GUINT16_TO_BE (temp[3]));
|
||||
|
||||
if (ls_a->oglw.size == 42)
|
||||
{
|
||||
if (psd_read (input, &ls_a->oglw.natcolor[0], 2, error) < 2 ||
|
||||
|
|
|
|||
|
|
@ -2796,6 +2796,43 @@ add_legacy_layer_effects (GimpLayer *layer,
|
|||
g_object_unref (color);
|
||||
}
|
||||
|
||||
if (lyr_a->layer_styles->oglw.effecton == 1)
|
||||
{
|
||||
PSDLayerStyleGlow oglw;
|
||||
GimpLayerMode mode;
|
||||
GimpDrawableFilter *filter;
|
||||
GeglColor *color = gegl_color_new ("none");
|
||||
gdouble blur;
|
||||
|
||||
oglw = lyr_a->layer_styles->oglw;
|
||||
|
||||
blur = (oglw.blur / 250.0) * 100.0;
|
||||
|
||||
if (oglw.ver == 0)
|
||||
convert_legacy_psd_color (color, oglw.color, space, ibm_pc_format);
|
||||
else if (oglw.ver == 2)
|
||||
convert_legacy_psd_color (color, oglw.natcolor, space, ibm_pc_format);
|
||||
|
||||
convert_psd_mode (oglw.blendsig, &mode);
|
||||
|
||||
filter = gimp_drawable_append_new_filter (GIMP_DRAWABLE (layer),
|
||||
"gegl:dropshadow",
|
||||
/* TODO: Translate after string freeze */
|
||||
"Outer Glow (imported)",
|
||||
GIMP_LAYER_MODE_REPLACE,
|
||||
1.0,
|
||||
"x", 0,
|
||||
"y", 0,
|
||||
"radius", blur,
|
||||
"grow-radius", blur,
|
||||
"color", color,
|
||||
"opacity", oglw.opacity / 255.0,
|
||||
NULL);
|
||||
|
||||
g_object_unref (filter);
|
||||
g_object_unref (color);
|
||||
}
|
||||
|
||||
if (lyr_a->layer_styles->isdw.effecton == 1)
|
||||
{
|
||||
PSDLayerStyleShadow isdw;
|
||||
|
|
|
|||
Loading…
Reference in a new issue