Commit 4c6d9ddd authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

new function.

2005-08-07  Michael Natterer  <mitch@gimp.org>

	* app/core/gimplayer.[ch] (gimp_layer_flatten): new function.

	* app/actions/layers-actions.c
	* app/actions/layers-commands.[ch]
	* app/widgets/gimphelp-ids.h
	* menus/image-menu.xml.in
	* menus/layers-menu.xml: added "Remove Alpha Channel" action,
	action callback, help ID and menu items. Fixes bug #309762.
parent 37307dcb
2005-08-07 Michael Natterer <mitch@gimp.org>
* app/core/gimplayer.[ch] (gimp_layer_flatten): new function.
* app/actions/layers-actions.c
* app/actions/layers-commands.[ch]
* app/widgets/gimphelp-ids.h
* menus/image-menu.xml.in
* menus/layers-menu.xml: added "Remove Alpha Channel" action,
action callback, help ID and menu items. Fixes bug #309762.
2005-08-07 Sven Neumann <sven@gimp.org>
* app/base/siox.c (siox_foreground_extract): micro optimizations.
......@@ -12,7 +23,6 @@
* app/tools/gimpforegroundselecttool.c
(gimp_foreground_select_tool_draw): show the extents of the working
area if the user moves the mouse out of it. Is this useful?
* app/tools/gimpforegroundselectoptions.c: removed colons from labels.
......
......@@ -172,7 +172,12 @@ static GimpActionEntry layers_actions[] =
{ "layers-alpha-add", GIMP_STOCK_TRANSPARENCY,
N_("Add Alpha C_hannel"), NULL, NULL,
G_CALLBACK (layers_alpha_add_cmd_callback),
GIMP_HELP_LAYER_ALPHA_ADD }
GIMP_HELP_LAYER_ALPHA_ADD },
{ "layers-alpha-remove", NULL,
N_("_Remove Alpha Channel"), NULL, NULL,
G_CALLBACK (layers_alpha_remove_cmd_callback),
GIMP_HELP_LAYER_ALPHA_REMOVE }
};
static GimpToggleActionEntry layers_toggle_actions[] =
......@@ -464,6 +469,7 @@ layers_actions_update (GimpActionGroup *group,
SET_SENSITIVE ("layers-crop", layer && sel);
SET_SENSITIVE ("layers-alpha-add", layer && !fs && !alpha);
SET_SENSITIVE ("layers-alpha-remove", layer && !fs && alpha);
SET_SENSITIVE ("layers-lock-alpha", layer);
SET_ACTIVE ("layers-lock-alpha", lock_alpha);
......
......@@ -705,6 +705,21 @@ layers_alpha_add_cmd_callback (GtkAction *action,
}
}
void
layers_alpha_remove_cmd_callback (GtkAction *action,
gpointer data)
{
GimpImage *gimage;
GimpLayer *layer;
return_if_no_layer (gimage, layer, data);
if (gimp_drawable_has_alpha (GIMP_DRAWABLE (layer)))
{
gimp_layer_flatten (layer, action_data_get_context (data));
gimp_image_flush (gimage);
}
}
void
layers_alpha_to_selection_cmd_callback (GtkAction *action,
gint value,
......
......@@ -79,6 +79,8 @@ void layers_mask_to_selection_cmd_callback (GtkAction *action,
void layers_alpha_add_cmd_callback (GtkAction *action,
gpointer data);
void layers_alpha_remove_cmd_callback (GtkAction *action,
gpointer data);
void layers_alpha_to_selection_cmd_callback (GtkAction *action,
gint value,
gpointer data);
......
......@@ -1651,6 +1651,57 @@ gimp_layer_add_alpha (GimpLayer *layer)
tile_manager_unref (new_tiles);
}
void
gimp_layer_flatten (GimpLayer *layer,
GimpContext *context)
{
PixelRegion srcPR, destPR;
TileManager *new_tiles;
GimpImageType new_type;
guchar bg[4];
g_return_if_fail (GIMP_IS_LAYER (layer));
g_return_if_fail (GIMP_IS_CONTEXT (context));
if (! gimp_drawable_has_alpha (GIMP_DRAWABLE (layer)))
return;
new_type = gimp_drawable_type_without_alpha (GIMP_DRAWABLE (layer));
gimp_image_get_background (gimp_item_get_image (GIMP_ITEM (layer)),
GIMP_DRAWABLE (layer),
context, bg);
/* Allocate the new tiles */
new_tiles = tile_manager_new (GIMP_ITEM (layer)->width,
GIMP_ITEM (layer)->height,
GIMP_IMAGE_TYPE_BYTES (new_type));
/* Configure the pixel regions */
pixel_region_init (&srcPR, GIMP_DRAWABLE (layer)->tiles,
0, 0,
GIMP_ITEM (layer)->width,
GIMP_ITEM (layer)->height,
FALSE);
pixel_region_init (&destPR, new_tiles,
0, 0,
GIMP_ITEM (layer)->width,
GIMP_ITEM (layer)->height,
TRUE);
/* Remove alpha channel */
flatten_region (&srcPR, &destPR, bg);
/* Set the new tiles */
gimp_drawable_set_tiles_full (GIMP_DRAWABLE (layer),
gimp_item_is_attached (GIMP_ITEM (layer)),
_("Remove Alpha Channel"),
new_tiles, new_type,
GIMP_ITEM (layer)->offset_x,
GIMP_ITEM (layer)->offset_y);
tile_manager_unref (new_tiles);
}
void
gimp_layer_resize_to_image (GimpLayer *layer,
GimpContext *context)
......
......@@ -107,6 +107,8 @@ void gimp_layer_apply_mask (GimpLayer *layer,
GimpMaskApplyMode mode,
gboolean push_undo);
void gimp_layer_add_alpha (GimpLayer *layer);
void gimp_layer_flatten (GimpLayer *layer,
GimpContext *context);
void gimp_layer_resize_to_image (GimpLayer *layer,
GimpContext *context);
......
......@@ -164,6 +164,7 @@
#define GIMP_HELP_LAYER_MASK_SELECTION_SUBTRACT "gimp-layer-mask-selection-subtract"
#define GIMP_HELP_LAYER_MASK_SELECTION_INTERSECT "gimp-layer-mask-selection-intersect"
#define GIMP_HELP_LAYER_ALPHA_ADD "gimp-layer-alpha-add"
#define GIMP_HELP_LAYER_ALPHA_REMOVE "gimp-layer-alpha-remove"
#define GIMP_HELP_LAYER_ALPHA_SELECTION_REPLACE "gimp-layer-alpha-selection-replace"
#define GIMP_HELP_LAYER_ALPHA_SELECTION_ADD "gimp-layer-alpha-selection-add"
#define GIMP_HELP_LAYER_ALPHA_SELECTION_SUBTRACT "gimp-layer-alpha-selection-subtract"
......
......@@ -386,6 +386,7 @@
<menu action="layers-transparency-menu" name="Transparency">
<placeholder name="Modify">
<menuitem action="layers-alpha-add" />
<menuitem action="layers-alpha-remove" />
</placeholder>
<separator />
<placeholder name="Selection">
......
......@@ -33,6 +33,7 @@
<menuitem action="layers-mask-selection-replace" />
<separator />
<menuitem action="layers-alpha-add" />
<menuitem action="layers-alpha-remove" />
<menuitem action="layers-alpha-selection-replace" />
<separator />
<menuitem action="layers-merge-layers" />
......
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