Commit 21829c44 authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann

take image type instead of basetype of the source drawable. Handle

2005-08-09  Sven Neumann  <sven@gimp.org>

	* app/core/gimplayer.c (gimp_layer_transform_color): take image
	type instead of basetype of the source drawable. Handle conversion
	from drawables without alpha channel.
	(gimp_layer_new_from_region): handle source regions without alpha.
parent aa524698
2005-08-09 Sven Neumann <sven@gimp.org>
* app/core/gimplayer.c (gimp_layer_transform_color): take image
type instead of basetype of the source drawable. Handle conversion
from drawables without alpha channel.
(gimp_layer_new_from_region): handle source regions without alpha.
2005-08-08 Jakub Steiner <jimmac@ximian.com>
* themes/Default/images/tools/stock-tool-foreground-select-16.png
......
......@@ -157,7 +157,7 @@ static void gimp_layer_transform_color (GimpImage *gimage,
PixelRegion *layerPR,
PixelRegion *bufPR,
GimpDrawable *drawable,
GimpImageBaseType src_type);
GimpImageType src_type);
static void gimp_layer_layer_mask_update (GimpDrawable *layer_mask,
gint x,
......@@ -645,7 +645,7 @@ gimp_layer_convert (GimpItem *item,
gimp_layer_transform_color (gimp_item_get_image (item),
&newPR, &layerPR,
NULL,
old_base_type);
gimp_drawable_type (drawable));
}
break;
}
......@@ -918,13 +918,15 @@ gimp_layer_get_opacity_at (GimpPickable *pickable,
}
static void
gimp_layer_transform_color (GimpImage *gimage,
PixelRegion *layerPR,
PixelRegion *bufPR,
GimpDrawable *drawable,
GimpImageBaseType src_type)
gimp_layer_transform_color (GimpImage *gimage,
PixelRegion *layerPR,
PixelRegion *bufPR,
GimpDrawable *drawable,
GimpImageType src_type)
{
gpointer pr;
GimpImageBaseType base_type = GIMP_IMAGE_TYPE_BASE_TYPE (src_type);
gboolean alpha = GIMP_IMAGE_TYPE_HAS_ALPHA (src_type);
gpointer pr;
for (pr = pixel_regions_register (2, layerPR, bufPR);
pr != NULL;
......@@ -942,10 +944,11 @@ gimp_layer_transform_color (GimpImage *gimage,
for (i = 0; i < layerPR->w; i++)
{
gimp_image_transform_color (gimage, drawable, d, src_type, s);
gimp_image_transform_color (gimage, drawable, d, base_type, s);
/* copy alpha channel */
d[layerPR->bytes - 1] = s[bufPR->bytes - 1];
/* alpha channel */
d[layerPR->bytes - 1] = (alpha ?
s[bufPR->bytes - 1] : OPAQUE_OPACITY);
s += bufPR->bytes;
d += layerPR->bytes;
......@@ -1171,9 +1174,10 @@ gimp_layer_new_from_region (PixelRegion *region,
case GIMP_RGB_IMAGE:
add_alpha_region (region, &layerPR);
break;
case GIMP_GRAY_IMAGE:
case GIMP_GRAYA_IMAGE:
gimp_layer_transform_color (dest_gimage, &layerPR, region,
GIMP_DRAWABLE (new_layer), GIMP_GRAY);
GIMP_DRAWABLE (new_layer), src_type);
break;
default:
g_warning ("%s: unhandled type conversion", G_STRFUNC);
......@@ -1196,9 +1200,10 @@ gimp_layer_new_from_region (PixelRegion *region,
case GIMP_GRAYA_IMAGE:
switch (src_type)
{
case GIMP_RGB_IMAGE:
case GIMP_RGBA_IMAGE:
gimp_layer_transform_color (dest_gimage, &layerPR, region,
GIMP_DRAWABLE (new_layer), GIMP_RGB);
GIMP_DRAWABLE (new_layer), src_type);
break;
case GIMP_GRAYA_IMAGE:
copy_region (region, &layerPR);
......@@ -1219,13 +1224,15 @@ gimp_layer_new_from_region (PixelRegion *region,
case GIMP_INDEXEDA_IMAGE:
switch (src_type)
{
case GIMP_RGB_IMAGE:
case GIMP_RGBA_IMAGE:
gimp_layer_transform_color (dest_gimage, &layerPR, region,
GIMP_DRAWABLE (new_layer), GIMP_RGB);
GIMP_DRAWABLE (new_layer), src_type);
break;
case GIMP_GRAY_IMAGE:
case GIMP_GRAYA_IMAGE:
gimp_layer_transform_color (dest_gimage, &layerPR, region,
GIMP_DRAWABLE (new_layer), GIMP_GRAY);
GIMP_DRAWABLE (new_layer), src_type);
break;
default:
g_warning ("%s: unhandled type conversion", G_STRFUNC);
......
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