Commit 96ebc6f8 authored by Michael Natterer's avatar Michael Natterer 😴

app: add "new_precision" argument to gimp_drawable_convert_type()

for clarity and consistency with the "new_base_type" argument.
parent 0e8a00db
......@@ -447,7 +447,9 @@ gimp_channel_convert (GimpItem *item,
if (! gimp_drawable_is_gray (drawable))
{
gimp_drawable_convert_type (drawable, dest_image, GIMP_GRAY, FALSE);
gimp_drawable_convert_type (drawable, dest_image, GIMP_GRAY,
gimp_image_get_precision (dest_image),
FALSE);
}
if (gimp_drawable_has_alpha (drawable))
......
......@@ -134,6 +134,7 @@ static gint64 gimp_drawable_real_estimate_memsize (const GimpDrawable *drawable
static void gimp_drawable_real_convert_type (GimpDrawable *drawable,
GimpImage *dest_image,
GimpImageBaseType new_base_type,
GimpPrecision new_precision,
gboolean push_undo);
static GeglBuffer * gimp_drawable_real_get_buffer (GimpDrawable *drawable);
......@@ -693,13 +694,15 @@ static void
gimp_drawable_real_convert_type (GimpDrawable *drawable,
GimpImage *dest_image,
GimpImageBaseType new_base_type,
GimpPrecision new_precision,
gboolean push_undo)
{
GeglBuffer *dest_buffer;
const Babl *format;
format = gimp_image_get_format (dest_image, new_base_type,
gimp_drawable_has_alpha (drawable));
format = gimp_babl_format (new_base_type,
new_precision,
gimp_drawable_has_alpha (drawable));
dest_buffer =
gimp_gegl_buffer_new (GEGL_RECTANGLE (0, 0,
......@@ -1155,20 +1158,21 @@ void
gimp_drawable_convert_type (GimpDrawable *drawable,
GimpImage *dest_image,
GimpImageBaseType new_base_type,
GimpPrecision new_precision,
gboolean push_undo)
{
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
g_return_if_fail (GIMP_IS_IMAGE (dest_image));
g_return_if_fail (new_base_type !=
gimp_drawable_get_base_type (drawable) ||
gimp_image_get_precision (dest_image) !=
gimp_drawable_get_precision (drawable));
g_return_if_fail (new_base_type != gimp_drawable_get_base_type (drawable) ||
new_precision != gimp_drawable_get_precision (drawable));
if (! gimp_item_is_attached (GIMP_ITEM (drawable)))
push_undo = FALSE;
GIMP_DRAWABLE_GET_CLASS (drawable)->convert_type (drawable, dest_image,
new_base_type, push_undo);
new_base_type,
new_precision,
push_undo);
}
void
......
......@@ -62,6 +62,7 @@ struct _GimpDrawableClass
void (* convert_type) (GimpDrawable *drawable,
GimpImage *dest_image,
GimpImageBaseType new_base_type,
GimpPrecision new_precision,
gboolean push_undo);
void (* apply_buffer) (GimpDrawable *drawable,
GeglBuffer *buffer,
......@@ -143,6 +144,7 @@ void gimp_drawable_get_active_components (const GimpDrawable *drawable,
void gimp_drawable_convert_type (GimpDrawable *drawable,
GimpImage *dest_image,
GimpImageBaseType new_base_type,
GimpPrecision new_precision,
gboolean push_undo);
void gimp_drawable_apply_buffer (GimpDrawable *drawable,
......
......@@ -136,6 +136,7 @@ static gint64 gimp_group_layer_estimate_memsize (const GimpDrawable *drawab
static void gimp_group_layer_convert_type (GimpDrawable *drawable,
GimpImage *dest_image,
GimpImageBaseType new_base_type,
GimpPrecision new_precision,
gboolean push_undo);
static const Babl * gimp_group_layer_get_format (GimpProjectable *projectable);
......@@ -847,6 +848,7 @@ static void
gimp_group_layer_convert_type (GimpDrawable *drawable,
GimpImage *dest_image,
GimpImageBaseType new_base_type,
GimpPrecision new_precision,
gboolean push_undo)
{
GimpGroupLayer *group = GIMP_GROUP_LAYER (drawable);
......
......@@ -75,6 +75,7 @@ gimp_group_layer_undo_constructed (GObject *object)
case GIMP_UNDO_GROUP_LAYER_CONVERT:
group_layer_undo->prev_type = gimp_drawable_get_base_type (GIMP_DRAWABLE (group));
group_layer_undo->prev_precision = gimp_drawable_get_precision (GIMP_DRAWABLE (group));
break;
default:
......@@ -118,12 +119,19 @@ gimp_group_layer_undo_pop (GimpUndo *undo,
case GIMP_UNDO_GROUP_LAYER_CONVERT:
{
GimpImageBaseType type;
GimpPrecision precision;
type = gimp_drawable_get_base_type (GIMP_DRAWABLE (group));
precision = gimp_drawable_get_precision (GIMP_DRAWABLE (group));
type = gimp_drawable_get_base_type (GIMP_DRAWABLE (group));
gimp_drawable_convert_type (GIMP_DRAWABLE (group),
gimp_item_get_image (GIMP_ITEM (group)),
group_layer_undo->prev_type, FALSE);
group_layer_undo->prev_type = type;
group_layer_undo->prev_type,
group_layer_undo->prev_precision,
FALSE);
group_layer_undo->prev_type = type;
group_layer_undo->prev_precision = precision;
}
break;
......
......@@ -37,6 +37,7 @@ struct _GimpGroupLayerUndo
GimpItemUndo parent_instance;
GimpImageBaseType prev_type;
GimpPrecision prev_precision;
};
struct _GimpGroupLayerUndoClass
......
......@@ -971,6 +971,7 @@ gimp_image_convert (GimpImage *image,
case GIMP_RGB:
case GIMP_GRAY:
gimp_drawable_convert_type (GIMP_DRAWABLE (layer), image, new_type,
gimp_drawable_get_precision (GIMP_DRAWABLE (layer)),
TRUE);
break;
......
......@@ -620,7 +620,11 @@ gimp_layer_convert (GimpItem *item,
if (old_base_type != new_base_type ||
old_precision != new_precision)
gimp_drawable_convert_type (drawable, dest_image, new_base_type, FALSE);
{
gimp_drawable_convert_type (drawable, dest_image,
new_base_type, new_precision,
FALSE);
}
if (layer->mask)
gimp_item_set_image (GIMP_ITEM (layer->mask), dest_image);
......
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