2012-04-29 07:22:20 -07:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
|
*
|
|
|
|
|
* gimpimage-convert-precision.c
|
|
|
|
|
* Copyright (C) 2012 Michael Natterer <mitch@gimp.org>
|
|
|
|
|
*
|
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2018-07-11 14:47:19 -07:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2012-04-29 07:22:20 -07:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
2015-10-20 14:53:47 -07:00
|
|
|
#include <cairo.h>
|
2013-10-14 16:58:39 -07:00
|
|
|
#include <gdk-pixbuf/gdk-pixbuf.h>
|
2012-04-29 07:22:20 -07:00
|
|
|
#include <gegl.h>
|
|
|
|
|
|
2015-10-20 14:53:47 -07:00
|
|
|
#include "libgimpcolor/gimpcolor.h"
|
|
|
|
|
|
2012-04-29 07:22:20 -07:00
|
|
|
#include "core-types.h"
|
|
|
|
|
|
2015-10-20 14:53:47 -07:00
|
|
|
#include "gegl/gimp-babl.h"
|
2018-05-24 07:21:21 -07:00
|
|
|
#include "gegl/gimp-gegl-loops.h"
|
2012-04-29 07:22:20 -07:00
|
|
|
|
app: use GimpObjectQueue in lots of places
Use GimpObjectQueue, added in the previous commit, in various
instances where we perform an action on a set of objects. This
improves progress reporting, by using a single progress for the
entire operation, rather than reporting the progress of each object
individually, and by taking the relative cost of each object into
account, instead of assuming a uniform cost for all objects.
In particular, this affects the various whole-image operations
(i.e., transformations and color conversions), operations on linked
items, and operations on layer groups. This also affects layers
with masks, whose progress is now reported together instead of
individually.
Additionally, this commit fixes erroneous group-layer mask cropping
during undo when resizing the image, by properly calling
{start,end}_move() on all the resized layers before starting the
operation, and when scaling the image, by only scaling top-level
layers, and letting group layers scale their children themselves.
2018-03-25 07:18:46 -07:00
|
|
|
#include "gimpchannel.h"
|
2012-04-29 07:22:20 -07:00
|
|
|
#include "gimpdrawable.h"
|
2017-01-22 13:03:55 -08:00
|
|
|
#include "gimpdrawable-operation.h"
|
2012-04-29 07:22:20 -07:00
|
|
|
#include "gimpimage.h"
|
2015-10-20 14:53:47 -07:00
|
|
|
#include "gimpimage-color-profile.h"
|
2012-04-29 07:22:20 -07:00
|
|
|
#include "gimpimage-convert-precision.h"
|
|
|
|
|
#include "gimpimage-undo.h"
|
|
|
|
|
#include "gimpimage-undo-push.h"
|
app: use GimpObjectQueue in lots of places
Use GimpObjectQueue, added in the previous commit, in various
instances where we perform an action on a set of objects. This
improves progress reporting, by using a single progress for the
entire operation, rather than reporting the progress of each object
individually, and by taking the relative cost of each object into
account, instead of assuming a uniform cost for all objects.
In particular, this affects the various whole-image operations
(i.e., transformations and color conversions), operations on linked
items, and operations on layer groups. This also affects layers
with masks, whose progress is now reported together instead of
individually.
Additionally, this commit fixes erroneous group-layer mask cropping
during undo when resizing the image, by properly calling
{start,end}_move() on all the resized layers before starting the
operation, and when scaling the image, by only scaling top-level
layers, and letting group layers scale their children themselves.
2018-03-25 07:18:46 -07:00
|
|
|
#include "gimpobjectqueue.h"
|
2012-04-29 07:22:20 -07:00
|
|
|
#include "gimpprogress.h"
|
|
|
|
|
|
2012-11-10 09:56:44 -08:00
|
|
|
#include "text/gimptextlayer.h"
|
|
|
|
|
|
2012-04-29 07:22:20 -07:00
|
|
|
#include "gimp-intl.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2016-11-07 11:41:39 -08:00
|
|
|
gimp_image_convert_precision (GimpImage *image,
|
|
|
|
|
GimpPrecision precision,
|
|
|
|
|
GeglDitherMethod layer_dither_type,
|
|
|
|
|
GeglDitherMethod text_layer_dither_type,
|
|
|
|
|
GeglDitherMethod mask_dither_type,
|
|
|
|
|
GimpProgress *progress)
|
2012-04-29 07:22:20 -07:00
|
|
|
{
|
2015-10-20 14:53:47 -07:00
|
|
|
GimpColorProfile *old_profile;
|
2016-04-28 15:42:42 -07:00
|
|
|
GimpColorProfile *new_profile = NULL;
|
2015-10-20 14:53:47 -07:00
|
|
|
const Babl *old_format;
|
|
|
|
|
const Babl *new_format;
|
app: use GimpObjectQueue in lots of places
Use GimpObjectQueue, added in the previous commit, in various
instances where we perform an action on a set of objects. This
improves progress reporting, by using a single progress for the
entire operation, rather than reporting the progress of each object
individually, and by taking the relative cost of each object into
account, instead of assuming a uniform cost for all objects.
In particular, this affects the various whole-image operations
(i.e., transformations and color conversions), operations on linked
items, and operations on layer groups. This also affects layers
with masks, whose progress is now reported together instead of
individually.
Additionally, this commit fixes erroneous group-layer mask cropping
during undo when resizing the image, by properly calling
{start,end}_move() on all the resized layers before starting the
operation, and when scaling the image, by only scaling top-level
layers, and letting group layers scale their children themselves.
2018-03-25 07:18:46 -07:00
|
|
|
GimpObjectQueue *queue;
|
2018-03-27 06:34:42 -07:00
|
|
|
GimpProgress *sub_progress;
|
app: use GimpObjectQueue in lots of places
Use GimpObjectQueue, added in the previous commit, in various
instances where we perform an action on a set of objects. This
improves progress reporting, by using a single progress for the
entire operation, rather than reporting the progress of each object
individually, and by taking the relative cost of each object into
account, instead of assuming a uniform cost for all objects.
In particular, this affects the various whole-image operations
(i.e., transformations and color conversions), operations on linked
items, and operations on layer groups. This also affects layers
with masks, whose progress is now reported together instead of
individually.
Additionally, this commit fixes erroneous group-layer mask cropping
during undo when resizing the image, by properly calling
{start,end}_move() on all the resized layers before starting the
operation, and when scaling the image, by only scaling top-level
layers, and letting group layers scale their children themselves.
2018-03-25 07:18:46 -07:00
|
|
|
GList *layers;
|
|
|
|
|
GimpDrawable *drawable;
|
2015-10-21 13:22:30 -07:00
|
|
|
const gchar *undo_desc = NULL;
|
2012-04-29 07:22:20 -07:00
|
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_IMAGE (image));
|
|
|
|
|
g_return_if_fail (precision != gimp_image_get_precision (image));
|
2018-07-06 10:43:26 -07:00
|
|
|
g_return_if_fail (gimp_babl_is_valid (gimp_image_get_base_type (image),
|
|
|
|
|
precision));
|
2012-04-29 07:22:20 -07:00
|
|
|
g_return_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress));
|
|
|
|
|
|
|
|
|
|
switch (precision)
|
|
|
|
|
{
|
2013-06-23 07:51:24 -07:00
|
|
|
case GIMP_PRECISION_U8_LINEAR:
|
|
|
|
|
undo_desc = C_("undo-type", "Convert Image to 8 bit linear integer");
|
2012-04-29 07:22:20 -07:00
|
|
|
break;
|
2013-06-23 07:51:24 -07:00
|
|
|
case GIMP_PRECISION_U8_GAMMA:
|
|
|
|
|
undo_desc = C_("undo-type", "Convert Image to 8 bit gamma integer");
|
2012-04-29 07:22:20 -07:00
|
|
|
break;
|
2013-06-23 07:51:24 -07:00
|
|
|
case GIMP_PRECISION_U16_LINEAR:
|
|
|
|
|
undo_desc = C_("undo-type", "Convert Image to 16 bit linear integer");
|
2012-04-29 07:22:20 -07:00
|
|
|
break;
|
2013-06-23 07:51:24 -07:00
|
|
|
case GIMP_PRECISION_U16_GAMMA:
|
|
|
|
|
undo_desc = C_("undo-type", "Convert Image to 16 bit gamma integer");
|
2012-04-29 07:22:20 -07:00
|
|
|
break;
|
2013-06-23 07:51:24 -07:00
|
|
|
case GIMP_PRECISION_U32_LINEAR:
|
|
|
|
|
undo_desc = C_("undo-type", "Convert Image to 32 bit linear integer");
|
|
|
|
|
break;
|
|
|
|
|
case GIMP_PRECISION_U32_GAMMA:
|
|
|
|
|
undo_desc = C_("undo-type", "Convert Image to 32 bit gamma integer");
|
|
|
|
|
break;
|
|
|
|
|
case GIMP_PRECISION_HALF_LINEAR:
|
|
|
|
|
undo_desc = C_("undo-type", "Convert Image to 16 bit linear floating point");
|
|
|
|
|
break;
|
|
|
|
|
case GIMP_PRECISION_HALF_GAMMA:
|
|
|
|
|
undo_desc = C_("undo-type", "Convert Image to 16 bit gamma floating point");
|
|
|
|
|
break;
|
|
|
|
|
case GIMP_PRECISION_FLOAT_LINEAR:
|
|
|
|
|
undo_desc = C_("undo-type", "Convert Image to 32 bit linear floating point");
|
|
|
|
|
break;
|
|
|
|
|
case GIMP_PRECISION_FLOAT_GAMMA:
|
|
|
|
|
undo_desc = C_("undo-type", "Convert Image to 32 bit gamma floating point");
|
2012-04-29 07:22:20 -07:00
|
|
|
break;
|
2014-03-08 15:41:58 -08:00
|
|
|
case GIMP_PRECISION_DOUBLE_LINEAR:
|
|
|
|
|
undo_desc = C_("undo-type", "Convert Image to 64 bit linear floating point");
|
|
|
|
|
break;
|
|
|
|
|
case GIMP_PRECISION_DOUBLE_GAMMA:
|
|
|
|
|
undo_desc = C_("undo-type", "Convert Image to 64 bit gamma floating point");
|
|
|
|
|
break;
|
2012-04-29 07:22:20 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (progress)
|
2014-07-12 14:45:20 -07:00
|
|
|
gimp_progress_start (progress, FALSE, "%s", undo_desc);
|
2012-04-29 07:22:20 -07:00
|
|
|
|
2018-03-27 06:34:42 -07:00
|
|
|
queue = gimp_object_queue_new (progress);
|
|
|
|
|
sub_progress = GIMP_PROGRESS (queue);
|
app: use GimpObjectQueue in lots of places
Use GimpObjectQueue, added in the previous commit, in various
instances where we perform an action on a set of objects. This
improves progress reporting, by using a single progress for the
entire operation, rather than reporting the progress of each object
individually, and by taking the relative cost of each object into
account, instead of assuming a uniform cost for all objects.
In particular, this affects the various whole-image operations
(i.e., transformations and color conversions), operations on linked
items, and operations on layer groups. This also affects layers
with masks, whose progress is now reported together instead of
individually.
Additionally, this commit fixes erroneous group-layer mask cropping
during undo when resizing the image, by properly calling
{start,end}_move() on all the resized layers before starting the
operation, and when scaling the image, by only scaling top-level
layers, and letting group layers scale their children themselves.
2018-03-25 07:18:46 -07:00
|
|
|
|
|
|
|
|
layers = gimp_image_get_layer_list (image);
|
|
|
|
|
gimp_object_queue_push_list (queue, layers);
|
|
|
|
|
g_list_free (layers);
|
|
|
|
|
|
|
|
|
|
gimp_object_queue_push (queue, gimp_image_get_mask (image));
|
|
|
|
|
gimp_object_queue_push_container (queue, gimp_image_get_channels (image));
|
|
|
|
|
|
2012-04-29 07:22:20 -07:00
|
|
|
g_object_freeze_notify (G_OBJECT (image));
|
|
|
|
|
|
|
|
|
|
gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_IMAGE_CONVERT,
|
|
|
|
|
undo_desc);
|
|
|
|
|
|
2012-05-05 12:41:20 -07:00
|
|
|
/* Push the image precision to the stack */
|
2012-04-29 07:22:20 -07:00
|
|
|
gimp_image_undo_push_image_precision (image, NULL);
|
|
|
|
|
|
2015-10-21 11:27:06 -07:00
|
|
|
old_profile = gimp_image_get_color_profile (image);
|
2015-10-20 14:53:47 -07:00
|
|
|
old_format = gimp_image_get_layer_format (image, FALSE);
|
|
|
|
|
|
2012-04-29 07:22:20 -07:00
|
|
|
/* Set the new precision */
|
|
|
|
|
g_object_set (image, "precision", precision, NULL);
|
|
|
|
|
|
2015-10-20 14:53:47 -07:00
|
|
|
new_format = gimp_image_get_layer_format (image, FALSE);
|
|
|
|
|
|
2016-05-20 15:37:28 -07:00
|
|
|
if (old_profile)
|
2016-04-28 15:42:42 -07:00
|
|
|
{
|
2016-05-20 15:37:28 -07:00
|
|
|
if (gimp_babl_format_get_linear (old_format) !=
|
|
|
|
|
gimp_babl_format_get_linear (new_format))
|
2016-04-28 15:42:42 -07:00
|
|
|
{
|
2016-05-20 15:37:28 -07:00
|
|
|
/* when converting between linear and gamma, we create a new
|
|
|
|
|
* profile using the original profile's chromacities and
|
|
|
|
|
* whitepoint, but a linear/sRGB-gamma TRC.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
if (gimp_babl_format_get_linear (new_format))
|
|
|
|
|
{
|
|
|
|
|
new_profile =
|
|
|
|
|
gimp_color_profile_new_linear_from_color_profile (old_profile);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
new_profile =
|
|
|
|
|
gimp_color_profile_new_srgb_trc_from_color_profile (old_profile);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* if a new profile cannot be be generated, convert to the
|
|
|
|
|
* builtin profile, which is better than leaving the user with
|
|
|
|
|
* broken colors
|
|
|
|
|
*/
|
|
|
|
|
if (! new_profile)
|
|
|
|
|
{
|
|
|
|
|
new_profile = gimp_image_get_builtin_color_profile (image);
|
|
|
|
|
g_object_ref (new_profile);
|
|
|
|
|
}
|
2016-04-28 15:42:42 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (! new_profile)
|
2016-05-20 15:37:28 -07:00
|
|
|
new_profile = g_object_ref (old_profile);
|
2016-04-28 15:42:42 -07:00
|
|
|
}
|
|
|
|
|
|
app: use GimpObjectQueue in lots of places
Use GimpObjectQueue, added in the previous commit, in various
instances where we perform an action on a set of objects. This
improves progress reporting, by using a single progress for the
entire operation, rather than reporting the progress of each object
individually, and by taking the relative cost of each object into
account, instead of assuming a uniform cost for all objects.
In particular, this affects the various whole-image operations
(i.e., transformations and color conversions), operations on linked
items, and operations on layer groups. This also affects layers
with masks, whose progress is now reported together instead of
individually.
Additionally, this commit fixes erroneous group-layer mask cropping
during undo when resizing the image, by properly calling
{start,end}_move() on all the resized layers before starting the
operation, and when scaling the image, by only scaling top-level
layers, and letting group layers scale their children themselves.
2018-03-25 07:18:46 -07:00
|
|
|
while ((drawable = gimp_object_queue_pop (queue)))
|
2012-04-29 07:22:20 -07:00
|
|
|
{
|
app: use GimpObjectQueue in lots of places
Use GimpObjectQueue, added in the previous commit, in various
instances where we perform an action on a set of objects. This
improves progress reporting, by using a single progress for the
entire operation, rather than reporting the progress of each object
individually, and by taking the relative cost of each object into
account, instead of assuming a uniform cost for all objects.
In particular, this affects the various whole-image operations
(i.e., transformations and color conversions), operations on linked
items, and operations on layer groups. This also affects layers
with masks, whose progress is now reported together instead of
individually.
Additionally, this commit fixes erroneous group-layer mask cropping
during undo when resizing the image, by properly calling
{start,end}_move() on all the resized layers before starting the
operation, and when scaling the image, by only scaling top-level
layers, and letting group layers scale their children themselves.
2018-03-25 07:18:46 -07:00
|
|
|
if (drawable == GIMP_DRAWABLE (gimp_image_get_mask (image)))
|
|
|
|
|
{
|
|
|
|
|
GeglBuffer *buffer;
|
2012-11-10 09:56:44 -08:00
|
|
|
|
app: use GimpObjectQueue in lots of places
Use GimpObjectQueue, added in the previous commit, in various
instances where we perform an action on a set of objects. This
improves progress reporting, by using a single progress for the
entire operation, rather than reporting the progress of each object
individually, and by taking the relative cost of each object into
account, instead of assuming a uniform cost for all objects.
In particular, this affects the various whole-image operations
(i.e., transformations and color conversions), operations on linked
items, and operations on layer groups. This also affects layers
with masks, whose progress is now reported together instead of
individually.
Additionally, this commit fixes erroneous group-layer mask cropping
during undo when resizing the image, by properly calling
{start,end}_move() on all the resized layers before starting the
operation, and when scaling the image, by only scaling top-level
layers, and letting group layers scale their children themselves.
2018-03-25 07:18:46 -07:00
|
|
|
gimp_image_undo_push_mask_precision (image, NULL,
|
|
|
|
|
GIMP_CHANNEL (drawable));
|
|
|
|
|
|
|
|
|
|
buffer = gegl_buffer_new (GEGL_RECTANGLE (0, 0,
|
|
|
|
|
gimp_image_get_width (image),
|
|
|
|
|
gimp_image_get_height (image)),
|
|
|
|
|
gimp_image_get_mask_format (image));
|
|
|
|
|
|
2018-05-24 07:21:21 -07:00
|
|
|
gimp_gegl_buffer_copy (gimp_drawable_get_buffer (drawable), NULL,
|
|
|
|
|
GEGL_ABYSS_NONE,
|
|
|
|
|
buffer, NULL);
|
app: use GimpObjectQueue in lots of places
Use GimpObjectQueue, added in the previous commit, in various
instances where we perform an action on a set of objects. This
improves progress reporting, by using a single progress for the
entire operation, rather than reporting the progress of each object
individually, and by taking the relative cost of each object into
account, instead of assuming a uniform cost for all objects.
In particular, this affects the various whole-image operations
(i.e., transformations and color conversions), operations on linked
items, and operations on layer groups. This also affects layers
with masks, whose progress is now reported together instead of
individually.
Additionally, this commit fixes erroneous group-layer mask cropping
during undo when resizing the image, by properly calling
{start,end}_move() on all the resized layers before starting the
operation, and when scaling the image, by only scaling top-level
layers, and letting group layers scale their children themselves.
2018-03-25 07:18:46 -07:00
|
|
|
|
|
|
|
|
gimp_drawable_set_buffer (drawable, FALSE, NULL, buffer);
|
|
|
|
|
g_object_unref (buffer);
|
2018-03-27 06:36:28 -07:00
|
|
|
|
|
|
|
|
gimp_progress_set_value (sub_progress, 1.0);
|
app: use GimpObjectQueue in lots of places
Use GimpObjectQueue, added in the previous commit, in various
instances where we perform an action on a set of objects. This
improves progress reporting, by using a single progress for the
entire operation, rather than reporting the progress of each object
individually, and by taking the relative cost of each object into
account, instead of assuming a uniform cost for all objects.
In particular, this affects the various whole-image operations
(i.e., transformations and color conversions), operations on linked
items, and operations on layer groups. This also affects layers
with masks, whose progress is now reported together instead of
individually.
Additionally, this commit fixes erroneous group-layer mask cropping
during undo when resizing the image, by properly calling
{start,end}_move() on all the resized layers before starting the
operation, and when scaling the image, by only scaling top-level
layers, and letting group layers scale their children themselves.
2018-03-25 07:18:46 -07:00
|
|
|
}
|
2012-11-10 09:56:44 -08:00
|
|
|
else
|
app: use GimpObjectQueue in lots of places
Use GimpObjectQueue, added in the previous commit, in various
instances where we perform an action on a set of objects. This
improves progress reporting, by using a single progress for the
entire operation, rather than reporting the progress of each object
individually, and by taking the relative cost of each object into
account, instead of assuming a uniform cost for all objects.
In particular, this affects the various whole-image operations
(i.e., transformations and color conversions), operations on linked
items, and operations on layer groups. This also affects layers
with masks, whose progress is now reported together instead of
individually.
Additionally, this commit fixes erroneous group-layer mask cropping
during undo when resizing the image, by properly calling
{start,end}_move() on all the resized layers before starting the
operation, and when scaling the image, by only scaling top-level
layers, and letting group layers scale their children themselves.
2018-03-25 07:18:46 -07:00
|
|
|
{
|
|
|
|
|
gint dither_type;
|
2015-10-20 14:53:47 -07:00
|
|
|
|
app: use GimpObjectQueue in lots of places
Use GimpObjectQueue, added in the previous commit, in various
instances where we perform an action on a set of objects. This
improves progress reporting, by using a single progress for the
entire operation, rather than reporting the progress of each object
individually, and by taking the relative cost of each object into
account, instead of assuming a uniform cost for all objects.
In particular, this affects the various whole-image operations
(i.e., transformations and color conversions), operations on linked
items, and operations on layer groups. This also affects layers
with masks, whose progress is now reported together instead of
individually.
Additionally, this commit fixes erroneous group-layer mask cropping
during undo when resizing the image, by properly calling
{start,end}_move() on all the resized layers before starting the
operation, and when scaling the image, by only scaling top-level
layers, and letting group layers scale their children themselves.
2018-03-25 07:18:46 -07:00
|
|
|
if (gimp_item_is_text_layer (GIMP_ITEM (drawable)))
|
|
|
|
|
dither_type = text_layer_dither_type;
|
|
|
|
|
else
|
|
|
|
|
dither_type = layer_dither_type;
|
|
|
|
|
|
|
|
|
|
gimp_drawable_convert_type (drawable, image,
|
|
|
|
|
gimp_drawable_get_base_type (drawable),
|
|
|
|
|
precision,
|
|
|
|
|
gimp_drawable_has_alpha (drawable),
|
|
|
|
|
new_profile,
|
|
|
|
|
dither_type,
|
|
|
|
|
mask_dither_type,
|
2018-03-27 06:34:42 -07:00
|
|
|
TRUE, sub_progress);
|
app: use GimpObjectQueue in lots of places
Use GimpObjectQueue, added in the previous commit, in various
instances where we perform an action on a set of objects. This
improves progress reporting, by using a single progress for the
entire operation, rather than reporting the progress of each object
individually, and by taking the relative cost of each object into
account, instead of assuming a uniform cost for all objects.
In particular, this affects the various whole-image operations
(i.e., transformations and color conversions), operations on linked
items, and operations on layer groups. This also affects layers
with masks, whose progress is now reported together instead of
individually.
Additionally, this commit fixes erroneous group-layer mask cropping
during undo when resizing the image, by properly calling
{start,end}_move() on all the resized layers before starting the
operation, and when scaling the image, by only scaling top-level
layers, and letting group layers scale their children themselves.
2018-03-25 07:18:46 -07:00
|
|
|
}
|
|
|
|
|
}
|
2012-04-29 07:22:20 -07:00
|
|
|
|
2016-05-20 15:37:28 -07:00
|
|
|
if (new_profile)
|
2015-10-20 14:53:47 -07:00
|
|
|
{
|
2016-05-20 15:37:28 -07:00
|
|
|
if (new_profile != old_profile)
|
|
|
|
|
gimp_image_set_color_profile (image, new_profile, NULL);
|
|
|
|
|
|
2016-04-28 15:42:42 -07:00
|
|
|
g_object_unref (new_profile);
|
2015-10-20 14:53:47 -07:00
|
|
|
}
|
|
|
|
|
|
2012-04-29 07:22:20 -07:00
|
|
|
gimp_image_undo_group_end (image);
|
|
|
|
|
|
|
|
|
|
gimp_image_precision_changed (image);
|
|
|
|
|
g_object_thaw_notify (G_OBJECT (image));
|
|
|
|
|
|
app: use GimpObjectQueue in lots of places
Use GimpObjectQueue, added in the previous commit, in various
instances where we perform an action on a set of objects. This
improves progress reporting, by using a single progress for the
entire operation, rather than reporting the progress of each object
individually, and by taking the relative cost of each object into
account, instead of assuming a uniform cost for all objects.
In particular, this affects the various whole-image operations
(i.e., transformations and color conversions), operations on linked
items, and operations on layer groups. This also affects layers
with masks, whose progress is now reported together instead of
individually.
Additionally, this commit fixes erroneous group-layer mask cropping
during undo when resizing the image, by properly calling
{start,end}_move() on all the resized layers before starting the
operation, and when scaling the image, by only scaling top-level
layers, and letting group layers scale their children themselves.
2018-03-25 07:18:46 -07:00
|
|
|
g_object_unref (queue);
|
2015-10-21 13:22:30 -07:00
|
|
|
|
2012-04-29 07:22:20 -07:00
|
|
|
if (progress)
|
|
|
|
|
gimp_progress_end (progress);
|
|
|
|
|
}
|
2017-01-22 13:03:55 -08:00
|
|
|
|
|
|
|
|
void
|
|
|
|
|
gimp_image_convert_dither_u8 (GimpImage *image,
|
|
|
|
|
GimpProgress *progress)
|
|
|
|
|
{
|
|
|
|
|
GeglNode *dither;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_IMAGE (image));
|
|
|
|
|
g_return_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress));
|
|
|
|
|
|
|
|
|
|
dither = gegl_node_new_child (NULL,
|
|
|
|
|
"operation", "gegl:noise-rgb",
|
2018-03-29 00:03:51 -07:00
|
|
|
"red", 1.0 / 256.0,
|
|
|
|
|
"green", 1.0 / 256.0,
|
|
|
|
|
"blue", 1.0 / 256.0,
|
|
|
|
|
"linear", FALSE,
|
|
|
|
|
"gaussian", FALSE,
|
2017-01-22 13:03:55 -08:00
|
|
|
NULL);
|
|
|
|
|
|
|
|
|
|
if (dither)
|
|
|
|
|
{
|
app: use GimpObjectQueue in lots of places
Use GimpObjectQueue, added in the previous commit, in various
instances where we perform an action on a set of objects. This
improves progress reporting, by using a single progress for the
entire operation, rather than reporting the progress of each object
individually, and by taking the relative cost of each object into
account, instead of assuming a uniform cost for all objects.
In particular, this affects the various whole-image operations
(i.e., transformations and color conversions), operations on linked
items, and operations on layer groups. This also affects layers
with masks, whose progress is now reported together instead of
individually.
Additionally, this commit fixes erroneous group-layer mask cropping
during undo when resizing the image, by properly calling
{start,end}_move() on all the resized layers before starting the
operation, and when scaling the image, by only scaling top-level
layers, and letting group layers scale their children themselves.
2018-03-25 07:18:46 -07:00
|
|
|
GimpObjectQueue *queue;
|
2018-03-29 00:01:23 -07:00
|
|
|
GimpProgress *sub_progress;
|
app: use GimpObjectQueue in lots of places
Use GimpObjectQueue, added in the previous commit, in various
instances where we perform an action on a set of objects. This
improves progress reporting, by using a single progress for the
entire operation, rather than reporting the progress of each object
individually, and by taking the relative cost of each object into
account, instead of assuming a uniform cost for all objects.
In particular, this affects the various whole-image operations
(i.e., transformations and color conversions), operations on linked
items, and operations on layer groups. This also affects layers
with masks, whose progress is now reported together instead of
individually.
Additionally, this commit fixes erroneous group-layer mask cropping
during undo when resizing the image, by properly calling
{start,end}_move() on all the resized layers before starting the
operation, and when scaling the image, by only scaling top-level
layers, and letting group layers scale their children themselves.
2018-03-25 07:18:46 -07:00
|
|
|
GList *layers;
|
|
|
|
|
GList *list;
|
|
|
|
|
GimpDrawable *drawable;
|
|
|
|
|
|
|
|
|
|
if (progress)
|
|
|
|
|
gimp_progress_start (progress, FALSE, "%s", _("Dithering"));
|
2017-01-22 13:03:55 -08:00
|
|
|
|
2018-03-29 00:01:23 -07:00
|
|
|
queue = gimp_object_queue_new (progress);
|
|
|
|
|
sub_progress = GIMP_PROGRESS (queue);
|
2017-01-22 13:03:55 -08:00
|
|
|
|
app: use GimpObjectQueue in lots of places
Use GimpObjectQueue, added in the previous commit, in various
instances where we perform an action on a set of objects. This
improves progress reporting, by using a single progress for the
entire operation, rather than reporting the progress of each object
individually, and by taking the relative cost of each object into
account, instead of assuming a uniform cost for all objects.
In particular, this affects the various whole-image operations
(i.e., transformations and color conversions), operations on linked
items, and operations on layer groups. This also affects layers
with masks, whose progress is now reported together instead of
individually.
Additionally, this commit fixes erroneous group-layer mask cropping
during undo when resizing the image, by properly calling
{start,end}_move() on all the resized layers before starting the
operation, and when scaling the image, by only scaling top-level
layers, and letting group layers scale their children themselves.
2018-03-25 07:18:46 -07:00
|
|
|
layers = gimp_image_get_layer_list (image);
|
|
|
|
|
|
|
|
|
|
for (list = layers; list; list = g_list_next (list))
|
2017-01-22 13:03:55 -08:00
|
|
|
{
|
|
|
|
|
if (! gimp_viewable_get_children (list->data) &&
|
|
|
|
|
! gimp_item_is_text_layer (list->data))
|
|
|
|
|
{
|
app: use GimpObjectQueue in lots of places
Use GimpObjectQueue, added in the previous commit, in various
instances where we perform an action on a set of objects. This
improves progress reporting, by using a single progress for the
entire operation, rather than reporting the progress of each object
individually, and by taking the relative cost of each object into
account, instead of assuming a uniform cost for all objects.
In particular, this affects the various whole-image operations
(i.e., transformations and color conversions), operations on linked
items, and operations on layer groups. This also affects layers
with masks, whose progress is now reported together instead of
individually.
Additionally, this commit fixes erroneous group-layer mask cropping
during undo when resizing the image, by properly calling
{start,end}_move() on all the resized layers before starting the
operation, and when scaling the image, by only scaling top-level
layers, and letting group layers scale their children themselves.
2018-03-25 07:18:46 -07:00
|
|
|
gimp_object_queue_push (queue, list->data);
|
2017-01-22 13:03:55 -08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
app: use GimpObjectQueue in lots of places
Use GimpObjectQueue, added in the previous commit, in various
instances where we perform an action on a set of objects. This
improves progress reporting, by using a single progress for the
entire operation, rather than reporting the progress of each object
individually, and by taking the relative cost of each object into
account, instead of assuming a uniform cost for all objects.
In particular, this affects the various whole-image operations
(i.e., transformations and color conversions), operations on linked
items, and operations on layer groups. This also affects layers
with masks, whose progress is now reported together instead of
individually.
Additionally, this commit fixes erroneous group-layer mask cropping
during undo when resizing the image, by properly calling
{start,end}_move() on all the resized layers before starting the
operation, and when scaling the image, by only scaling top-level
layers, and letting group layers scale their children themselves.
2018-03-25 07:18:46 -07:00
|
|
|
g_list_free (layers);
|
2017-01-22 13:03:55 -08:00
|
|
|
|
app: use GimpObjectQueue in lots of places
Use GimpObjectQueue, added in the previous commit, in various
instances where we perform an action on a set of objects. This
improves progress reporting, by using a single progress for the
entire operation, rather than reporting the progress of each object
individually, and by taking the relative cost of each object into
account, instead of assuming a uniform cost for all objects.
In particular, this affects the various whole-image operations
(i.e., transformations and color conversions), operations on linked
items, and operations on layer groups. This also affects layers
with masks, whose progress is now reported together instead of
individually.
Additionally, this commit fixes erroneous group-layer mask cropping
during undo when resizing the image, by properly calling
{start,end}_move() on all the resized layers before starting the
operation, and when scaling the image, by only scaling top-level
layers, and letting group layers scale their children themselves.
2018-03-25 07:18:46 -07:00
|
|
|
while ((drawable = gimp_object_queue_pop (queue)))
|
2017-01-22 13:03:55 -08:00
|
|
|
{
|
2018-03-29 00:01:23 -07:00
|
|
|
gimp_drawable_apply_operation (drawable, sub_progress,
|
app: use GimpObjectQueue in lots of places
Use GimpObjectQueue, added in the previous commit, in various
instances where we perform an action on a set of objects. This
improves progress reporting, by using a single progress for the
entire operation, rather than reporting the progress of each object
individually, and by taking the relative cost of each object into
account, instead of assuming a uniform cost for all objects.
In particular, this affects the various whole-image operations
(i.e., transformations and color conversions), operations on linked
items, and operations on layer groups. This also affects layers
with masks, whose progress is now reported together instead of
individually.
Additionally, this commit fixes erroneous group-layer mask cropping
during undo when resizing the image, by properly calling
{start,end}_move() on all the resized layers before starting the
operation, and when scaling the image, by only scaling top-level
layers, and letting group layers scale their children themselves.
2018-03-25 07:18:46 -07:00
|
|
|
_("Dithering"),
|
|
|
|
|
dither);
|
2017-01-22 13:03:55 -08:00
|
|
|
}
|
|
|
|
|
|
app: use GimpObjectQueue in lots of places
Use GimpObjectQueue, added in the previous commit, in various
instances where we perform an action on a set of objects. This
improves progress reporting, by using a single progress for the
entire operation, rather than reporting the progress of each object
individually, and by taking the relative cost of each object into
account, instead of assuming a uniform cost for all objects.
In particular, this affects the various whole-image operations
(i.e., transformations and color conversions), operations on linked
items, and operations on layer groups. This also affects layers
with masks, whose progress is now reported together instead of
individually.
Additionally, this commit fixes erroneous group-layer mask cropping
during undo when resizing the image, by properly calling
{start,end}_move() on all the resized layers before starting the
operation, and when scaling the image, by only scaling top-level
layers, and letting group layers scale their children themselves.
2018-03-25 07:18:46 -07:00
|
|
|
g_object_unref (queue);
|
2017-01-22 13:03:55 -08:00
|
|
|
|
2018-03-29 00:01:23 -07:00
|
|
|
if (progress)
|
|
|
|
|
gimp_progress_end (progress);
|
|
|
|
|
|
2017-01-22 13:03:55 -08:00
|
|
|
g_object_unref (dither);
|
|
|
|
|
}
|
|
|
|
|
}
|