mirror of https://github.com/GNOME/gimp.git
libgimp: add GIMP_EXPORT_NEEDS_OPAQUE_LAYERS export capacity.
Currently capability GIMP_EXPORT_CAN_HANDLE_LAYERS implies GIMP_EXPORT_CAN_HANDLE_ALPHA. Though in many cases, multi-layer implies alpha for basic compositing, our export plug-ins sometimes use the concept of "layer export" for multi-pages or collection files. Additionally sometimes alpha may not even be supported at all whereas layers are. This will be the case in the next commit which will make use of this new capability.
This commit is contained in:
parent
cf8148df5e
commit
9933f46f85
|
@ -151,6 +151,25 @@ export_flatten (gint32 image_ID,
|
|||
*drawable_ID = flattened;
|
||||
}
|
||||
|
||||
static void
|
||||
export_remove_alpha (gint32 image_ID,
|
||||
gint32 *drawable_ID)
|
||||
{
|
||||
gint32 n_layers;
|
||||
gint32 *layers;
|
||||
gint i;
|
||||
|
||||
layers = gimp_image_get_layers (image_ID, &n_layers);
|
||||
|
||||
for (i = 0; i < n_layers; i++)
|
||||
{
|
||||
if (gimp_drawable_has_alpha (layers[i]))
|
||||
gimp_layer_flatten (layers[i]);
|
||||
}
|
||||
|
||||
g_free (layers);
|
||||
}
|
||||
|
||||
static void
|
||||
export_apply_masks (gint32 image_ID,
|
||||
gint *drawable_ID)
|
||||
|
@ -298,6 +317,15 @@ static ExportAction export_action_flatten =
|
|||
0
|
||||
};
|
||||
|
||||
static ExportAction export_action_remove_alpha =
|
||||
{
|
||||
export_remove_alpha,
|
||||
NULL,
|
||||
N_("%s plug-in can't handle transparent layers"),
|
||||
{ N_("Flatten Image"), NULL },
|
||||
0
|
||||
};
|
||||
|
||||
static ExportAction export_action_apply_masks =
|
||||
{
|
||||
export_apply_masks,
|
||||
|
@ -724,7 +752,8 @@ gimp_export_image (gint32 *image_ID,
|
|||
if (capabilities & GIMP_EXPORT_CAN_HANDLE_LAYER_MASKS)
|
||||
capabilities |= GIMP_EXPORT_CAN_HANDLE_LAYERS;
|
||||
|
||||
if (capabilities & GIMP_EXPORT_CAN_HANDLE_LAYERS)
|
||||
if (capabilities & GIMP_EXPORT_CAN_HANDLE_LAYERS &&
|
||||
! (capabilities & GIMP_EXPORT_NEEDS_OPAQUE_LAYERS))
|
||||
capabilities |= GIMP_EXPORT_CAN_HANDLE_ALPHA;
|
||||
|
||||
if (format_name && g_getenv ("GIMP_INTERACTIVE_EXPORT"))
|
||||
|
@ -768,9 +797,17 @@ gimp_export_image (gint32 *image_ID,
|
|||
{
|
||||
if (! (capabilities & GIMP_EXPORT_CAN_HANDLE_ALPHA))
|
||||
{
|
||||
actions = g_slist_prepend (actions, &export_action_flatten);
|
||||
added_flatten = TRUE;
|
||||
break;
|
||||
if (! (capabilities & GIMP_EXPORT_CAN_HANDLE_LAYERS))
|
||||
{
|
||||
actions = g_slist_prepend (actions, &export_action_flatten);
|
||||
added_flatten = TRUE;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
actions = g_slist_prepend (actions, &export_action_remove_alpha);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -41,7 +41,8 @@ typedef enum
|
|||
GIMP_EXPORT_CAN_HANDLE_LAYERS = 1 << 5,
|
||||
GIMP_EXPORT_CAN_HANDLE_LAYERS_AS_ANIMATION = 1 << 6,
|
||||
GIMP_EXPORT_CAN_HANDLE_LAYER_MASKS = 1 << 7,
|
||||
GIMP_EXPORT_NEEDS_ALPHA = 1 << 8
|
||||
GIMP_EXPORT_NEEDS_ALPHA = 1 << 8,
|
||||
GIMP_EXPORT_NEEDS_OPAQUE_LAYERS = 1 << 9
|
||||
} GimpExportCapabilities;
|
||||
|
||||
typedef enum
|
||||
|
|
Loading…
Reference in New Issue