Commit 393ce1d5 authored by Michael Natterer's avatar Michael Natterer 😴
Browse files

plug-ins: use the new composite mode API in file-psd

No clue if this is right.
parent 2a96d598
......@@ -1142,6 +1142,7 @@ add_layers (gint32 image_id,
GeglBuffer *buffer;
GimpImageType image_type;
GimpLayerMode layer_mode;
GimpLayerCompositeMode layer_composite;
IFDBG(2) g_debug ("Number of layers: %d", img_a->num_layers);
......@@ -1408,8 +1409,9 @@ add_layers (gint32 image_id,
IFDBG(2) g_debug ("End group layer id %d.", layer_id);
if (layer_id != -1)
{
layer_mode = psd_to_gimp_blend_mode (lyr_a[lidx]->blend_mode);
layer_mode = psd_to_gimp_blend_mode (lyr_a[lidx]->blend_mode, &layer_composite);
gimp_layer_set_mode (layer_id, layer_mode);
gimp_layer_set_composite_mode (layer_id, layer_composite);
gimp_layer_set_opacity (layer_id,
lyr_a[lidx]->opacity * 100 / 255);
gimp_item_set_name (layer_id, lyr_a[lidx]->name);
......@@ -1462,10 +1464,11 @@ add_layers (gint32 image_id,
g_free (lyr_chn[channel_idx[cidx]]->data);
}
layer_mode = psd_to_gimp_blend_mode (lyr_a[lidx]->blend_mode);
layer_mode = psd_to_gimp_blend_mode (lyr_a[lidx]->blend_mode, &layer_composite);
layer_id = gimp_layer_new (image_id, lyr_a[lidx]->name, l_w, l_h,
image_type, lyr_a[lidx]->opacity * 100 / 255,
layer_mode);
gimp_layer_set_composite_mode (layer_id, layer_composite);
IFDBG(3) g_debug ("Layer tattoo: %d", layer_id);
g_free (lyr_a[lidx]->name);
gimp_image_insert_layer (image_id, layer_id, parent_group_id, 0);
......
......@@ -606,16 +606,30 @@ encode_packbits (const gchar *src,
}
GimpLayerMode
psd_to_gimp_blend_mode (const gchar *psd_mode)
psd_to_gimp_blend_mode (const gchar *psd_mode,
GimpLayerCompositeMode *layer_composite)
{
/* FIXME: Do all photoshop modes use the union rule? We always return
* "union", effectively, only returning "auto" for modes that default to
* "union", to reduce UI clutter.
*/
if (layer_composite) *layer_composite = GIMP_LAYER_COMPOSITE_SRC_ATOP;
if (g_ascii_strncasecmp (psd_mode, "norm", 4) == 0) /* Normal (ps3) */
return GIMP_LAYER_MODE_NORMAL;
{
if (layer_composite) *layer_composite = GIMP_LAYER_COMPOSITE_AUTO;
return GIMP_LAYER_MODE_NORMAL;
}
if (g_ascii_strncasecmp (psd_mode, "dark", 4) == 0) /* Darken (ps3) */
return GIMP_LAYER_MODE_DARKEN_ONLY_LEGACY;
if (g_ascii_strncasecmp (psd_mode, "lite", 4) == 0) /* Lighten (ps3) */
return GIMP_LAYER_MODE_LIGHTEN_ONLY_LEGACY;
if (g_ascii_strncasecmp (psd_mode, "hue ", 4) == 0) /* Hue (ps3) */
return GIMP_LAYER_MODE_HSV_HUE_LEGACY;
if (g_ascii_strncasecmp (psd_mode, "sat ", 4) == 0) /* Saturation (ps3) */
{
if (CONVERSION_WARNINGS)
......@@ -627,8 +641,10 @@ psd_to_gimp_blend_mode (const gchar *psd_mode)
}
return GIMP_LAYER_MODE_HSV_SATURATION_LEGACY;
}
if (g_ascii_strncasecmp (psd_mode, "colr", 4) == 0) /* Color (ps3) */
return GIMP_LAYER_MODE_HSV_COLOR_LEGACY;
if (g_ascii_strncasecmp (psd_mode, "lum ", 4) == 0) /* Luminosity (ps3) */
{
if (CONVERSION_WARNINGS)
......@@ -640,18 +656,28 @@ psd_to_gimp_blend_mode (const gchar *psd_mode)
}
return GIMP_LAYER_MODE_HSV_VALUE_LEGACY;
}
if (g_ascii_strncasecmp (psd_mode, "mul ", 4) == 0) /* Multiply (ps3) */
return GIMP_LAYER_MODE_MULTIPLY_LEGACY;
if (g_ascii_strncasecmp (psd_mode, "lddg", 4) == 0) /* Linear Dodge (cs2) */
return GIMP_LAYER_MODE_ADDITION_LEGACY;
if (g_ascii_strncasecmp (psd_mode, "scrn", 4) == 0) /* Screen (ps3) */
return GIMP_LAYER_MODE_SCREEN_LEGACY;
if (g_ascii_strncasecmp (psd_mode, "diss", 4) == 0) /* Dissolve (ps3) */
return GIMP_LAYER_MODE_DISSOLVE;
{
if (layer_composite) *layer_composite = GIMP_LAYER_COMPOSITE_AUTO;
return GIMP_LAYER_MODE_DISSOLVE;
}
if (g_ascii_strncasecmp (psd_mode, "over", 4) == 0) /* Overlay (ps3) */
return GIMP_LAYER_MODE_OVERLAY;
if (g_ascii_strncasecmp (psd_mode, "hLit", 4) == 0) /* Hard light (ps3) */
return GIMP_LAYER_MODE_HARDLIGHT_LEGACY;
if (g_ascii_strncasecmp (psd_mode, "sLit", 4) == 0) /* Soft light (ps3) */
{
if (CONVERSION_WARNINGS)
......@@ -663,8 +689,10 @@ psd_to_gimp_blend_mode (const gchar *psd_mode)
}
return GIMP_LAYER_MODE_SOFTLIGHT_LEGACY;
}
if (g_ascii_strncasecmp (psd_mode, "diff", 4) == 0) /* Difference (ps3) */
return GIMP_LAYER_MODE_DIFFERENCE_LEGACY;
if (g_ascii_strncasecmp (psd_mode, "smud", 4) == 0) /* Exclusion (ps6) */
{
if (CONVERSION_WARNINGS)
......@@ -673,12 +701,16 @@ psd_to_gimp_blend_mode (const gchar *psd_mode)
g_message ("Unsupported blend mode: %s. Mode reverts to normal",
mode_name);
}
if (layer_composite) *layer_composite = GIMP_LAYER_COMPOSITE_AUTO;
return GIMP_LAYER_MODE_NORMAL;
}
if (g_ascii_strncasecmp (psd_mode, "div ", 4) == 0) /* Color dodge (ps6) */
return GIMP_LAYER_MODE_DODGE_LEGACY;
if (g_ascii_strncasecmp (psd_mode, "idiv", 4) == 0) /* Color burn (ps6) */
return GIMP_LAYER_MODE_BURN_LEGACY;
if (g_ascii_strncasecmp (psd_mode, "lbrn", 4) == 0) /* Linear burn (ps7)*/
{
if (CONVERSION_WARNINGS)
......@@ -687,10 +719,13 @@ psd_to_gimp_blend_mode (const gchar *psd_mode)
g_message ("Unsupported blend mode: %s. Mode reverts to normal",
mode_name);
}
if (layer_composite) *layer_composite = GIMP_LAYER_COMPOSITE_AUTO;
return GIMP_LAYER_MODE_NORMAL;
}
if (g_ascii_strncasecmp (psd_mode, "lddg", 4) == 0) /* Linear dodge (ps7)*/
return GIMP_LAYER_MODE_ADDITION_LEGACY;
if (g_ascii_strncasecmp (psd_mode, "lLit", 4) == 0) /* Linear light (ps7)*/
{
if (CONVERSION_WARNINGS)
......@@ -699,8 +734,10 @@ psd_to_gimp_blend_mode (const gchar *psd_mode)
g_message ("Unsupported blend mode: %s. Mode reverts to normal",
mode_name);
}
if (layer_composite) *layer_composite = GIMP_LAYER_COMPOSITE_AUTO;
return GIMP_LAYER_MODE_NORMAL;
}
if (g_ascii_strncasecmp (psd_mode, "pLit", 4) == 0) /* Pin light (ps7)*/
{
if (CONVERSION_WARNINGS)
......@@ -709,8 +746,10 @@ psd_to_gimp_blend_mode (const gchar *psd_mode)
g_message ("Unsupported blend mode: %s. Mode reverts to normal",
mode_name);
}
if (layer_composite) *layer_composite = GIMP_LAYER_COMPOSITE_AUTO;
return GIMP_LAYER_MODE_NORMAL;
}
if (g_ascii_strncasecmp (psd_mode, "vLit", 4) == 0) /* Vivid light (ps7)*/
{
if (CONVERSION_WARNINGS)
......@@ -719,8 +758,10 @@ psd_to_gimp_blend_mode (const gchar *psd_mode)
g_message ("Unsupported blend mode: %s. Mode reverts to normal",
mode_name);
}
if (layer_composite) *layer_composite = GIMP_LAYER_COMPOSITE_AUTO;
return GIMP_LAYER_MODE_NORMAL;
}
if (g_ascii_strncasecmp (psd_mode, "hMix", 4) == 0) /* Hard Mix (CS)*/
{
if (CONVERSION_WARNINGS)
......@@ -729,6 +770,7 @@ psd_to_gimp_blend_mode (const gchar *psd_mode)
g_message ("Unsupported blend mode: %s. Mode reverts to normal",
mode_name);
}
if (layer_composite) *layer_composite = GIMP_LAYER_COMPOSITE_AUTO;
return GIMP_LAYER_MODE_NORMAL;
}
......@@ -739,121 +781,156 @@ psd_to_gimp_blend_mode (const gchar *psd_mode)
mode_name);
g_free (mode_name);
}
if (layer_composite) *layer_composite = GIMP_LAYER_COMPOSITE_AUTO;
return GIMP_LAYER_MODE_NORMAL;
}
gchar *
gimp_to_psd_blend_mode (GimpLayerMode gimp_layer_mode)
gimp_to_psd_blend_mode (GimpLayerMode layer_mode,
GimpLayerCompositeMode layer_composite)
{
gchar *psd_mode;
switch (gimp_layer_mode)
if (((layer_mode == GIMP_LAYER_MODE_NORMAL ||
layer_mode == GIMP_LAYER_MODE_DISSOLVE) &&
(layer_composite != GIMP_LAYER_COMPOSITE_AUTO &&
layer_composite != GIMP_LAYER_COMPOSITE_SRC_OVER)) ||
layer_composite != GIMP_LAYER_COMPOSITE_SRC_OVER)
{
case GIMP_LAYER_MODE_NORMAL:
psd_mode = g_strndup ("norm", 4); /* Normal (ps3) */
break;
case GIMP_LAYER_MODE_DISSOLVE:
psd_mode = g_strndup ("diss", 4); /* Dissolve (ps3) */
break;
case GIMP_LAYER_MODE_BEHIND:
if (CONVERSION_WARNINGS)
g_message ("Unsupported blend mode: %s. Mode reverts to normal",
gimp_layer_mode_effects_name (gimp_layer_mode));
psd_mode = g_strndup ("norm", 4);
break;
case GIMP_LAYER_MODE_MULTIPLY_LEGACY:
psd_mode = g_strndup ("mul ", 4); /* Multiply (ps3) */
break;
case GIMP_LAYER_MODE_SCREEN_LEGACY:
psd_mode = g_strndup ("scrn", 4); /* Screen (ps3) */
break;
case GIMP_LAYER_MODE_OVERLAY:
psd_mode = g_strndup ("over", 4); /* Overlay (ps3) */
break;
case GIMP_LAYER_MODE_DIFFERENCE_LEGACY:
psd_mode = g_strndup ("diff", 4); /* Difference (ps3) */
break;
case GIMP_LAYER_MODE_ADDITION_LEGACY:
psd_mode = g_strndup ("lddg", 4); /* Linear dodge (ps7)*/
break;
case GIMP_LAYER_MODE_SUBTRACT_LEGACY:
if (CONVERSION_WARNINGS)
g_message ("Unsupported blend mode: %s. Mode reverts to normal",
gimp_layer_mode_effects_name (gimp_layer_mode));
psd_mode = g_strndup ("norm", 4);
break;
case GIMP_LAYER_MODE_DARKEN_ONLY_LEGACY:
psd_mode = g_strndup ("dark", 4); /* Darken (ps3) */
break;
case GIMP_LAYER_MODE_LIGHTEN_ONLY_LEGACY:
psd_mode = g_strndup ("lite", 4); /* Lighten (ps3) */
break;
case GIMP_LAYER_MODE_HSV_HUE_LEGACY:
psd_mode = g_strndup ("hue ", 4); /* Hue (ps3) */
break;
case GIMP_LAYER_MODE_HSV_SATURATION_LEGACY:
if (CONVERSION_WARNINGS)
g_message ("Gimp uses a different equation to photoshop for "
"blend mode: %s. Results will differ.",
gimp_layer_mode_effects_name (gimp_layer_mode));
psd_mode = g_strndup ("sat ", 4); /* Saturation (ps3) */
break;
case GIMP_LAYER_MODE_HSV_COLOR_LEGACY:
psd_mode = g_strndup ("colr", 4); /* Color (ps3) */
break;
case GIMP_LAYER_MODE_HSV_VALUE_LEGACY:
if (CONVERSION_WARNINGS)
g_message ("Gimp uses a different equation to photoshop for "
"blend mode: %s. Results will differ.",
gimp_layer_mode_effects_name (gimp_layer_mode));
psd_mode = g_strndup ("lum ", 4); /* Luminosity (ps3) */
break;
case GIMP_LAYER_MODE_DIVIDE_LEGACY:
if (CONVERSION_WARNINGS)
g_message ("Unsupported blend mode: %s. Mode reverts to normal",
gimp_layer_mode_effects_name (gimp_layer_mode));
psd_mode = g_strndup ("norm", 4);
break;
case GIMP_LAYER_MODE_DODGE_LEGACY:
psd_mode = g_strndup ("div ", 4); /* Color Dodge (ps6) */
break;
case GIMP_LAYER_MODE_BURN_LEGACY:
psd_mode = g_strndup ("idiv", 4); /* Color Burn (ps6) */
break;
case GIMP_LAYER_MODE_HARDLIGHT_LEGACY:
psd_mode = g_strndup ("hLit", 4); /* Hard Light (ps3) */
break;
case GIMP_LAYER_MODE_OVERLAY_LEGACY:
case GIMP_LAYER_MODE_SOFTLIGHT_LEGACY:
if (CONVERSION_WARNINGS)
g_message ("Unsupported blend mode: %s. Mode reverts to normal",
gimp_layer_mode_effects_name (gimp_layer_mode));
psd_mode = g_strndup ("sLit", 4); /* Soft Light (ps3) */
break;
case GIMP_LAYER_MODE_GRAIN_EXTRACT_LEGACY:
if (CONVERSION_WARNINGS)
g_message ("Unsupported blend mode: %s. Mode reverts to normal",
gimp_layer_mode_effects_name (gimp_layer_mode));
psd_mode = g_strndup ("norm", 4);
break;
case GIMP_LAYER_MODE_GRAIN_MERGE_LEGACY:
if (CONVERSION_WARNINGS)
g_message ("Unsupported blend mode: %s. Mode reverts to normal",
gimp_layer_mode_effects_name (gimp_layer_mode));
psd_mode = g_strndup ("norm", 4);
break;
case GIMP_LAYER_MODE_COLOR_ERASE:
if (CONVERSION_WARNINGS)
g_message ("Unsupported blend mode: %s. Mode reverts to normal",
gimp_layer_mode_effects_name (gimp_layer_mode));
psd_mode = g_strndup ("norm", 4);
break;
/* FIXME, and above if() */
}
default:
if (CONVERSION_WARNINGS)
g_message ("Unsupported blend mode: %s. Mode reverts to normal",
gimp_layer_mode_effects_name (gimp_layer_mode));
psd_mode = g_strndup ("norm", 4);
switch (layer_mode)
{
case GIMP_LAYER_MODE_NORMAL:
psd_mode = g_strndup ("norm", 4); /* Normal (ps3) */
break;
case GIMP_LAYER_MODE_DISSOLVE:
psd_mode = g_strndup ("diss", 4); /* Dissolve (ps3) */
break;
case GIMP_LAYER_MODE_BEHIND:
if (CONVERSION_WARNINGS)
g_message ("Unsupported blend mode: %s. Mode reverts to normal",
gimp_layer_mode_effects_name (layer_mode));
psd_mode = g_strndup ("norm", 4);
break;
case GIMP_LAYER_MODE_MULTIPLY_LEGACY:
psd_mode = g_strndup ("mul ", 4); /* Multiply (ps3) */
break;
case GIMP_LAYER_MODE_SCREEN_LEGACY:
psd_mode = g_strndup ("scrn", 4); /* Screen (ps3) */
break;
case GIMP_LAYER_MODE_OVERLAY:
psd_mode = g_strndup ("over", 4); /* Overlay (ps3) */
break;
case GIMP_LAYER_MODE_DIFFERENCE_LEGACY:
psd_mode = g_strndup ("diff", 4); /* Difference (ps3) */
break;
case GIMP_LAYER_MODE_ADDITION_LEGACY:
psd_mode = g_strndup ("lddg", 4); /* Linear dodge (ps7)*/
break;
case GIMP_LAYER_MODE_SUBTRACT_LEGACY:
if (CONVERSION_WARNINGS)
g_message ("Unsupported blend mode: %s. Mode reverts to normal",
gimp_layer_mode_effects_name (layer_mode));
psd_mode = g_strndup ("norm", 4);
break;
case GIMP_LAYER_MODE_DARKEN_ONLY_LEGACY:
psd_mode = g_strndup ("dark", 4); /* Darken (ps3) */
break;
case GIMP_LAYER_MODE_LIGHTEN_ONLY_LEGACY:
psd_mode = g_strndup ("lite", 4); /* Lighten (ps3) */
break;
case GIMP_LAYER_MODE_HSV_HUE_LEGACY:
psd_mode = g_strndup ("hue ", 4); /* Hue (ps3) */
break;
case GIMP_LAYER_MODE_HSV_SATURATION_LEGACY:
if (CONVERSION_WARNINGS)
g_message ("Gimp uses a different equation to photoshop for "
"blend mode: %s. Results will differ.",
gimp_layer_mode_effects_name (layer_mode));
psd_mode = g_strndup ("sat ", 4); /* Saturation (ps3) */
break;
case GIMP_LAYER_MODE_HSV_COLOR_LEGACY:
psd_mode = g_strndup ("colr", 4); /* Color (ps3) */
break;
case GIMP_LAYER_MODE_HSV_VALUE_LEGACY:
if (CONVERSION_WARNINGS)
g_message ("Gimp uses a different equation to photoshop for "
"blend mode: %s. Results will differ.",
gimp_layer_mode_effects_name (layer_mode));
psd_mode = g_strndup ("lum ", 4); /* Luminosity (ps3) */
break;
case GIMP_LAYER_MODE_DIVIDE_LEGACY:
if (CONVERSION_WARNINGS)
g_message ("Unsupported blend mode: %s. Mode reverts to normal",
gimp_layer_mode_effects_name (layer_mode));
psd_mode = g_strndup ("norm", 4);
break;
case GIMP_LAYER_MODE_DODGE_LEGACY:
psd_mode = g_strndup ("div ", 4); /* Color Dodge (ps6) */
break;
case GIMP_LAYER_MODE_BURN_LEGACY:
psd_mode = g_strndup ("idiv", 4); /* Color Burn (ps6) */
break;
case GIMP_LAYER_MODE_HARDLIGHT_LEGACY:
psd_mode = g_strndup ("hLit", 4); /* Hard Light (ps3) */
break;
case GIMP_LAYER_MODE_OVERLAY_LEGACY:
case GIMP_LAYER_MODE_SOFTLIGHT_LEGACY:
if (CONVERSION_WARNINGS)
g_message ("Unsupported blend mode: %s. Mode reverts to normal",
gimp_layer_mode_effects_name (layer_mode));
psd_mode = g_strndup ("sLit", 4); /* Soft Light (ps3) */
break;
case GIMP_LAYER_MODE_GRAIN_EXTRACT_LEGACY:
if (CONVERSION_WARNINGS)
g_message ("Unsupported blend mode: %s. Mode reverts to normal",
gimp_layer_mode_effects_name (layer_mode));
psd_mode = g_strndup ("norm", 4);
break;
case GIMP_LAYER_MODE_GRAIN_MERGE_LEGACY:
if (CONVERSION_WARNINGS)
g_message ("Unsupported blend mode: %s. Mode reverts to normal",
gimp_layer_mode_effects_name (layer_mode));
psd_mode = g_strndup ("norm", 4);
break;
case GIMP_LAYER_MODE_COLOR_ERASE:
if (CONVERSION_WARNINGS)
g_message ("Unsupported blend mode: %s. Mode reverts to normal",
gimp_layer_mode_effects_name (layer_mode));
psd_mode = g_strndup ("norm", 4);
break;
default:
if (CONVERSION_WARNINGS)
g_message ("Unsupported blend mode: %s. Mode reverts to normal",
gimp_layer_mode_effects_name (layer_mode));
psd_mode = g_strndup ("norm", 4);
}
return psd_mode;
......
......@@ -75,8 +75,10 @@ gchar * encode_packbits (const gchar *src,
guint32 unpacked_len,
guint16 *packed_len);
GimpLayerMode psd_to_gimp_blend_mode (const gchar *psd_mode);
GimpLayerMode psd_to_gimp_blend_mode (const gchar *psd_mode,
GimpLayerCompositeMode *layer_composite);
gchar * gimp_to_psd_blend_mode (GimpLayerMode gimp_layer_mode);
gchar * gimp_to_psd_blend_mode (GimpLayerMode layer_mode,
GimpLayerCompositeMode layer_composite);
#endif /* __PSD_UTIL_H__ */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment