Commit 95235369 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

Forgot some gint opacity values:

2002-03-04  Michael Natterer  <mitch@gimp.org>

	Forgot some gint opacity values:

	* app/core/gimplayer.[ch]: layer->opacity, gimp_layer_new(),
	gimp_layer_new_from_tiles()

	* app/core/gimpimage-projection.[ch]: gimp_image_projection_opacity()

	* app/core/gimpdrawable-transform.c
	* app/core/gimpedit.c
	* app/core/gimpimage-mask.c
	* app/core/gimpimage-merge.c
	* app/core/gimpimage-new.c
	* app/core/gimpimage.c
	* app/core/gimplayer-floating-sel.c
	* app/gui/layers-commands.c
	* app/tools/gimptexttool.c
	* app/widgets/gimplayerlistview.c
	* app/xcf/xcf-load.c
	* app/xcf/xcf-save.c
	* tools/pdbgen/pdb/layer.pdb: changed accordingly.

	* app/pdb/layer_cmds.c
	* libgimp/gimplayer_pdb.c: regenerated.
parent ddc01ea9
2002-03-04 Michael Natterer <mitch@gimp.org>
Forgot some gint opacity values:
* app/core/gimplayer.[ch]: layer->opacity, gimp_layer_new(),
gimp_layer_new_from_tiles()
* app/core/gimpimage-projection.[ch]: gimp_image_projection_opacity()
* app/core/gimpdrawable-transform.c
* app/core/gimpedit.c
* app/core/gimpimage-mask.c
* app/core/gimpimage-merge.c
* app/core/gimpimage-new.c
* app/core/gimpimage.c
* app/core/gimplayer-floating-sel.c
* app/gui/layers-commands.c
* app/tools/gimptexttool.c
* app/widgets/gimplayerlistview.c
* app/xcf/xcf-load.c
* app/xcf/xcf-save.c
* tools/pdbgen/pdb/layer.pdb: changed accordingly.
* app/pdb/layer_cmds.c
* libgimp/gimplayer_pdb.c: regenerated.
2002-03-03 Sven Neumann <sven@gimp.org> 2002-03-03 Sven Neumann <sven@gimp.org>
* app/core/gimpimage-contiguous-region.c: some cleanup, removed * app/core/gimpimage-contiguous-region.c: some cleanup, removed
unused parameters and code. unused parameters and code.
* app/widgets/gimptoolinfopreview.c: fixed stupid bug I introduced * app/widgets/gimptoolinfopreview.c: fixed stupid bug I introduced
yesterday. yesterday.
......
...@@ -430,9 +430,12 @@ new_layer_query_ok_callback (GtkWidget *widget, ...@@ -430,9 +430,12 @@ new_layer_query_ok_callback (GtkWidget *widget,
if ((gimage = options->gimage)) if ((gimage = options->gimage))
{ {
layer = gimp_layer_new (gimage, options->xsize, options->ysize, layer = gimp_layer_new (gimage,
options->xsize,
options->ysize,
gimp_image_base_type_with_alpha (gimage), gimp_image_base_type_with_alpha (gimage),
layer_name, OPAQUE_OPACITY, GIMP_NORMAL_MODE); layer_name,
GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE);
if (layer) if (layer)
{ {
gimp_drawable_fill_by_type (GIMP_DRAWABLE (layer), gimp_drawable_fill_by_type (GIMP_DRAWABLE (layer),
...@@ -491,7 +494,9 @@ layers_new_layer_query (GimpImage *gimage, ...@@ -491,7 +494,9 @@ layers_new_layer_query (GimpImage *gimage,
undo_push_group_start (gimage, EDIT_PASTE_UNDO_GROUP); undo_push_group_start (gimage, EDIT_PASTE_UNDO_GROUP);
new_layer = gimp_layer_new (gimage, width, height, new_layer = gimp_layer_new (gimage,
width,
height,
gimp_image_base_type_with_alpha (gimage), gimp_image_base_type_with_alpha (gimage),
_("Empty Layer Copy"), _("Empty Layer Copy"),
template->opacity, template->opacity,
......
...@@ -176,12 +176,12 @@ gimp_edit_paste (GimpImage *gimage, ...@@ -176,12 +176,12 @@ gimp_edit_paste (GimpImage *gimage,
layer = gimp_layer_new_from_tiles (paste->tiles, layer = gimp_layer_new_from_tiles (paste->tiles,
gimage, gimage,
_("Pasted Layer"), _("Pasted Layer"),
OPAQUE_OPACITY, GIMP_NORMAL_MODE); GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE);
else else
layer = gimp_layer_new_from_tiles (paste->tiles, layer = gimp_layer_new_from_tiles (paste->tiles,
gimage, gimage,
_("Pasted Layer"), _("Pasted Layer"),
OPAQUE_OPACITY, GIMP_NORMAL_MODE); GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE);
if (! layer) if (! layer)
return NULL; return NULL;
...@@ -256,7 +256,7 @@ gimp_edit_paste_as_new (Gimp *gimp, ...@@ -256,7 +256,7 @@ gimp_edit_paste_as_new (Gimp *gimp,
layer = gimp_layer_new_from_tiles (paste->tiles, layer = gimp_layer_new_from_tiles (paste->tiles,
gimage, gimage,
_("Pasted Layer"), _("Pasted Layer"),
OPAQUE_OPACITY, GIMP_NORMAL_MODE); GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE);
if (layer) if (layer)
{ {
......
...@@ -748,7 +748,7 @@ gimp_drawable_transform_paste (GimpDrawable *drawable, ...@@ -748,7 +748,7 @@ gimp_drawable_transform_paste (GimpDrawable *drawable,
gimp_layer_new_from_tiles (tiles, gimp_layer_new_from_tiles (tiles,
gimage, gimage,
_("Transformation"), _("Transformation"),
OPAQUE_OPACITY, GIMP_NORMAL_MODE); GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE);
if (! layer) if (! layer)
{ {
g_warning ("%s: gimp_layer_new_frome_tiles() failed", g_warning ("%s: gimp_layer_new_frome_tiles() failed",
......
...@@ -748,7 +748,7 @@ gimp_drawable_transform_paste (GimpDrawable *drawable, ...@@ -748,7 +748,7 @@ gimp_drawable_transform_paste (GimpDrawable *drawable,
gimp_layer_new_from_tiles (tiles, gimp_layer_new_from_tiles (tiles,
gimage, gimage,
_("Transformation"), _("Transformation"),
OPAQUE_OPACITY, GIMP_NORMAL_MODE); GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE);
if (! layer) if (! layer)
{ {
g_warning ("%s: gimp_layer_new_frome_tiles() failed", g_warning ("%s: gimp_layer_new_frome_tiles() failed",
......
...@@ -176,12 +176,12 @@ gimp_edit_paste (GimpImage *gimage, ...@@ -176,12 +176,12 @@ gimp_edit_paste (GimpImage *gimage,
layer = gimp_layer_new_from_tiles (paste->tiles, layer = gimp_layer_new_from_tiles (paste->tiles,
gimage, gimage,
_("Pasted Layer"), _("Pasted Layer"),
OPAQUE_OPACITY, GIMP_NORMAL_MODE); GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE);
else else
layer = gimp_layer_new_from_tiles (paste->tiles, layer = gimp_layer_new_from_tiles (paste->tiles,
gimage, gimage,
_("Pasted Layer"), _("Pasted Layer"),
OPAQUE_OPACITY, GIMP_NORMAL_MODE); GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE);
if (! layer) if (! layer)
return NULL; return NULL;
...@@ -256,7 +256,7 @@ gimp_edit_paste_as_new (Gimp *gimp, ...@@ -256,7 +256,7 @@ gimp_edit_paste_as_new (Gimp *gimp,
layer = gimp_layer_new_from_tiles (paste->tiles, layer = gimp_layer_new_from_tiles (paste->tiles,
gimage, gimage,
_("Pasted Layer"), _("Pasted Layer"),
OPAQUE_OPACITY, GIMP_NORMAL_MODE); GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE);
if (layer) if (layer)
{ {
......
...@@ -395,7 +395,7 @@ gimp_image_mask_float (GimpImage *gimage, ...@@ -395,7 +395,7 @@ gimp_image_mask_float (GimpImage *gimage,
layer = gimp_layer_new_from_tiles (tiles, layer = gimp_layer_new_from_tiles (tiles,
gimage, gimage,
_("Floating Selection"), _("Floating Selection"),
OPAQUE_OPACITY, GIMP_NORMAL_MODE); GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE);
/* Set the offsets */ /* Set the offsets */
tile_manager_get_offsets (tiles, &x1, &y1); tile_manager_get_offsets (tiles, &x1, &y1);
......
...@@ -310,7 +310,7 @@ gimp_image_merge_layers (GimpImage *gimage, ...@@ -310,7 +310,7 @@ gimp_image_merge_layers (GimpImage *gimage,
merge_layer = gimp_layer_new (gimage, (x2 - x1), (y2 - y1), merge_layer = gimp_layer_new (gimage, (x2 - x1), (y2 - y1),
type, type,
gimp_object_get_name (GIMP_OBJECT (layer)), gimp_object_get_name (GIMP_OBJECT (layer)),
OPAQUE_OPACITY, GIMP_NORMAL_MODE); GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE);
if (!merge_layer) if (!merge_layer)
{ {
g_warning ("%s: could not allocate merge layer.", g_warning ("%s: could not allocate merge layer.",
...@@ -348,7 +348,7 @@ gimp_image_merge_layers (GimpImage *gimage, ...@@ -348,7 +348,7 @@ gimp_image_merge_layers (GimpImage *gimage,
gimp_layer_new (gimage, (x2 - x1), (y2 - y1), gimp_layer_new (gimage, (x2 - x1), (y2 - y1),
gimp_drawable_type_with_alpha (GIMP_DRAWABLE (layer)), gimp_drawable_type_with_alpha (GIMP_DRAWABLE (layer)),
"merged layer", "merged layer",
OPAQUE_OPACITY, GIMP_NORMAL_MODE); GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE);
if (!merge_layer) if (!merge_layer)
{ {
...@@ -449,7 +449,10 @@ gimp_image_merge_layers (GimpImage *gimage, ...@@ -449,7 +449,10 @@ gimp_image_merge_layers (GimpImage *gimage,
} }
combine_regions (&src1PR, &src2PR, &src1PR, mask, NULL, combine_regions (&src1PR, &src2PR, &src1PR, mask, NULL,
layer->opacity, layer->mode, active, operation); layer->opacity * 255.999,
layer->mode,
active,
operation);
gimp_image_remove_layer (gimage, layer); gimp_image_remove_layer (gimage, layer);
reverse_list = g_slist_next (reverse_list); reverse_list = g_slist_next (reverse_list);
......
...@@ -270,7 +270,7 @@ gimp_image_new_create_image (Gimp *gimp, ...@@ -270,7 +270,7 @@ gimp_image_new_create_image (Gimp *gimp,
layer = gimp_layer_new (gimage, width, height, layer = gimp_layer_new (gimage, width, height,
type, _("Background"), type, _("Background"),
OPAQUE_OPACITY, GIMP_NORMAL_MODE); GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE);
if (layer) if (layer)
{ {
......
...@@ -167,12 +167,12 @@ gimp_image_projection_bytes (const GimpImage *gimage) ...@@ -167,12 +167,12 @@ gimp_image_projection_bytes (const GimpImage *gimage)
return gimage->proj_bytes; return gimage->proj_bytes;
} }
gint gdouble
gimp_image_projection_opacity (const GimpImage *gimage) gimp_image_projection_opacity (const GimpImage *gimage)
{ {
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), -1); g_return_val_if_fail (GIMP_IS_IMAGE (gimage), GIMP_OPACITY_OPAQUE);
return OPAQUE_OPACITY; return GIMP_OPACITY_OPAQUE;
} }
guchar * guchar *
...@@ -597,7 +597,7 @@ gimp_image_construct (GimpImage *gimage, ...@@ -597,7 +597,7 @@ gimp_image_construct (GimpImage *gimage,
gimage->height) && /* Covers all. */ gimage->height) && /* Covers all. */
(!gimp_drawable_is_indexed (GIMP_DRAWABLE (gimage->layers->data))) && (!gimp_drawable_is_indexed (GIMP_DRAWABLE (gimage->layers->data))) &&
/* Not indexed. */ /* Not indexed. */
(((GimpLayer *)(gimage->layers->data))->opacity == OPAQUE_OPACITY) (((GimpLayer *)(gimage->layers->data))->opacity == GIMP_OPACITY_OPAQUE)
/* Opaque */ /* Opaque */
) )
{ {
...@@ -661,11 +661,17 @@ project_intensity (GimpImage *gimage, ...@@ -661,11 +661,17 @@ project_intensity (GimpImage *gimage,
PixelRegion *mask) PixelRegion *mask)
{ {
if (! gimage->construct_flag) if (! gimage->construct_flag)
initial_region (src, dest, mask, NULL, layer->opacity, initial_region (src, dest, mask, NULL,
layer->mode, gimage->visible, INITIAL_INTENSITY); layer->opacity * 255.999,
layer->mode,
gimage->visible,
INITIAL_INTENSITY);
else else
combine_regions (dest, src, dest, mask, NULL, layer->opacity, combine_regions (dest, src, dest, mask, NULL,
layer->mode, gimage->visible, COMBINE_INTEN_A_INTEN); layer->opacity * 255.999,
layer->mode,
gimage->visible,
COMBINE_INTEN_A_INTEN);
} }
static void static void
...@@ -676,11 +682,17 @@ project_intensity_alpha (GimpImage *gimage, ...@@ -676,11 +682,17 @@ project_intensity_alpha (GimpImage *gimage,
PixelRegion *mask) PixelRegion *mask)
{ {
if (! gimage->construct_flag) if (! gimage->construct_flag)
initial_region (src, dest, mask, NULL, layer->opacity, initial_region (src, dest, mask, NULL,
layer->mode, gimage->visible, INITIAL_INTENSITY_ALPHA); layer->opacity * 255.999,
layer->mode,
gimage->visible,
INITIAL_INTENSITY_ALPHA);
else else
combine_regions (dest, src, dest, mask, NULL, layer->opacity, combine_regions (dest, src, dest, mask, NULL,
layer->mode, gimage->visible, COMBINE_INTEN_A_INTEN_A); layer->opacity * 255.999,
layer->mode,
gimage->visible,
COMBINE_INTEN_A_INTEN_A);
} }
static void static void
...@@ -690,8 +702,11 @@ project_indexed (GimpImage *gimage, ...@@ -690,8 +702,11 @@ project_indexed (GimpImage *gimage,
PixelRegion *dest) PixelRegion *dest)
{ {
if (! gimage->construct_flag) if (! gimage->construct_flag)
initial_region (src, dest, NULL, gimage->cmap, layer->opacity, initial_region (src, dest, NULL, gimage->cmap,
layer->mode, gimage->visible, INITIAL_INDEXED); layer->opacity * 255.999,
layer->mode,
gimage->visible,
INITIAL_INDEXED);
else else
g_warning ("%s: unable to project indexed image.", G_GNUC_PRETTY_FUNCTION); g_warning ("%s: unable to project indexed image.", G_GNUC_PRETTY_FUNCTION);
} }
...@@ -704,11 +719,17 @@ project_indexed_alpha (GimpImage *gimage, ...@@ -704,11 +719,17 @@ project_indexed_alpha (GimpImage *gimage,
PixelRegion *mask) PixelRegion *mask)
{ {
if (! gimage->construct_flag) if (! gimage->construct_flag)
initial_region (src, dest, mask, gimage->cmap, layer->opacity, initial_region (src, dest, mask, gimage->cmap,
layer->mode, gimage->visible, INITIAL_INDEXED_ALPHA); layer->opacity * 255.999,
layer->mode,
gimage->visible,
INITIAL_INDEXED_ALPHA);
else else
combine_regions (dest, src, dest, mask, gimage->cmap, layer->opacity, combine_regions (dest, src, dest, mask, gimage->cmap,
layer->mode, gimage->visible, COMBINE_INTEN_A_INDEXED_A); layer->opacity * 255.999,
layer->mode,
gimage->visible,
COMBINE_INTEN_A_INDEXED_A);
} }
static void static void
...@@ -729,15 +750,21 @@ project_channel (GimpImage *gimage, ...@@ -729,15 +750,21 @@ project_channel (GimpImage *gimage,
type = (channel->show_masked) ? type = (channel->show_masked) ?
INITIAL_CHANNEL_MASK : INITIAL_CHANNEL_SELECTION; INITIAL_CHANNEL_MASK : INITIAL_CHANNEL_SELECTION;
initial_region (src2, src, NULL, col, opacity, initial_region (src2, src, NULL, col,
GIMP_NORMAL_MODE, NULL, type); opacity,
GIMP_NORMAL_MODE,
NULL,
type);
} }
else else
{ {
type = (channel->show_masked) ? type = (channel->show_masked) ?
COMBINE_INTEN_A_CHANNEL_MASK : COMBINE_INTEN_A_CHANNEL_SELECTION; COMBINE_INTEN_A_CHANNEL_MASK : COMBINE_INTEN_A_CHANNEL_SELECTION;
combine_regions (src, src2, src, NULL, col, opacity, combine_regions (src, src2, src, NULL, col,
GIMP_NORMAL_MODE, NULL, type); opacity,
GIMP_NORMAL_MODE,
NULL,
type);
} }
} }
...@@ -26,7 +26,7 @@ void gimp_image_projection_free (GimpImage *gimage); ...@@ -26,7 +26,7 @@ void gimp_image_projection_free (GimpImage *gimage);
TileManager * gimp_image_projection (GimpImage *gimage); TileManager * gimp_image_projection (GimpImage *gimage);
GimpImageType gimp_image_projection_type (const GimpImage *gimage); GimpImageType gimp_image_projection_type (const GimpImage *gimage);
gint gimp_image_projection_bytes (const GimpImage *gimage); gint gimp_image_projection_bytes (const GimpImage *gimage);
gint gimp_image_projection_opacity (const GimpImage *gimage); gdouble gimp_image_projection_opacity (const GimpImage *gimage);
guchar * gimp_image_projection_get_color_at (GimpImage *gimage, guchar * gimp_image_projection_get_color_at (GimpImage *gimage,
gint x, gint x,
......
...@@ -837,14 +837,14 @@ gimp_image_get_new_preview (GimpViewable *viewable, ...@@ -837,14 +837,14 @@ gimp_image_get_new_preview (GimpViewable *viewable,
if (! construct_flag) if (! construct_flag)
initial_region (&src2PR, &src1PR, initial_region (&src2PR, &src1PR,
mask, NULL, mask, NULL,
layer->opacity, layer->opacity * 255.999,
layer->mode, layer->mode,
visible_components, visible_components,
INITIAL_INTENSITY_ALPHA); INITIAL_INTENSITY_ALPHA);
else else
combine_regions (&src1PR, &src2PR, &src1PR, combine_regions (&src1PR, &src2PR, &src1PR,
mask, NULL, mask, NULL,
layer->opacity, layer->opacity * 255.999,
layer->mode, layer->mode,
visible_components, visible_components,
COMBINE_INTEN_A_INTEN_A); COMBINE_INTEN_A_INTEN_A);
...@@ -854,14 +854,14 @@ gimp_image_get_new_preview (GimpViewable *viewable, ...@@ -854,14 +854,14 @@ gimp_image_get_new_preview (GimpViewable *viewable,
if (! construct_flag) if (! construct_flag)
initial_region (&src2PR, &src1PR, initial_region (&src2PR, &src1PR,
mask, NULL, mask, NULL,
layer->opacity, layer->opacity * 255.999,
layer->mode, layer->mode,
visible_components, visible_components,
INITIAL_INTENSITY); INITIAL_INTENSITY);
else else
combine_regions (&src1PR, &src2PR, &src1PR, combine_regions (&src1PR, &src2PR, &src1PR,
mask, NULL, mask, NULL,
layer->opacity, layer->opacity * 255.999,
layer->mode, layer->mode,
visible_components, visible_components,
COMBINE_INTEN_A_INTEN); COMBINE_INTEN_A_INTEN);
...@@ -1846,15 +1846,20 @@ gimp_image_apply_image (GimpImage *gimage, ...@@ -1846,15 +1846,20 @@ gimp_image_apply_image (GimpImage *gimage,
mx, my, mx, my,
(x2 - x1), (y2 - y1), (x2 - x1), (y2 - y1),
FALSE); FALSE);
combine_regions (&src1PR, src2PR, &destPR, &maskPR, NULL, combine_regions (&src1PR, src2PR, &destPR, &maskPR, NULL,
opacity * 255.999, mode, opacity * 255.999,
active_components, operation); mode,
active_components,
operation);
} }
else else
{ {
combine_regions (&src1PR, src2PR, &destPR, NULL, NULL, combine_regions (&src1PR, src2PR, &destPR, NULL, NULL,
opacity * 255.999, mode, opacity * 255.999,
active_components, operation); mode,
active_components,
operation);
} }
} }
...@@ -1983,7 +1988,8 @@ gimp_image_replace_image (GimpImage *gimage, ...@@ -1983,7 +1988,8 @@ gimp_image_replace_image (GimpImage *gimage,
combine_regions_replace (&src1PR, src2PR, &destPR, &tempPR, NULL, combine_regions_replace (&src1PR, src2PR, &destPR, &tempPR, NULL,
opacity * 255.999, opacity * 255.999,
active_components, operation); active_components,
operation);
g_free (temp_data); g_free (temp_data);
} }
...@@ -1991,7 +1997,8 @@ gimp_image_replace_image (GimpImage *gimage, ...@@ -1991,7 +1997,8 @@ gimp_image_replace_image (GimpImage *gimage,
{ {
combine_regions_replace (&src1PR, src2PR, &destPR, maskPR, NULL, combine_regions_replace (&src1PR, src2PR, &destPR, maskPR, NULL,
opacity * 255.999, opacity * 255.999,
active_components, operation); active_components,
operation);
} }
} }
......
...@@ -464,9 +464,8 @@ floating_sel_composite (GimpLayer *layer, ...@@ -464,9 +464,8 @@ floating_sel_composite (GimpLayer *layer,
/* apply the fs with the undo specified by the value /* apply the fs with the undo specified by the value
* passed to this function * passed to this function
*/ */
gimp_image_apply_image (gimage, layer->fs.drawable, &fsPR, gimp_image_apply_image (gimage, layer->fs.drawable, &fsPR, undo,
undo, layer->opacity,
(gdouble) layer->opacity / 255.0,
layer->mode, layer->mode,
NULL, NULL,
(x1 - offx), (y1 - offy)); (x1 - offx), (y1 - offy));
......
...@@ -186,7 +186,7 @@ gimp_layer_init (GimpLayer *layer) ...@@ -186,7 +186,7 @@ gimp_layer_init (GimpLayer *layer)
layer->mask = NULL; layer->mask = NULL;
layer->opacity = OPAQUE_OPACITY; layer->opacity = GIMP_OPACITY_OPAQUE;
layer->mode = GIMP_NORMAL_MODE; layer->mode = GIMP_NORMAL_MODE;
/* floating selection */ /* floating selection */
...@@ -310,16 +310,14 @@ gimp_layer_new (GimpImage *gimage, ...@@ -310,16 +310,14 @@ gimp_layer_new (GimpImage *gimage,
gint height, gint height,
GimpImageType type, GimpImageType type,
const gchar *name, const gchar *name,
gint opacity, gdouble opacity,
GimpLayerModeEffects mode) GimpLayerModeEffects mode)
{ {
GimpLayer *layer; GimpLayer *layer;
if (width < 1 || height < 1) g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
{ g_return_val_if_fail (width > 0, NULL);
g_message (_("Zero width or height layers not allowed.")); g_return_val_if_fail (height > 0, NULL);
return NULL;
}
layer = g_object_new (GIMP_TYPE_LAYER, NULL); layer = g_object_new (GIMP_TYPE_LAYER, NULL);
...@@ -329,8 +327,10 @@ gimp_layer_new (GimpImage *gimage, ...@@ -329,8 +327,10 @@ gimp_layer_new (GimpImage *gimage,
type, type,
name); name);
layer->mode = mode; opacity = CLAMP (opacity, GIMP_OPACITY_TRANSPARENT, GIMP_OPACITY_OPAQUE);
layer->opacity = opacity; layer->opacity = opacity;
layer->mode = mode;
return layer; return layer;
} }
...@@ -366,35 +366,47 @@ gimp_layer_copy (const GimpLayer *layer, ...@@ -366,35 +366,47 @@ gimp_layer_copy (const GimpLayer *layer,
return new_layer; return new_layer;
} }
/**
* gimp_layer_new_from_tiles:
* @tiles: The buffer to make the new layer from.
* @dest_gimage: The image the new layer will be added to.
* @name: The new layer's name.
* @opacity: The new layer's opacity.
* @mode: The new layer's mode.
*
* Copies %tiles to a layer taking into consideration the
* possibility of transforming the contents to meet the requirements
* of the target image type
*
* Return value: The new layer.
**/
GimpLayer * GimpLayer *
gimp_layer_new_from_tiles (TileManager *tiles, gimp_layer_new_from_tiles (TileManager *tiles,
GimpImage *dest_gimage, GimpImage *dest_gimage,
const gchar *name, const gchar *name,
gint opacity, gdouble opacity,
GimpLayerModeEffects mode) GimpLayerModeEffects mode)
{ {
GimpLayer *new_layer; GimpLayer *new_layer;
PixelRegion layerPR; PixelRegion layerPR;
PixelRegion bufPR; PixelRegion bufPR;
gint width, height;
/* Function copies buffer to a layer
* taking into consideration the possibility of transforming
* the contents to meet the requirements of the target image type
*/
g_return_val_if_fail (tiles != NULL, NULL); g_return_val_if_fail (tiles != NULL, NULL);
g_return_val_if_fail (GIMP_IS_IMAGE (dest_gimage), NULL); g_return_val_if_fail (GIMP_IS_IMAGE (dest_gimage), NULL);
g_return_val_if_fail (name != NULL, NULL); g_return_val_if_fail (name != NULL, NULL);
width = tile_manager_width (tiles);
height = tile_manager_height (tiles);
new_layer = gimp_layer_new (dest_gimage, new_layer = gimp_layer_new (dest_gimage,
tile_manager_width (tiles), width, height,
tile_manager_height (tiles),
gimp_image_base_type_with_alpha (dest_gimage), gimp_image_base_type_with_alpha (dest_gimage),
name, name,
opacity, opacity,
mode); mode);
if (!new_layer) if (! new_layer)
{ {
g_message ("gimp_layer_new_from_tiles: could not allocate new layer"); g_message ("gimp_layer_new_from_tiles: could not allocate new layer");
return NULL; return NULL;
...@@ -403,13 +415,11 @@ gimp_layer_new_from_tiles (TileManager *tiles, ...@@ -403,13 +415,11 @@ gimp_layer_new_from_tiles (TileManager *tiles,
/* Configure the pixel regions */ /* Configure the pixel regions */
pixel_region_init (&bufPR, tiles, pixel_region_init (&bufPR, tiles,
0, 0, 0, 0,
GIMP_DRAWABLE (new_layer)->width, width, height,
GIMP_DRAWABLE (new_layer)->height,
FALSE); FALSE);
pixel_region_init (&layerPR, GIMP_DRAWABLE (new_layer)->tiles, pixel_region_init (&layerPR, GIMP_DRAWABLE (new_layer)->tiles,
0, 0, 0, 0,
GIMP_DRAWABLE (new_layer)->width, width, height,
GIMP_DRAWABLE (new_layer)->height,
TRUE); TRUE);
if ((tile_manager_bpp (tiles) == 4 && if ((tile_manager_bpp (tiles) == 4 &&
...@@ -1458,15 +1468,13 @@ void ...@@ -1458,15 +1468,13 @@ void
gimp_layer_set_opacity (GimpLayer *layer, gimp_layer_set_opacity (GimpLayer *layer,
gdouble opacity) gdouble opacity)
{ {
gint layer_opacity;
g_return_if_fail (GIMP_IS_LAYER (layer)); g_return_if_fail (GIMP_IS_LAYER (layer));
layer_opacity = (gint) (opacity * 255.999); opacity = CLAMP (opacity, GIMP_OPACITY_TRANSPARENT, GIMP_OPACITY_OPAQUE);