2006-12-09 13:33:38 -08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
2001-06-26 05:09:43 -07:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
|
*
|
2009-01-17 14:28:01 -08:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
2001-06-26 05:09:43 -07:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-17 14:28:01 -08:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2001-06-26 05:09:43 -07:00
|
|
|
* (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/>.
|
2001-06-26 05:09:43 -07:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
2008-10-09 13:24:04 -07:00
|
|
|
#include <gegl.h>
|
2001-06-26 05:09:43 -07:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
2016-09-26 13:44:34 -07:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
2016-05-06 18:01:18 -07:00
|
|
|
#include "libgimpcolor/gimpcolor.h"
|
2001-06-26 05:09:43 -07:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
|
2004-04-20 06:25:55 -07:00
|
|
|
#include "actions-types.h"
|
2001-06-26 05:09:43 -07:00
|
|
|
|
2016-09-24 03:33:42 -07:00
|
|
|
#include "config/gimpdialogconfig.h"
|
2006-10-14 09:51:30 -07:00
|
|
|
|
2013-06-23 08:15:30 -07:00
|
|
|
#include "gegl/gimp-babl.h"
|
|
|
|
|
|
2003-12-08 13:56:22 -08:00
|
|
|
#include "core/core-enums.h"
|
2001-08-14 07:53:55 -07:00
|
|
|
#include "core/gimp.h"
|
2001-10-17 04:33:43 -07:00
|
|
|
#include "core/gimpcontext.h"
|
2001-06-26 05:09:43 -07:00
|
|
|
#include "core/gimpimage.h"
|
2015-08-02 13:18:43 -07:00
|
|
|
#include "core/gimpimage-color-profile.h"
|
2016-09-27 06:43:25 -07:00
|
|
|
#include "core/gimpimage-convert-indexed.h"
|
2012-04-29 07:22:20 -07:00
|
|
|
#include "core/gimpimage-convert-precision.h"
|
2012-06-26 05:38:33 -07:00
|
|
|
#include "core/gimpimage-convert-type.h"
|
2002-03-15 07:09:58 -08:00
|
|
|
#include "core/gimpimage-crop.h"
|
2001-06-26 05:09:43 -07:00
|
|
|
#include "core/gimpimage-duplicate.h"
|
2003-05-18 11:48:36 -07:00
|
|
|
#include "core/gimpimage-flip.h"
|
2002-02-13 06:41:35 -08:00
|
|
|
#include "core/gimpimage-merge.h"
|
include the new "paint-funcs/paint-funcs-types.h".
2001-11-28 Michael Natterer <mitch@gimp.org>
* app/base/base-types.h: include the new
"paint-funcs/paint-funcs-types.h".
* app/paint-funcs/Makefile.am
* app/paint-funcs/paint-funcs-types.h: new file. Includes
"base/base-types.h".
* app/paint-funcs/paint-funcs.[ch]: removed the enums here,
include "paint-funcs-types.h".
* app/widgets/widgets-types.h: include "display/display-types.h"
* app/display/display-types.h: include "widgets/widgets-types.h".
* app/tools/tools-types.h: include "display/display-types.h"
* app/gui/gui-types.h: include "tools/tools-types.h".
The order of namespaces/dependencies should be (but is not):
(base, paint-funcs) -> (core, file, xcf, pdb) ->
(widgets, display) -> tools -> gui
* app/path.c: include "tools/tools-types.h".
* app/core/Makefile.am
* app/core/gimpimage-guides.[ch]
* app/core/gimpimage-merge.[ch]
* app/core/gimpimage-resize.[ch]
* app/core/gimpimage-scale.[ch]: new files.
* app/core/gimpimage.[ch]: removed the stuff which is in the new
files. Reordered all functions in both the .h and .c files,
commented the groups of functions.
* app/core/gimpcontainer.c: create the handler_id using a counter,
not the address of a pointer, because the address *may* be the
same twice, added debugging output.
* app/core/gimpviewable.[ch]: added primitive support for getting
a preview GdkPixbuf.
* app/nav_window.c
* app/undo.c
* app/undo_history.c
* app/core/gimpimage-duplicate.c
* app/core/gimpimage-mask.[ch]
* app/display/gimpdisplay.c
* app/display/gimpdisplayshell-callbacks.c
* app/display/gimpdisplayshell-dnd.c
* app/display/gimpdisplayshell-render.c
* app/display/gimpdisplayshell-scale.c
* app/display/gimpdisplayshell-scroll.c
* app/gui/image-commands.c
* app/gui/info-window.c
* app/gui/layers-commands.c
* app/gui/palette-import-dialog.c
* app/tools/gimpbycolorselecttool.c
* app/tools/gimpeditselectiontool.c
* app/tools/gimpmeasuretool.c
* app/tools/gimpmovetool.c
* app/widgets/gimpcontainerview-utils.c
* app/xcf/xcf-load.c: changed accordingly, some cleanup.
* tools/pdbgen/pdb/guides.pdb
* tools/pdbgen/pdb/image.pdb: changed accordingly, reordered functions.
* app/plug_in.c: set the labels of the "Repeat" and "Re-Show" menu
items to the name of the last plug-in (Fixes #50986).
* app/display/gimpdisplayshell.[ch]: set the labels of "Undo" and
"Redo" to the resp. undo names. Much simplified the WM icon stuff
by removing most code and using gimp_viewable_get_new_preview_pixbuf().
* app/widgets/gimpbrushfactoryview.c: forgot to assign the GQuark
returned by gimp_container_add_handler().
* app/pdb/guides_cmds.c
* app/pdb/image_cmds.c
* libgimp/gimpimage_pdb.[ch]: regenerated.
2001-11-28 09:51:06 -08:00
|
|
|
#include "core/gimpimage-resize.h"
|
2003-05-20 03:36:29 -07:00
|
|
|
#include "core/gimpimage-rotate.h"
|
include the new "paint-funcs/paint-funcs-types.h".
2001-11-28 Michael Natterer <mitch@gimp.org>
* app/base/base-types.h: include the new
"paint-funcs/paint-funcs-types.h".
* app/paint-funcs/Makefile.am
* app/paint-funcs/paint-funcs-types.h: new file. Includes
"base/base-types.h".
* app/paint-funcs/paint-funcs.[ch]: removed the enums here,
include "paint-funcs-types.h".
* app/widgets/widgets-types.h: include "display/display-types.h"
* app/display/display-types.h: include "widgets/widgets-types.h".
* app/tools/tools-types.h: include "display/display-types.h"
* app/gui/gui-types.h: include "tools/tools-types.h".
The order of namespaces/dependencies should be (but is not):
(base, paint-funcs) -> (core, file, xcf, pdb) ->
(widgets, display) -> tools -> gui
* app/path.c: include "tools/tools-types.h".
* app/core/Makefile.am
* app/core/gimpimage-guides.[ch]
* app/core/gimpimage-merge.[ch]
* app/core/gimpimage-resize.[ch]
* app/core/gimpimage-scale.[ch]: new files.
* app/core/gimpimage.[ch]: removed the stuff which is in the new
files. Reordered all functions in both the .h and .c files,
commented the groups of functions.
* app/core/gimpcontainer.c: create the handler_id using a counter,
not the address of a pointer, because the address *may* be the
same twice, added debugging output.
* app/core/gimpviewable.[ch]: added primitive support for getting
a preview GdkPixbuf.
* app/nav_window.c
* app/undo.c
* app/undo_history.c
* app/core/gimpimage-duplicate.c
* app/core/gimpimage-mask.[ch]
* app/display/gimpdisplay.c
* app/display/gimpdisplayshell-callbacks.c
* app/display/gimpdisplayshell-dnd.c
* app/display/gimpdisplayshell-render.c
* app/display/gimpdisplayshell-scale.c
* app/display/gimpdisplayshell-scroll.c
* app/gui/image-commands.c
* app/gui/info-window.c
* app/gui/layers-commands.c
* app/gui/palette-import-dialog.c
* app/tools/gimpbycolorselecttool.c
* app/tools/gimpeditselectiontool.c
* app/tools/gimpmeasuretool.c
* app/tools/gimpmovetool.c
* app/widgets/gimpcontainerview-utils.c
* app/xcf/xcf-load.c: changed accordingly, some cleanup.
* tools/pdbgen/pdb/guides.pdb
* tools/pdbgen/pdb/image.pdb: changed accordingly, reordered functions.
* app/plug_in.c: set the labels of the "Repeat" and "Re-Show" menu
items to the name of the last plug-in (Fixes #50986).
* app/display/gimpdisplayshell.[ch]: set the labels of "Undo" and
"Redo" to the resp. undo names. Much simplified the WM icon stuff
by removing most code and using gimp_viewable_get_new_preview_pixbuf().
* app/widgets/gimpbrushfactoryview.c: forgot to assign the GQuark
returned by gimp_container_add_handler().
* app/pdb/guides_cmds.c
* app/pdb/image_cmds.c
* libgimp/gimpimage_pdb.[ch]: regenerated.
2001-11-28 09:51:06 -08:00
|
|
|
#include "core/gimpimage-scale.h"
|
2003-02-13 03:23:50 -08:00
|
|
|
#include "core/gimpimage-undo.h"
|
2015-07-01 06:19:03 -07:00
|
|
|
#include "core/gimpitem.h"
|
2012-09-22 11:35:36 -07:00
|
|
|
#include "core/gimppickable.h"
|
|
|
|
|
#include "core/gimppickable-auto-shrink.h"
|
2004-08-10 11:47:21 -07:00
|
|
|
#include "core/gimpprogress.h"
|
2001-06-26 05:09:43 -07:00
|
|
|
|
2004-05-25 05:02:54 -07:00
|
|
|
#include "widgets/gimpdialogfactory.h"
|
2004-01-31 12:23:53 -08:00
|
|
|
#include "widgets/gimpdock.h"
|
2004-10-27 03:33:08 -07:00
|
|
|
#include "widgets/gimphelp-ids.h"
|
2014-05-01 18:01:23 -07:00
|
|
|
#include "widgets/gimpwidgets-utils.h"
|
2002-08-30 14:00:42 -07:00
|
|
|
|
2001-09-25 16:23:09 -07:00
|
|
|
#include "display/gimpdisplay.h"
|
2002-06-26 15:16:59 -07:00
|
|
|
#include "display/gimpdisplayshell.h"
|
2001-09-25 16:23:09 -07:00
|
|
|
|
2016-09-11 15:03:22 -07:00
|
|
|
#include "dialogs/dialogs.h"
|
2015-08-02 13:20:16 -07:00
|
|
|
#include "dialogs/color-profile-dialog.h"
|
2016-04-30 09:49:02 -07:00
|
|
|
#include "dialogs/convert-indexed-dialog.h"
|
2012-09-23 14:46:11 -07:00
|
|
|
#include "dialogs/convert-precision-dialog.h"
|
2004-09-13 08:15:23 -07:00
|
|
|
#include "dialogs/grid-dialog.h"
|
2004-10-23 09:42:37 -07:00
|
|
|
#include "dialogs/image-merge-layers-dialog.h"
|
2004-09-13 08:15:23 -07:00
|
|
|
#include "dialogs/image-new-dialog.h"
|
2005-04-04 15:34:29 -07:00
|
|
|
#include "dialogs/image-properties-dialog.h"
|
2004-10-26 18:20:07 -07:00
|
|
|
#include "dialogs/image-scale-dialog.h"
|
2004-11-13 14:27:39 -08:00
|
|
|
#include "dialogs/print-size-dialog.h"
|
2004-09-13 08:15:23 -07:00
|
|
|
#include "dialogs/resize-dialog.h"
|
2004-04-20 06:25:55 -07:00
|
|
|
|
2004-05-03 07:03:51 -07:00
|
|
|
#include "actions.h"
|
2002-02-13 06:41:35 -08:00
|
|
|
#include "image-commands.h"
|
2001-06-26 05:09:43 -07:00
|
|
|
|
2003-03-25 08:38:19 -08:00
|
|
|
#include "gimp-intl.h"
|
2001-06-26 05:09:43 -07:00
|
|
|
|
|
|
|
|
|
2004-05-03 07:46:29 -07:00
|
|
|
/* local function prototypes */
|
2001-06-26 05:09:43 -07:00
|
|
|
|
2016-09-29 13:43:37 -07:00
|
|
|
static void image_convert_rgb_callback (GtkWidget *dialog,
|
|
|
|
|
GimpImage *image,
|
2016-09-29 14:06:46 -07:00
|
|
|
GimpColorProfile *new_profile,
|
|
|
|
|
GFile *new_file,
|
2016-09-29 13:43:37 -07:00
|
|
|
GimpColorRenderingIntent intent,
|
|
|
|
|
gboolean bpc,
|
|
|
|
|
gpointer user_data);
|
|
|
|
|
|
|
|
|
|
static void image_convert_gray_callback (GtkWidget *dialog,
|
|
|
|
|
GimpImage *image,
|
2016-09-29 14:06:46 -07:00
|
|
|
GimpColorProfile *new_profile,
|
|
|
|
|
GFile *new_file,
|
2016-09-29 13:43:37 -07:00
|
|
|
GimpColorRenderingIntent intent,
|
|
|
|
|
gboolean bpc,
|
|
|
|
|
gpointer user_data);
|
|
|
|
|
|
2016-09-27 06:43:25 -07:00
|
|
|
static void image_convert_indexed_callback (GtkWidget *dialog,
|
|
|
|
|
GimpImage *image,
|
2016-09-27 14:51:33 -07:00
|
|
|
GimpConvertPaletteType palette_type,
|
|
|
|
|
gint max_colors,
|
|
|
|
|
gboolean remove_duplicates,
|
2016-09-27 06:43:25 -07:00
|
|
|
GimpConvertDitherType dither_type,
|
2016-09-27 13:47:06 -07:00
|
|
|
gboolean dither_alpha,
|
|
|
|
|
gboolean dither_text_layers,
|
2016-09-27 06:43:25 -07:00
|
|
|
GimpPalette *custom_palette,
|
|
|
|
|
gpointer user_data);
|
|
|
|
|
|
2016-09-26 13:44:34 -07:00
|
|
|
static void image_convert_precision_callback (GtkWidget *dialog,
|
|
|
|
|
GimpImage *image,
|
|
|
|
|
GimpPrecision precision,
|
|
|
|
|
GeglDitherMethod layer_dither_method,
|
|
|
|
|
GeglDitherMethod text_layer_dither_method,
|
|
|
|
|
GeglDitherMethod mask_dither_method,
|
|
|
|
|
gpointer user_data);
|
|
|
|
|
|
2016-09-29 13:43:37 -07:00
|
|
|
static void image_profile_assign_callback (GtkWidget *dialog,
|
|
|
|
|
GimpImage *image,
|
2016-09-29 14:06:46 -07:00
|
|
|
GimpColorProfile *new_profile,
|
|
|
|
|
GFile *new_file,
|
2016-09-29 13:43:37 -07:00
|
|
|
GimpColorRenderingIntent intent,
|
|
|
|
|
gboolean bpc,
|
|
|
|
|
gpointer user_data);
|
|
|
|
|
|
|
|
|
|
static void image_profile_convert_callback (GtkWidget *dialog,
|
|
|
|
|
GimpImage *image,
|
2016-09-29 14:06:46 -07:00
|
|
|
GimpColorProfile *new_profile,
|
|
|
|
|
GFile *new_file,
|
2016-09-29 13:43:37 -07:00
|
|
|
GimpColorRenderingIntent intent,
|
|
|
|
|
gboolean bpc,
|
|
|
|
|
gpointer user_data);
|
|
|
|
|
|
2016-09-26 13:44:34 -07:00
|
|
|
static void image_resize_callback (GtkWidget *dialog,
|
|
|
|
|
GimpViewable *viewable,
|
|
|
|
|
GimpContext *context,
|
|
|
|
|
gint width,
|
|
|
|
|
gint height,
|
|
|
|
|
GimpUnit unit,
|
|
|
|
|
gint offset_x,
|
|
|
|
|
gint offset_y,
|
2016-10-19 15:30:10 -07:00
|
|
|
GimpFillType fill_type,
|
2016-09-26 13:44:34 -07:00
|
|
|
GimpItemSet layer_set,
|
|
|
|
|
gboolean resize_text_layers,
|
|
|
|
|
gpointer user_data);
|
|
|
|
|
|
|
|
|
|
static void image_print_size_callback (GtkWidget *dialog,
|
|
|
|
|
GimpImage *image,
|
|
|
|
|
gdouble xresolution,
|
|
|
|
|
gdouble yresolution,
|
|
|
|
|
GimpUnit resolution_unit,
|
|
|
|
|
gpointer user_data);
|
|
|
|
|
|
|
|
|
|
static void image_scale_callback (GtkWidget *dialog,
|
|
|
|
|
GimpViewable *viewable,
|
|
|
|
|
gint width,
|
|
|
|
|
gint height,
|
|
|
|
|
GimpUnit unit,
|
|
|
|
|
GimpInterpolationType interpolation,
|
|
|
|
|
gdouble xresolution,
|
|
|
|
|
gdouble yresolution,
|
|
|
|
|
GimpUnit resolution_unit,
|
|
|
|
|
gpointer user_data);
|
|
|
|
|
|
|
|
|
|
static void image_merge_layers_callback (GtkWidget *dialog,
|
|
|
|
|
GimpImage *image,
|
|
|
|
|
GimpContext *context,
|
|
|
|
|
GimpMergeType merge_type,
|
|
|
|
|
gboolean merge_active_group,
|
app: merge layers in chunks, and show progress
In gimp_image_merge_layers() -- the internal function used by the
various layer-merging/flattenning functions -- process the merged-
layer graph in chunks, using gimp_gegl_apply_operation(), instead
of in one go, using gegl_node_blit_buffer(). Processing in chunks
better utilizes the cache, since it reduces the size of
intermediate buffers, reducing the chances of hitting the swap when
merging large images (see, for example, issue #3012.)
Additionally, this allows us to show progress indication. Have the
relevant gimpimage-merge functions take a GimpProgress, and pass it
down to gimp_image_merge_layers(). Adapt all callers.
(cherry picked from commit e83d8ac4f2dc0260e97a91938ae3e34608efdbf9)
2019-02-25 01:49:04 -08:00
|
|
|
gboolean discard_invisible,
|
|
|
|
|
gpointer user_data);
|
2001-06-26 05:09:43 -07:00
|
|
|
|
|
|
|
|
|
2004-10-23 12:13:17 -07:00
|
|
|
/* private variables */
|
|
|
|
|
|
2016-09-27 15:31:59 -07:00
|
|
|
static GimpUnit image_resize_unit = GIMP_UNIT_PIXEL;
|
|
|
|
|
static GimpUnit image_scale_unit = GIMP_UNIT_PIXEL;
|
|
|
|
|
static GimpInterpolationType image_scale_interp = -1;
|
|
|
|
|
static GimpPalette *image_convert_indexed_custom_palette = NULL;
|
|
|
|
|
|
2016-09-27 06:43:25 -07:00
|
|
|
|
2001-06-26 05:09:43 -07:00
|
|
|
/* public functions */
|
|
|
|
|
|
2004-05-25 05:02:54 -07:00
|
|
|
void
|
|
|
|
|
image_new_cmd_callback (GtkAction *action,
|
|
|
|
|
gpointer data)
|
|
|
|
|
{
|
|
|
|
|
GtkWidget *widget;
|
|
|
|
|
GtkWidget *dialog;
|
|
|
|
|
return_if_no_widget (widget, data);
|
|
|
|
|
|
2010-02-28 14:20:57 -08:00
|
|
|
dialog = gimp_dialog_factory_dialog_new (gimp_dialog_factory_get_singleton (),
|
2004-05-25 05:02:54 -07:00
|
|
|
gtk_widget_get_screen (widget),
|
2014-05-01 18:01:23 -07:00
|
|
|
gimp_widget_get_monitor (widget),
|
2010-05-16 03:19:18 -07:00
|
|
|
NULL /*ui_manager*/,
|
2004-09-13 08:15:23 -07:00
|
|
|
"gimp-image-new-dialog", -1, FALSE);
|
2004-05-25 05:02:54 -07:00
|
|
|
|
|
|
|
|
if (dialog)
|
|
|
|
|
{
|
2006-03-28 09:08:36 -08:00
|
|
|
GimpImage *image = action_data_get_image (data);
|
2004-05-25 05:02:54 -07:00
|
|
|
|
2006-03-28 09:08:36 -08:00
|
|
|
image_new_dialog_set (dialog, image, NULL);
|
2004-08-31 15:41:15 -07:00
|
|
|
|
|
|
|
|
gtk_window_present (GTK_WINDOW (dialog));
|
2004-05-25 05:02:54 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-08 10:32:57 -07:00
|
|
|
void
|
|
|
|
|
image_duplicate_cmd_callback (GtkAction *action,
|
|
|
|
|
gpointer data)
|
|
|
|
|
{
|
|
|
|
|
GimpDisplay *display;
|
|
|
|
|
GimpImage *image;
|
|
|
|
|
GimpDisplayShell *shell;
|
|
|
|
|
GimpImage *new_image;
|
|
|
|
|
return_if_no_display (display, data);
|
|
|
|
|
|
|
|
|
|
image = gimp_display_get_image (display);
|
|
|
|
|
shell = gimp_display_get_shell (display);
|
|
|
|
|
|
|
|
|
|
new_image = gimp_image_duplicate (image);
|
|
|
|
|
|
|
|
|
|
gimp_create_display (new_image->gimp, new_image, shell->unit,
|
|
|
|
|
gimp_zoom_model_get_factor (shell->zoom),
|
|
|
|
|
G_OBJECT (gtk_widget_get_screen (GTK_WIDGET (shell))),
|
|
|
|
|
gimp_widget_get_monitor (GTK_WIDGET (shell)));
|
|
|
|
|
|
|
|
|
|
g_object_unref (new_image);
|
|
|
|
|
}
|
|
|
|
|
|
2001-06-26 05:09:43 -07:00
|
|
|
void
|
2012-04-25 07:46:58 -07:00
|
|
|
image_convert_base_type_cmd_callback (GtkAction *action,
|
|
|
|
|
GtkAction *current,
|
|
|
|
|
gpointer data)
|
2001-06-26 05:09:43 -07:00
|
|
|
{
|
2006-06-14 07:36:34 -07:00
|
|
|
GimpImage *image;
|
|
|
|
|
GimpDisplay *display;
|
2014-06-15 13:10:06 -07:00
|
|
|
GtkWidget *widget;
|
2016-09-27 15:31:59 -07:00
|
|
|
GimpDialogConfig *config;
|
2014-06-15 13:10:06 -07:00
|
|
|
GtkWidget *dialog;
|
2006-06-14 07:36:34 -07:00
|
|
|
GimpImageBaseType value;
|
2007-12-06 11:51:02 -08:00
|
|
|
GError *error = NULL;
|
2006-03-28 09:08:36 -08:00
|
|
|
return_if_no_image (image, data);
|
2006-03-28 09:55:52 -08:00
|
|
|
return_if_no_display (display, data);
|
2014-06-15 13:10:06 -07:00
|
|
|
return_if_no_widget (widget, data);
|
2001-06-26 05:09:43 -07:00
|
|
|
|
2006-06-14 07:36:34 -07:00
|
|
|
value = gtk_radio_action_get_current_value (GTK_RADIO_ACTION (action));
|
|
|
|
|
|
2012-05-07 12:57:33 -07:00
|
|
|
if (value == gimp_image_get_base_type (image))
|
2006-06-14 07:36:34 -07:00
|
|
|
return;
|
|
|
|
|
|
2016-09-11 15:03:22 -07:00
|
|
|
#define CONVERT_TYPE_DIALOG_KEY "gimp-convert-type-dialog"
|
|
|
|
|
|
|
|
|
|
dialog = dialogs_get_dialog (G_OBJECT (image), CONVERT_TYPE_DIALOG_KEY);
|
2014-06-15 13:10:06 -07:00
|
|
|
|
2016-04-30 09:34:15 -07:00
|
|
|
if (dialog)
|
|
|
|
|
{
|
|
|
|
|
gtk_widget_destroy (dialog);
|
|
|
|
|
dialog = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-27 15:31:59 -07:00
|
|
|
config = GIMP_DIALOG_CONFIG (image->gimp->config);
|
|
|
|
|
|
2006-06-14 07:36:34 -07:00
|
|
|
switch (value)
|
2004-06-10 07:25:04 -07:00
|
|
|
{
|
|
|
|
|
case GIMP_RGB:
|
|
|
|
|
case GIMP_GRAY:
|
2016-04-30 09:34:15 -07:00
|
|
|
if (gimp_image_get_color_profile (image))
|
|
|
|
|
{
|
2016-09-29 13:43:37 -07:00
|
|
|
ColorProfileDialogType dialog_type;
|
|
|
|
|
GimpColorProfileCallback callback;
|
|
|
|
|
GimpColorProfile *current_profile;
|
|
|
|
|
GimpColorProfile *default_profile;
|
|
|
|
|
const Babl *format;
|
|
|
|
|
|
|
|
|
|
current_profile =
|
|
|
|
|
gimp_color_managed_get_color_profile (GIMP_COLOR_MANAGED (image));
|
2016-04-30 09:34:15 -07:00
|
|
|
|
|
|
|
|
if (value == GIMP_RGB)
|
2016-09-29 13:43:37 -07:00
|
|
|
{
|
|
|
|
|
dialog_type = COLOR_PROFILE_DIALOG_CONVERT_TO_RGB;
|
|
|
|
|
callback = image_convert_rgb_callback;
|
|
|
|
|
|
|
|
|
|
format = gimp_babl_format (GIMP_RGB,
|
|
|
|
|
gimp_image_get_precision (image),
|
|
|
|
|
TRUE);
|
|
|
|
|
default_profile = gimp_babl_format_get_color_profile (format);
|
|
|
|
|
}
|
2016-04-30 09:34:15 -07:00
|
|
|
else
|
2016-09-29 13:43:37 -07:00
|
|
|
{
|
|
|
|
|
dialog_type = COLOR_PROFILE_DIALOG_CONVERT_TO_GRAY;
|
|
|
|
|
callback = image_convert_gray_callback;
|
|
|
|
|
|
|
|
|
|
format = gimp_babl_format (GIMP_GRAY,
|
|
|
|
|
gimp_image_get_precision (image),
|
|
|
|
|
TRUE);
|
|
|
|
|
default_profile = gimp_babl_format_get_color_profile (format);
|
|
|
|
|
}
|
2016-04-30 09:34:15 -07:00
|
|
|
|
|
|
|
|
dialog = color_profile_dialog_new (dialog_type,
|
|
|
|
|
image,
|
|
|
|
|
action_data_get_context (data),
|
|
|
|
|
widget,
|
2016-09-29 13:43:37 -07:00
|
|
|
current_profile,
|
|
|
|
|
default_profile,
|
|
|
|
|
0, 0,
|
|
|
|
|
callback,
|
|
|
|
|
display);
|
2016-04-30 09:34:15 -07:00
|
|
|
}
|
|
|
|
|
else if (! gimp_image_convert_type (image, value, NULL, NULL, &error))
|
2007-12-06 11:51:02 -08:00
|
|
|
{
|
2008-11-04 04:33:09 -08:00
|
|
|
gimp_message_literal (image->gimp,
|
2013-09-14 09:59:20 -07:00
|
|
|
G_OBJECT (widget), GIMP_MESSAGE_WARNING,
|
|
|
|
|
error->message);
|
2007-12-06 11:51:02 -08:00
|
|
|
g_clear_error (&error);
|
|
|
|
|
}
|
2004-06-10 07:25:04 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case GIMP_INDEXED:
|
2016-04-30 09:49:02 -07:00
|
|
|
dialog = convert_indexed_dialog_new (image,
|
|
|
|
|
action_data_get_context (data),
|
|
|
|
|
widget,
|
2016-09-27 15:31:59 -07:00
|
|
|
config->image_convert_indexed_palette_type,
|
|
|
|
|
config->image_convert_indexed_max_colors,
|
|
|
|
|
config->image_convert_indexed_remove_duplicates,
|
|
|
|
|
config->image_convert_indexed_dither_type,
|
|
|
|
|
config->image_convert_indexed_dither_alpha,
|
|
|
|
|
config->image_convert_indexed_dither_text_layers,
|
2016-09-27 06:43:25 -07:00
|
|
|
image_convert_indexed_custom_palette,
|
|
|
|
|
image_convert_indexed_callback,
|
|
|
|
|
display);
|
2016-04-30 09:34:15 -07:00
|
|
|
break;
|
|
|
|
|
}
|
2006-06-16 02:16:49 -07:00
|
|
|
|
2016-04-30 09:34:15 -07:00
|
|
|
if (dialog)
|
|
|
|
|
{
|
2016-09-11 15:03:22 -07:00
|
|
|
dialogs_attach_dialog (G_OBJECT (image),
|
|
|
|
|
CONVERT_TYPE_DIALOG_KEY, dialog);
|
2014-06-15 13:10:06 -07:00
|
|
|
gtk_window_present (GTK_WINDOW (dialog));
|
2004-06-10 07:25:04 -07:00
|
|
|
}
|
2006-06-16 02:16:49 -07:00
|
|
|
|
2016-09-25 13:18:37 -07:00
|
|
|
/* always flush, also when only the indexed dialog was shown, so
|
|
|
|
|
* the menu items get updated back to the current image type
|
2014-06-15 13:10:06 -07:00
|
|
|
*/
|
2006-06-16 02:16:49 -07:00
|
|
|
gimp_image_flush (image);
|
2001-06-26 05:09:43 -07:00
|
|
|
}
|
|
|
|
|
|
2012-04-25 07:46:58 -07:00
|
|
|
void
|
|
|
|
|
image_convert_precision_cmd_callback (GtkAction *action,
|
|
|
|
|
GtkAction *current,
|
|
|
|
|
gpointer data)
|
|
|
|
|
{
|
2015-11-22 14:19:49 -08:00
|
|
|
GimpImage *image;
|
|
|
|
|
GimpDisplay *display;
|
|
|
|
|
GtkWidget *widget;
|
2016-09-26 13:44:34 -07:00
|
|
|
GimpDialogConfig *config;
|
2015-11-22 14:19:49 -08:00
|
|
|
GtkWidget *dialog;
|
|
|
|
|
GimpComponentType value;
|
2012-04-25 07:46:58 -07:00
|
|
|
return_if_no_image (image, data);
|
|
|
|
|
return_if_no_display (display, data);
|
2014-06-15 13:19:33 -07:00
|
|
|
return_if_no_widget (widget, data);
|
2012-04-25 07:46:58 -07:00
|
|
|
|
|
|
|
|
value = gtk_radio_action_get_current_value (GTK_RADIO_ACTION (action));
|
|
|
|
|
|
2015-11-22 14:19:49 -08:00
|
|
|
if (value == gimp_image_get_component_type (image))
|
2012-04-25 07:46:58 -07:00
|
|
|
return;
|
|
|
|
|
|
2016-09-11 15:03:22 -07:00
|
|
|
#define CONVERT_PRECISION_DIALOG_KEY "gimp-convert-precision-dialog"
|
|
|
|
|
|
|
|
|
|
dialog = dialogs_get_dialog (G_OBJECT (image), CONVERT_PRECISION_DIALOG_KEY);
|
2014-06-15 13:19:33 -07:00
|
|
|
|
2016-09-26 13:44:34 -07:00
|
|
|
if (dialog)
|
2012-09-23 14:46:11 -07:00
|
|
|
{
|
2016-09-26 13:44:34 -07:00
|
|
|
gtk_widget_destroy (dialog);
|
|
|
|
|
dialog = NULL;
|
2015-11-22 14:19:49 -08:00
|
|
|
}
|
2012-09-23 14:46:11 -07:00
|
|
|
|
2016-09-26 13:44:34 -07:00
|
|
|
config = GIMP_DIALOG_CONFIG (image->gimp->config);
|
|
|
|
|
|
|
|
|
|
dialog = convert_precision_dialog_new (image,
|
|
|
|
|
action_data_get_context (data),
|
|
|
|
|
widget,
|
|
|
|
|
value,
|
|
|
|
|
config->image_convert_precision_layer_dither_method,
|
|
|
|
|
config->image_convert_precision_text_layer_dither_method,
|
|
|
|
|
config->image_convert_precision_channel_dither_method,
|
|
|
|
|
image_convert_precision_callback,
|
|
|
|
|
display);
|
|
|
|
|
|
|
|
|
|
dialogs_attach_dialog (G_OBJECT (image),
|
|
|
|
|
CONVERT_PRECISION_DIALOG_KEY, dialog);
|
|
|
|
|
|
2015-11-22 14:19:49 -08:00
|
|
|
gtk_window_present (GTK_WINDOW (dialog));
|
2012-09-23 14:46:11 -07:00
|
|
|
|
2015-11-22 14:19:49 -08:00
|
|
|
/* see comment above */
|
|
|
|
|
gimp_image_flush (image);
|
|
|
|
|
}
|
2012-09-23 14:46:11 -07:00
|
|
|
|
2015-11-22 14:19:49 -08:00
|
|
|
void
|
|
|
|
|
image_convert_gamma_cmd_callback (GtkAction *action,
|
|
|
|
|
GtkAction *current,
|
|
|
|
|
gpointer data)
|
|
|
|
|
{
|
|
|
|
|
GimpImage *image;
|
|
|
|
|
GimpDisplay *display;
|
|
|
|
|
gboolean value;
|
|
|
|
|
GimpPrecision precision;
|
|
|
|
|
return_if_no_image (image, data);
|
|
|
|
|
return_if_no_display (display, data);
|
2014-06-15 13:19:33 -07:00
|
|
|
|
2015-11-22 14:19:49 -08:00
|
|
|
value = gtk_radio_action_get_current_value (GTK_RADIO_ACTION (action));
|
2012-09-23 14:46:11 -07:00
|
|
|
|
2015-11-22 14:19:49 -08:00
|
|
|
if (value == gimp_babl_format_get_linear (gimp_image_get_layer_format (image,
|
|
|
|
|
FALSE)))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
precision = gimp_babl_precision (gimp_image_get_component_type (image),
|
|
|
|
|
value);
|
|
|
|
|
|
2016-11-07 11:41:39 -08:00
|
|
|
gimp_image_convert_precision (image, precision,
|
|
|
|
|
GEGL_DITHER_NONE,
|
|
|
|
|
GEGL_DITHER_NONE,
|
|
|
|
|
GEGL_DITHER_NONE,
|
2015-11-22 14:19:49 -08:00
|
|
|
GIMP_PROGRESS (display));
|
2012-04-25 07:46:58 -07:00
|
|
|
gimp_image_flush (image);
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-08 10:27:29 -07:00
|
|
|
void
|
|
|
|
|
image_color_management_enabled_cmd_callback (GtkAction *action,
|
|
|
|
|
gpointer data)
|
|
|
|
|
{
|
|
|
|
|
GimpImage *image;
|
|
|
|
|
gboolean enabled;
|
|
|
|
|
return_if_no_image (image, data);
|
|
|
|
|
|
|
|
|
|
enabled = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
|
|
|
|
|
|
|
|
|
|
if (enabled != gimp_image_get_is_color_managed (image))
|
|
|
|
|
{
|
|
|
|
|
gimp_image_set_is_color_managed (image, enabled, TRUE);
|
|
|
|
|
gimp_image_flush (image);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-15 11:19:32 -07:00
|
|
|
void
|
|
|
|
|
image_color_profile_assign_cmd_callback (GtkAction *action,
|
|
|
|
|
gpointer data)
|
|
|
|
|
{
|
2015-08-02 13:20:16 -07:00
|
|
|
GimpImage *image;
|
|
|
|
|
GimpDisplay *display;
|
|
|
|
|
GtkWidget *widget;
|
|
|
|
|
GtkWidget *dialog;
|
2015-06-15 11:19:32 -07:00
|
|
|
return_if_no_image (image, data);
|
2015-08-02 13:20:16 -07:00
|
|
|
return_if_no_display (display, data);
|
|
|
|
|
return_if_no_widget (widget, data);
|
2015-06-15 11:19:32 -07:00
|
|
|
|
2016-09-11 15:03:22 -07:00
|
|
|
#define PROFILE_ASSIGN_DIALOG_KEY "gimp-profile-assign-dialog"
|
|
|
|
|
|
|
|
|
|
dialog = dialogs_get_dialog (G_OBJECT (image), PROFILE_ASSIGN_DIALOG_KEY);
|
2015-08-02 13:20:16 -07:00
|
|
|
|
|
|
|
|
if (! dialog)
|
|
|
|
|
{
|
2016-09-29 13:43:37 -07:00
|
|
|
GimpColorProfile *current_profile;
|
|
|
|
|
GimpColorProfile *default_profile;
|
|
|
|
|
|
|
|
|
|
current_profile = gimp_color_managed_get_color_profile (GIMP_COLOR_MANAGED (image));
|
|
|
|
|
default_profile = gimp_image_get_builtin_color_profile (image);
|
|
|
|
|
|
2016-04-29 03:53:43 -07:00
|
|
|
dialog = color_profile_dialog_new (COLOR_PROFILE_DIALOG_ASSIGN_PROFILE,
|
|
|
|
|
image,
|
|
|
|
|
action_data_get_context (data),
|
|
|
|
|
widget,
|
2016-09-29 13:43:37 -07:00
|
|
|
current_profile,
|
|
|
|
|
default_profile,
|
|
|
|
|
0, 0,
|
|
|
|
|
image_profile_assign_callback,
|
|
|
|
|
display);
|
2015-08-02 13:20:16 -07:00
|
|
|
|
2016-09-11 15:03:22 -07:00
|
|
|
dialogs_attach_dialog (G_OBJECT (image),
|
|
|
|
|
PROFILE_ASSIGN_DIALOG_KEY, dialog);
|
2015-08-02 13:20:16 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gtk_window_present (GTK_WINDOW (dialog));
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-15 11:19:32 -07:00
|
|
|
void
|
|
|
|
|
image_color_profile_convert_cmd_callback (GtkAction *action,
|
|
|
|
|
gpointer data)
|
|
|
|
|
{
|
2015-08-02 13:20:16 -07:00
|
|
|
GimpImage *image;
|
|
|
|
|
GimpDisplay *display;
|
|
|
|
|
GtkWidget *widget;
|
|
|
|
|
GtkWidget *dialog;
|
2015-06-15 11:19:32 -07:00
|
|
|
return_if_no_image (image, data);
|
2015-08-02 13:20:16 -07:00
|
|
|
return_if_no_display (display, data);
|
|
|
|
|
return_if_no_widget (widget, data);
|
|
|
|
|
|
2016-09-11 15:03:22 -07:00
|
|
|
#define PROFILE_CONVERT_DIALOG_KEY "gimp-profile-convert-dialog"
|
|
|
|
|
|
|
|
|
|
dialog = dialogs_get_dialog (G_OBJECT (image), PROFILE_CONVERT_DIALOG_KEY);
|
2015-08-02 13:20:16 -07:00
|
|
|
|
|
|
|
|
if (! dialog)
|
|
|
|
|
{
|
2016-09-29 13:43:37 -07:00
|
|
|
GimpDialogConfig *config = GIMP_DIALOG_CONFIG (image->gimp->config);
|
|
|
|
|
GimpColorProfile *current_profile;
|
|
|
|
|
GimpColorProfile *default_profile;
|
|
|
|
|
|
|
|
|
|
current_profile = gimp_color_managed_get_color_profile (GIMP_COLOR_MANAGED (image));
|
|
|
|
|
default_profile = gimp_image_get_builtin_color_profile (image);
|
|
|
|
|
|
2016-04-29 03:53:43 -07:00
|
|
|
dialog = color_profile_dialog_new (COLOR_PROFILE_DIALOG_CONVERT_TO_PROFILE,
|
|
|
|
|
image,
|
|
|
|
|
action_data_get_context (data),
|
|
|
|
|
widget,
|
2016-09-29 13:43:37 -07:00
|
|
|
current_profile,
|
|
|
|
|
default_profile,
|
|
|
|
|
config->image_convert_profile_intent,
|
|
|
|
|
config->image_convert_profile_bpc,
|
|
|
|
|
image_profile_convert_callback,
|
|
|
|
|
display);
|
2015-08-02 13:20:16 -07:00
|
|
|
|
2016-09-11 15:03:22 -07:00
|
|
|
dialogs_attach_dialog (G_OBJECT (image),
|
|
|
|
|
PROFILE_CONVERT_DIALOG_KEY, dialog);
|
2015-08-02 13:20:16 -07:00
|
|
|
}
|
2015-06-15 11:19:32 -07:00
|
|
|
|
2015-08-02 13:20:16 -07:00
|
|
|
gtk_window_present (GTK_WINDOW (dialog));
|
2015-06-15 11:19:32 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
image_color_profile_discard_cmd_callback (GtkAction *action,
|
|
|
|
|
gpointer data)
|
|
|
|
|
{
|
|
|
|
|
GimpImage *image;
|
|
|
|
|
return_if_no_image (image, data);
|
|
|
|
|
|
|
|
|
|
gimp_image_set_color_profile (image, NULL, NULL);
|
|
|
|
|
gimp_image_flush (image);
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-06 18:01:18 -07:00
|
|
|
static void
|
|
|
|
|
image_profile_save_dialog_response (GtkWidget *dialog,
|
|
|
|
|
gint response_id,
|
|
|
|
|
GimpImage *image)
|
|
|
|
|
{
|
|
|
|
|
if (response_id == GTK_RESPONSE_ACCEPT)
|
|
|
|
|
{
|
|
|
|
|
GimpColorProfile *profile;
|
|
|
|
|
GFile *file;
|
|
|
|
|
GError *error = NULL;
|
|
|
|
|
|
|
|
|
|
profile = gimp_color_managed_get_color_profile (GIMP_COLOR_MANAGED (image));
|
|
|
|
|
file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (dialog));
|
|
|
|
|
|
|
|
|
|
if (! file)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (! gimp_color_profile_save_to_file (profile, file, &error))
|
|
|
|
|
{
|
|
|
|
|
gimp_message (image->gimp, NULL,
|
|
|
|
|
GIMP_MESSAGE_WARNING,
|
|
|
|
|
_("Saving color profile failed: %s"),
|
|
|
|
|
error->message);
|
|
|
|
|
g_clear_error (&error);
|
|
|
|
|
g_object_unref (file);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_object_unref (file);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gtk_widget_destroy (dialog);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
image_color_profile_save_cmd_callback (GtkAction *action,
|
|
|
|
|
gpointer data)
|
|
|
|
|
{
|
|
|
|
|
GimpImage *image;
|
|
|
|
|
GimpDisplay *display;
|
|
|
|
|
GtkWidget *widget;
|
|
|
|
|
GtkWidget *dialog;
|
|
|
|
|
return_if_no_image (image, data);
|
|
|
|
|
return_if_no_display (display, data);
|
|
|
|
|
return_if_no_widget (widget, data);
|
|
|
|
|
|
2016-09-11 15:03:22 -07:00
|
|
|
#define PROFILE_SAVE_DIALOG_KEY "gimp-profile-save-dialog"
|
|
|
|
|
|
|
|
|
|
dialog = dialogs_get_dialog (G_OBJECT (image), PROFILE_SAVE_DIALOG_KEY);
|
2016-05-06 18:01:18 -07:00
|
|
|
|
|
|
|
|
if (! dialog)
|
|
|
|
|
{
|
|
|
|
|
GtkWindow *toplevel;
|
|
|
|
|
GimpColorProfile *profile;
|
|
|
|
|
gchar *basename;
|
|
|
|
|
|
|
|
|
|
toplevel = GTK_WINDOW (gtk_widget_get_toplevel (widget));
|
|
|
|
|
profile = gimp_color_managed_get_color_profile (GIMP_COLOR_MANAGED (image));
|
|
|
|
|
|
|
|
|
|
dialog =
|
|
|
|
|
gimp_color_profile_chooser_dialog_new (_("Save Color Profile"),
|
|
|
|
|
toplevel,
|
|
|
|
|
GTK_FILE_CHOOSER_ACTION_SAVE);
|
|
|
|
|
|
2018-01-02 14:09:00 -08:00
|
|
|
gimp_color_profile_chooser_dialog_connect_path (dialog,
|
|
|
|
|
G_OBJECT (image->gimp->config),
|
|
|
|
|
"color-profile-path");
|
|
|
|
|
|
2016-05-06 18:01:18 -07:00
|
|
|
basename = g_strconcat (gimp_color_profile_get_label (profile),
|
|
|
|
|
".icc", NULL);
|
|
|
|
|
gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), basename);
|
|
|
|
|
g_free (basename);
|
|
|
|
|
|
|
|
|
|
g_signal_connect (dialog, "response",
|
|
|
|
|
G_CALLBACK (image_profile_save_dialog_response),
|
|
|
|
|
image);
|
|
|
|
|
|
2016-09-24 06:13:34 -07:00
|
|
|
dialogs_attach_dialog (G_OBJECT (image), PROFILE_SAVE_DIALOG_KEY, dialog);
|
2016-05-06 18:01:18 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gtk_window_present (GTK_WINDOW (dialog));
|
|
|
|
|
}
|
|
|
|
|
|
2001-06-26 05:09:43 -07:00
|
|
|
void
|
2004-04-29 05:52:29 -07:00
|
|
|
image_resize_cmd_callback (GtkAction *action,
|
2006-04-12 05:49:29 -07:00
|
|
|
gpointer data)
|
2001-06-26 05:09:43 -07:00
|
|
|
{
|
2016-09-24 06:07:04 -07:00
|
|
|
GimpImage *image;
|
|
|
|
|
GtkWidget *widget;
|
|
|
|
|
GimpDisplay *display;
|
|
|
|
|
GtkWidget *dialog;
|
2005-08-24 10:22:07 -07:00
|
|
|
return_if_no_image (image, data);
|
2004-10-27 03:33:08 -07:00
|
|
|
return_if_no_widget (widget, data);
|
2006-03-28 09:55:52 -08:00
|
|
|
return_if_no_display (display, data);
|
2001-06-26 05:09:43 -07:00
|
|
|
|
2016-09-24 06:10:19 -07:00
|
|
|
#define RESIZE_DIALOG_KEY "gimp-resize-dialog"
|
|
|
|
|
|
|
|
|
|
dialog = dialogs_get_dialog (G_OBJECT (image), RESIZE_DIALOG_KEY);
|
|
|
|
|
|
|
|
|
|
if (! dialog)
|
|
|
|
|
{
|
2016-10-19 15:30:10 -07:00
|
|
|
GimpDialogConfig *config = GIMP_DIALOG_CONFIG (image->gimp->config);
|
|
|
|
|
|
2016-09-24 06:10:19 -07:00
|
|
|
if (image_resize_unit != GIMP_UNIT_PERCENT)
|
|
|
|
|
image_resize_unit = gimp_display_get_shell (display)->unit;
|
|
|
|
|
|
|
|
|
|
dialog = resize_dialog_new (GIMP_VIEWABLE (image),
|
|
|
|
|
action_data_get_context (data),
|
2016-10-19 15:30:10 -07:00
|
|
|
_("Set Image Canvas Size"),
|
|
|
|
|
"gimp-image-resize",
|
2016-09-24 06:10:19 -07:00
|
|
|
widget,
|
2016-10-19 15:30:10 -07:00
|
|
|
gimp_standard_help_func,
|
|
|
|
|
GIMP_HELP_IMAGE_RESIZE,
|
2016-09-24 06:10:19 -07:00
|
|
|
image_resize_unit,
|
2016-10-19 15:30:10 -07:00
|
|
|
config->image_resize_fill_type,
|
|
|
|
|
config->image_resize_layer_set,
|
|
|
|
|
config->image_resize_resize_text_layers,
|
2016-09-24 06:10:19 -07:00
|
|
|
image_resize_callback,
|
|
|
|
|
display);
|
|
|
|
|
|
|
|
|
|
dialogs_attach_dialog (G_OBJECT (image), RESIZE_DIALOG_KEY, dialog);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gtk_window_present (GTK_WINDOW (dialog));
|
2001-06-26 05:09:43 -07:00
|
|
|
}
|
|
|
|
|
|
2004-09-04 15:08:43 -07:00
|
|
|
void
|
|
|
|
|
image_resize_to_layers_cmd_callback (GtkAction *action,
|
|
|
|
|
gpointer data)
|
|
|
|
|
{
|
2006-03-28 09:55:52 -08:00
|
|
|
GimpDisplay *display;
|
2009-10-06 10:20:44 -07:00
|
|
|
GimpImage *image;
|
2004-09-04 15:08:43 -07:00
|
|
|
GimpProgress *progress;
|
2006-03-28 09:55:52 -08:00
|
|
|
return_if_no_display (display, data);
|
2004-09-04 15:08:43 -07:00
|
|
|
|
2009-10-06 10:20:44 -07:00
|
|
|
image = gimp_display_get_image (display);
|
|
|
|
|
|
2014-07-12 14:45:20 -07:00
|
|
|
progress = gimp_progress_start (GIMP_PROGRESS (display), FALSE,
|
|
|
|
|
_("Resizing"));
|
2004-09-04 15:08:43 -07:00
|
|
|
|
2009-10-06 10:20:44 -07:00
|
|
|
gimp_image_resize_to_layers (image,
|
2004-09-04 15:08:43 -07:00
|
|
|
action_data_get_context (data),
|
2018-06-05 14:28:57 -07:00
|
|
|
NULL, NULL, NULL, NULL, progress);
|
2004-09-04 15:08:43 -07:00
|
|
|
|
|
|
|
|
if (progress)
|
|
|
|
|
gimp_progress_end (progress);
|
|
|
|
|
|
2009-10-06 10:20:44 -07:00
|
|
|
gimp_image_flush (image);
|
2004-09-04 15:08:43 -07:00
|
|
|
}
|
|
|
|
|
|
2007-06-09 10:17:30 -07:00
|
|
|
void
|
|
|
|
|
image_resize_to_selection_cmd_callback (GtkAction *action,
|
|
|
|
|
gpointer data)
|
|
|
|
|
{
|
|
|
|
|
GimpDisplay *display;
|
2009-10-06 10:20:44 -07:00
|
|
|
GimpImage *image;
|
2007-06-09 10:17:30 -07:00
|
|
|
GimpProgress *progress;
|
|
|
|
|
return_if_no_display (display, data);
|
|
|
|
|
|
2009-10-06 10:20:44 -07:00
|
|
|
image = gimp_display_get_image (display);
|
|
|
|
|
|
2014-07-12 14:45:20 -07:00
|
|
|
progress = gimp_progress_start (GIMP_PROGRESS (display), FALSE,
|
|
|
|
|
_("Resizing"));
|
2007-06-09 10:17:30 -07:00
|
|
|
|
2009-10-06 10:20:44 -07:00
|
|
|
gimp_image_resize_to_selection (image,
|
2007-06-09 10:17:30 -07:00
|
|
|
action_data_get_context (data),
|
|
|
|
|
progress);
|
|
|
|
|
|
|
|
|
|
if (progress)
|
|
|
|
|
gimp_progress_end (progress);
|
|
|
|
|
|
2009-10-06 10:20:44 -07:00
|
|
|
gimp_image_flush (image);
|
2007-06-09 10:17:30 -07:00
|
|
|
}
|
|
|
|
|
|
2004-11-13 14:27:39 -08:00
|
|
|
void
|
|
|
|
|
image_print_size_cmd_callback (GtkAction *action,
|
|
|
|
|
gpointer data)
|
|
|
|
|
{
|
2006-03-28 09:55:52 -08:00
|
|
|
GimpDisplay *display;
|
2009-10-06 10:20:44 -07:00
|
|
|
GimpImage *image;
|
2004-11-13 14:27:39 -08:00
|
|
|
GtkWidget *widget;
|
2009-10-06 10:20:44 -07:00
|
|
|
GtkWidget *dialog;
|
2006-03-28 09:55:52 -08:00
|
|
|
return_if_no_display (display, data);
|
2004-11-13 14:27:39 -08:00
|
|
|
return_if_no_widget (widget, data);
|
|
|
|
|
|
2009-10-06 10:20:44 -07:00
|
|
|
image = gimp_display_get_image (display);
|
|
|
|
|
|
2016-09-11 15:03:22 -07:00
|
|
|
#define PRINT_SIZE_DIALOG_KEY "gimp-print-size-dialog"
|
2004-11-13 14:27:39 -08:00
|
|
|
|
2016-09-11 15:03:22 -07:00
|
|
|
dialog = dialogs_get_dialog (G_OBJECT (image), PRINT_SIZE_DIALOG_KEY);
|
2004-11-13 14:27:39 -08:00
|
|
|
|
2016-09-11 15:03:22 -07:00
|
|
|
if (! dialog)
|
|
|
|
|
{
|
|
|
|
|
dialog = print_size_dialog_new (image,
|
|
|
|
|
action_data_get_context (data),
|
|
|
|
|
_("Set Image Print Resolution"),
|
|
|
|
|
"gimp-image-print-size",
|
|
|
|
|
widget,
|
|
|
|
|
gimp_standard_help_func,
|
|
|
|
|
GIMP_HELP_IMAGE_PRINT_SIZE,
|
|
|
|
|
image_print_size_callback,
|
|
|
|
|
NULL);
|
|
|
|
|
|
2016-09-24 06:13:34 -07:00
|
|
|
dialogs_attach_dialog (G_OBJECT (image), PRINT_SIZE_DIALOG_KEY, dialog);
|
2016-09-11 15:03:22 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gtk_window_present (GTK_WINDOW (dialog));
|
2004-11-13 14:27:39 -08:00
|
|
|
}
|
|
|
|
|
|
2001-06-26 05:09:43 -07:00
|
|
|
void
|
2004-04-29 05:52:29 -07:00
|
|
|
image_scale_cmd_callback (GtkAction *action,
|
2006-04-12 05:49:29 -07:00
|
|
|
gpointer data)
|
2001-06-26 05:09:43 -07:00
|
|
|
{
|
2006-10-14 09:51:30 -07:00
|
|
|
GimpDisplay *display;
|
2009-10-06 10:20:44 -07:00
|
|
|
GimpImage *image;
|
2006-10-14 09:51:30 -07:00
|
|
|
GtkWidget *widget;
|
|
|
|
|
GtkWidget *dialog;
|
2006-03-28 09:55:52 -08:00
|
|
|
return_if_no_display (display, data);
|
2004-10-26 18:20:07 -07:00
|
|
|
return_if_no_widget (widget, data);
|
2001-06-26 05:09:43 -07:00
|
|
|
|
2009-10-06 10:20:44 -07:00
|
|
|
image = gimp_display_get_image (display);
|
|
|
|
|
|
2016-09-11 15:03:22 -07:00
|
|
|
#define SCALE_DIALOG_KEY "gimp-scale-dialog"
|
2006-10-14 09:51:30 -07:00
|
|
|
|
2016-09-11 15:03:22 -07:00
|
|
|
dialog = dialogs_get_dialog (G_OBJECT (image), SCALE_DIALOG_KEY);
|
2006-10-14 09:51:30 -07:00
|
|
|
|
2016-09-11 15:03:22 -07:00
|
|
|
if (! dialog)
|
|
|
|
|
{
|
|
|
|
|
if (image_scale_unit != GIMP_UNIT_PERCENT)
|
|
|
|
|
image_scale_unit = gimp_display_get_shell (display)->unit;
|
|
|
|
|
|
|
|
|
|
if (image_scale_interp == -1)
|
|
|
|
|
image_scale_interp = display->gimp->config->interpolation_type;
|
|
|
|
|
|
|
|
|
|
dialog = image_scale_dialog_new (image,
|
|
|
|
|
action_data_get_context (data),
|
|
|
|
|
widget,
|
|
|
|
|
image_scale_unit,
|
|
|
|
|
image_scale_interp,
|
|
|
|
|
image_scale_callback,
|
|
|
|
|
display);
|
|
|
|
|
|
2016-09-24 06:13:34 -07:00
|
|
|
dialogs_attach_dialog (G_OBJECT (image), SCALE_DIALOG_KEY, dialog);
|
2016-09-11 15:03:22 -07:00
|
|
|
}
|
2004-10-30 11:11:16 -07:00
|
|
|
|
2016-09-11 15:03:22 -07:00
|
|
|
gtk_window_present (GTK_WINDOW (dialog));
|
2001-06-26 05:09:43 -07:00
|
|
|
}
|
|
|
|
|
|
2003-05-18 11:48:36 -07:00
|
|
|
void
|
2004-04-29 05:52:29 -07:00
|
|
|
image_flip_cmd_callback (GtkAction *action,
|
|
|
|
|
gint value,
|
|
|
|
|
gpointer data)
|
2003-05-18 11:48:36 -07:00
|
|
|
{
|
2006-03-28 09:55:52 -08:00
|
|
|
GimpDisplay *display;
|
2009-10-06 10:20:44 -07:00
|
|
|
GimpImage *image;
|
2003-05-18 11:48:36 -07:00
|
|
|
GimpProgress *progress;
|
2006-03-28 09:55:52 -08:00
|
|
|
return_if_no_display (display, data);
|
2003-05-18 11:48:36 -07:00
|
|
|
|
2009-10-06 10:20:44 -07:00
|
|
|
image = gimp_display_get_image (display);
|
|
|
|
|
|
2014-07-12 14:45:20 -07:00
|
|
|
progress = gimp_progress_start (GIMP_PROGRESS (display), FALSE,
|
|
|
|
|
_("Flipping"));
|
2003-05-18 11:48:36 -07:00
|
|
|
|
2009-10-06 10:20:44 -07:00
|
|
|
gimp_image_flip (image, action_data_get_context (data),
|
2004-08-10 11:47:21 -07:00
|
|
|
(GimpOrientationType) value, progress);
|
2003-05-18 11:48:36 -07:00
|
|
|
|
2004-08-10 11:47:21 -07:00
|
|
|
if (progress)
|
|
|
|
|
gimp_progress_end (progress);
|
2003-05-18 11:48:36 -07:00
|
|
|
|
2009-10-06 10:20:44 -07:00
|
|
|
gimp_image_flush (image);
|
2003-05-18 11:48:36 -07:00
|
|
|
}
|
|
|
|
|
|
2003-05-20 03:36:29 -07:00
|
|
|
void
|
2004-04-29 05:52:29 -07:00
|
|
|
image_rotate_cmd_callback (GtkAction *action,
|
|
|
|
|
gint value,
|
|
|
|
|
gpointer data)
|
2003-05-20 03:36:29 -07:00
|
|
|
{
|
2006-03-28 09:55:52 -08:00
|
|
|
GimpDisplay *display;
|
2009-10-06 10:20:44 -07:00
|
|
|
GimpImage *image;
|
2003-05-20 03:36:29 -07:00
|
|
|
GimpProgress *progress;
|
2006-03-28 09:55:52 -08:00
|
|
|
return_if_no_display (display, data);
|
2003-05-20 03:36:29 -07:00
|
|
|
|
2009-10-06 10:20:44 -07:00
|
|
|
image = gimp_display_get_image (display);
|
|
|
|
|
|
2014-07-12 14:45:20 -07:00
|
|
|
progress = gimp_progress_start (GIMP_PROGRESS (display), FALSE,
|
|
|
|
|
_("Rotating"));
|
2003-05-20 03:36:29 -07:00
|
|
|
|
2009-10-06 10:20:44 -07:00
|
|
|
gimp_image_rotate (image, action_data_get_context (data),
|
2004-08-10 11:47:21 -07:00
|
|
|
(GimpRotationType) value, progress);
|
2003-05-20 03:36:29 -07:00
|
|
|
|
2004-08-10 11:47:21 -07:00
|
|
|
if (progress)
|
|
|
|
|
gimp_progress_end (progress);
|
2003-05-20 03:36:29 -07:00
|
|
|
|
2009-10-06 10:20:44 -07:00
|
|
|
gimp_image_flush (image);
|
2003-05-20 03:36:29 -07:00
|
|
|
}
|
|
|
|
|
|
2002-03-15 07:09:58 -08:00
|
|
|
void
|
2012-09-22 11:35:36 -07:00
|
|
|
image_crop_to_selection_cmd_callback (GtkAction *action,
|
|
|
|
|
gpointer data)
|
2002-03-15 07:09:58 -08:00
|
|
|
{
|
2006-03-28 09:08:36 -08:00
|
|
|
GimpImage *image;
|
2006-10-09 11:49:15 -07:00
|
|
|
GtkWidget *widget;
|
2016-09-25 13:18:37 -07:00
|
|
|
gint x, y;
|
|
|
|
|
gint width, height;
|
2006-03-28 09:08:36 -08:00
|
|
|
return_if_no_image (image, data);
|
2006-10-09 11:49:15 -07:00
|
|
|
return_if_no_widget (widget, data);
|
2002-03-15 07:09:58 -08:00
|
|
|
|
2015-07-01 06:19:03 -07:00
|
|
|
if (! gimp_item_bounds (GIMP_ITEM (gimp_image_get_mask (image)),
|
2016-09-25 13:18:37 -07:00
|
|
|
&x, &y, &width, &height))
|
2002-03-15 07:09:58 -08:00
|
|
|
{
|
2008-11-04 04:33:09 -08:00
|
|
|
gimp_message_literal (image->gimp,
|
2013-09-14 09:59:20 -07:00
|
|
|
G_OBJECT (widget), GIMP_MESSAGE_WARNING,
|
2016-09-25 13:18:37 -07:00
|
|
|
_("Cannot crop because the current selection "
|
|
|
|
|
"is empty."));
|
2002-03-15 07:09:58 -08:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-09 15:02:16 -07:00
|
|
|
gimp_image_crop (image,
|
|
|
|
|
action_data_get_context (data), GIMP_FILL_TRANSPARENT,
|
2016-09-25 13:18:37 -07:00
|
|
|
x, y, width, height, TRUE);
|
2012-09-22 11:35:36 -07:00
|
|
|
gimp_image_flush (image);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
image_crop_to_content_cmd_callback (GtkAction *action,
|
|
|
|
|
gpointer data)
|
|
|
|
|
{
|
|
|
|
|
GimpImage *image;
|
|
|
|
|
GtkWidget *widget;
|
2016-09-25 13:40:28 -07:00
|
|
|
gint x, y;
|
|
|
|
|
gint width, height;
|
2012-09-22 11:35:36 -07:00
|
|
|
return_if_no_image (image, data);
|
|
|
|
|
return_if_no_widget (widget, data);
|
|
|
|
|
|
2014-08-31 08:38:49 -07:00
|
|
|
switch (gimp_pickable_auto_shrink (GIMP_PICKABLE (image),
|
|
|
|
|
0, 0,
|
|
|
|
|
gimp_image_get_width (image),
|
|
|
|
|
gimp_image_get_height (image),
|
2016-09-25 13:40:28 -07:00
|
|
|
&x, &y, &width, &height))
|
2012-09-22 11:35:36 -07:00
|
|
|
{
|
2014-08-31 08:38:49 -07:00
|
|
|
case GIMP_AUTO_SHRINK_SHRINK:
|
2016-10-09 15:02:16 -07:00
|
|
|
gimp_image_crop (image,
|
|
|
|
|
action_data_get_context (data), GIMP_FILL_TRANSPARENT,
|
2016-09-25 13:40:28 -07:00
|
|
|
x, y, width, height, TRUE);
|
2014-08-31 08:38:49 -07:00
|
|
|
gimp_image_flush (image);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case GIMP_AUTO_SHRINK_EMPTY:
|
2012-09-22 11:35:36 -07:00
|
|
|
gimp_message_literal (image->gimp,
|
2014-08-31 08:38:49 -07:00
|
|
|
G_OBJECT (widget), GIMP_MESSAGE_INFO,
|
2013-09-14 09:59:20 -07:00
|
|
|
_("Cannot crop because the image has no content."));
|
2014-08-31 08:38:49 -07:00
|
|
|
break;
|
2012-09-22 11:35:36 -07:00
|
|
|
|
2014-08-31 08:38:49 -07:00
|
|
|
case GIMP_AUTO_SHRINK_UNSHRINKABLE:
|
|
|
|
|
gimp_message_literal (image->gimp,
|
|
|
|
|
G_OBJECT (widget), GIMP_MESSAGE_INFO,
|
2016-09-25 13:18:37 -07:00
|
|
|
_("Cannot crop because the image is already "
|
|
|
|
|
"cropped to its content."));
|
2014-08-31 08:38:49 -07:00
|
|
|
break;
|
|
|
|
|
}
|
2002-03-15 07:09:58 -08:00
|
|
|
}
|
|
|
|
|
|
2002-02-13 06:41:35 -08:00
|
|
|
void
|
2004-04-29 05:52:29 -07:00
|
|
|
image_merge_layers_cmd_callback (GtkAction *action,
|
2002-02-13 06:41:35 -08:00
|
|
|
gpointer data)
|
|
|
|
|
{
|
app: merge layers in chunks, and show progress
In gimp_image_merge_layers() -- the internal function used by the
various layer-merging/flattenning functions -- process the merged-
layer graph in chunks, using gimp_gegl_apply_operation(), instead
of in one go, using gegl_node_blit_buffer(). Processing in chunks
better utilizes the cache, since it reduces the size of
intermediate buffers, reducing the chances of hitting the swap when
merging large images (see, for example, issue #3012.)
Additionally, this allows us to show progress indication. Have the
relevant gimpimage-merge functions take a GimpProgress, and pass it
down to gimp_image_merge_layers(). Adapt all callers.
(cherry picked from commit e83d8ac4f2dc0260e97a91938ae3e34608efdbf9)
2019-02-25 01:49:04 -08:00
|
|
|
GtkWidget *dialog;
|
|
|
|
|
GimpImage *image;
|
|
|
|
|
GimpDisplay *display;
|
|
|
|
|
GtkWidget *widget;
|
2006-03-28 09:08:36 -08:00
|
|
|
return_if_no_image (image, data);
|
app: merge layers in chunks, and show progress
In gimp_image_merge_layers() -- the internal function used by the
various layer-merging/flattenning functions -- process the merged-
layer graph in chunks, using gimp_gegl_apply_operation(), instead
of in one go, using gegl_node_blit_buffer(). Processing in chunks
better utilizes the cache, since it reduces the size of
intermediate buffers, reducing the chances of hitting the swap when
merging large images (see, for example, issue #3012.)
Additionally, this allows us to show progress indication. Have the
relevant gimpimage-merge functions take a GimpProgress, and pass it
down to gimp_image_merge_layers(). Adapt all callers.
(cherry picked from commit e83d8ac4f2dc0260e97a91938ae3e34608efdbf9)
2019-02-25 01:49:04 -08:00
|
|
|
return_if_no_display (display, data);
|
2004-05-03 07:46:29 -07:00
|
|
|
return_if_no_widget (widget, data);
|
2002-02-13 06:41:35 -08:00
|
|
|
|
2016-09-23 10:44:11 -07:00
|
|
|
#define MERGE_LAYERS_DIALOG_KEY "gimp-merge-layers-dialog"
|
2004-05-25 07:37:02 -07:00
|
|
|
|
2016-09-23 10:44:11 -07:00
|
|
|
dialog = dialogs_get_dialog (G_OBJECT (image), MERGE_LAYERS_DIALOG_KEY);
|
2004-05-25 07:37:02 -07:00
|
|
|
|
2016-09-23 10:44:11 -07:00
|
|
|
if (! dialog)
|
|
|
|
|
{
|
2016-09-24 03:33:42 -07:00
|
|
|
GimpDialogConfig *config = GIMP_DIALOG_CONFIG (image->gimp->config);
|
|
|
|
|
|
2016-09-23 10:44:11 -07:00
|
|
|
dialog = image_merge_layers_dialog_new (image,
|
|
|
|
|
action_data_get_context (data),
|
|
|
|
|
widget,
|
2016-09-24 03:33:42 -07:00
|
|
|
config->layer_merge_type,
|
|
|
|
|
config->layer_merge_active_group_only,
|
|
|
|
|
config->layer_merge_discard_invisible,
|
2016-09-23 10:44:11 -07:00
|
|
|
image_merge_layers_callback,
|
app: merge layers in chunks, and show progress
In gimp_image_merge_layers() -- the internal function used by the
various layer-merging/flattenning functions -- process the merged-
layer graph in chunks, using gimp_gegl_apply_operation(), instead
of in one go, using gegl_node_blit_buffer(). Processing in chunks
better utilizes the cache, since it reduces the size of
intermediate buffers, reducing the chances of hitting the swap when
merging large images (see, for example, issue #3012.)
Additionally, this allows us to show progress indication. Have the
relevant gimpimage-merge functions take a GimpProgress, and pass it
down to gimp_image_merge_layers(). Adapt all callers.
(cherry picked from commit e83d8ac4f2dc0260e97a91938ae3e34608efdbf9)
2019-02-25 01:49:04 -08:00
|
|
|
display);
|
2016-09-23 10:44:11 -07:00
|
|
|
|
|
|
|
|
dialogs_attach_dialog (G_OBJECT (image), MERGE_LAYERS_DIALOG_KEY, dialog);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gtk_window_present (GTK_WINDOW (dialog));
|
2002-02-13 06:41:35 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2004-04-29 05:52:29 -07:00
|
|
|
image_flatten_image_cmd_callback (GtkAction *action,
|
2002-02-13 06:41:35 -08:00
|
|
|
gpointer data)
|
|
|
|
|
{
|
app: merge layers in chunks, and show progress
In gimp_image_merge_layers() -- the internal function used by the
various layer-merging/flattenning functions -- process the merged-
layer graph in chunks, using gimp_gegl_apply_operation(), instead
of in one go, using gegl_node_blit_buffer(). Processing in chunks
better utilizes the cache, since it reduces the size of
intermediate buffers, reducing the chances of hitting the swap when
merging large images (see, for example, issue #3012.)
Additionally, this allows us to show progress indication. Have the
relevant gimpimage-merge functions take a GimpProgress, and pass it
down to gimp_image_merge_layers(). Adapt all callers.
(cherry picked from commit e83d8ac4f2dc0260e97a91938ae3e34608efdbf9)
2019-02-25 01:49:04 -08:00
|
|
|
GimpImage *image;
|
|
|
|
|
GimpDisplay *display;
|
|
|
|
|
GtkWidget *widget;
|
|
|
|
|
GError *error = NULL;
|
2006-03-28 09:08:36 -08:00
|
|
|
return_if_no_image (image, data);
|
app: merge layers in chunks, and show progress
In gimp_image_merge_layers() -- the internal function used by the
various layer-merging/flattenning functions -- process the merged-
layer graph in chunks, using gimp_gegl_apply_operation(), instead
of in one go, using gegl_node_blit_buffer(). Processing in chunks
better utilizes the cache, since it reduces the size of
intermediate buffers, reducing the chances of hitting the swap when
merging large images (see, for example, issue #3012.)
Additionally, this allows us to show progress indication. Have the
relevant gimpimage-merge functions take a GimpProgress, and pass it
down to gimp_image_merge_layers(). Adapt all callers.
(cherry picked from commit e83d8ac4f2dc0260e97a91938ae3e34608efdbf9)
2019-02-25 01:49:04 -08:00
|
|
|
return_if_no_display (display, data);
|
2013-08-09 12:31:55 -07:00
|
|
|
return_if_no_widget (widget, data);
|
|
|
|
|
|
app: merge layers in chunks, and show progress
In gimp_image_merge_layers() -- the internal function used by the
various layer-merging/flattenning functions -- process the merged-
layer graph in chunks, using gimp_gegl_apply_operation(), instead
of in one go, using gegl_node_blit_buffer(). Processing in chunks
better utilizes the cache, since it reduces the size of
intermediate buffers, reducing the chances of hitting the swap when
merging large images (see, for example, issue #3012.)
Additionally, this allows us to show progress indication. Have the
relevant gimpimage-merge functions take a GimpProgress, and pass it
down to gimp_image_merge_layers(). Adapt all callers.
(cherry picked from commit e83d8ac4f2dc0260e97a91938ae3e34608efdbf9)
2019-02-25 01:49:04 -08:00
|
|
|
if (! gimp_image_flatten (image, action_data_get_context (data),
|
|
|
|
|
GIMP_PROGRESS (display), &error))
|
2013-08-09 12:31:55 -07:00
|
|
|
{
|
|
|
|
|
gimp_message_literal (image->gimp,
|
|
|
|
|
G_OBJECT (widget), GIMP_MESSAGE_WARNING,
|
|
|
|
|
error->message);
|
|
|
|
|
g_clear_error (&error);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2002-02-13 06:41:35 -08:00
|
|
|
|
2006-03-28 09:08:36 -08:00
|
|
|
gimp_image_flush (image);
|
2002-02-13 06:41:35 -08:00
|
|
|
}
|
2003-01-10 09:55:53 -08:00
|
|
|
|
2003-07-27 03:34:15 -07:00
|
|
|
void
|
2004-04-29 05:52:29 -07:00
|
|
|
image_configure_grid_cmd_callback (GtkAction *action,
|
2003-07-27 03:34:15 -07:00
|
|
|
gpointer data)
|
|
|
|
|
{
|
2016-09-24 05:49:43 -07:00
|
|
|
GimpDisplay *display;
|
|
|
|
|
GimpImage *image;
|
|
|
|
|
GtkWidget *dialog;
|
2006-03-28 09:55:52 -08:00
|
|
|
return_if_no_display (display, data);
|
2003-07-27 03:34:15 -07:00
|
|
|
|
2009-10-06 10:20:44 -07:00
|
|
|
image = gimp_display_get_image (display);
|
2003-07-27 03:34:15 -07:00
|
|
|
|
2016-09-24 05:49:43 -07:00
|
|
|
#define GRID_DIALOG_KEY "gimp-grid-dialog"
|
|
|
|
|
|
|
|
|
|
dialog = dialogs_get_dialog (G_OBJECT (image), GRID_DIALOG_KEY);
|
|
|
|
|
|
|
|
|
|
if (! dialog)
|
2003-07-27 03:34:15 -07:00
|
|
|
{
|
2016-09-24 05:49:43 -07:00
|
|
|
GimpDisplayShell *shell = gimp_display_get_shell (display);
|
2003-07-27 03:34:15 -07:00
|
|
|
|
2016-09-24 05:49:43 -07:00
|
|
|
dialog = grid_dialog_new (image,
|
|
|
|
|
action_data_get_context (data),
|
2016-09-24 06:07:04 -07:00
|
|
|
gtk_widget_get_toplevel (GTK_WIDGET (shell)));
|
2003-07-27 03:34:15 -07:00
|
|
|
|
2016-09-24 05:49:43 -07:00
|
|
|
dialogs_attach_dialog (G_OBJECT (image), GRID_DIALOG_KEY, dialog);
|
2003-07-27 03:34:15 -07:00
|
|
|
}
|
|
|
|
|
|
2016-09-24 05:49:43 -07:00
|
|
|
gtk_window_present (GTK_WINDOW (dialog));
|
2003-07-27 03:34:15 -07:00
|
|
|
}
|
|
|
|
|
|
2005-04-04 15:34:29 -07:00
|
|
|
void
|
|
|
|
|
image_properties_cmd_callback (GtkAction *action,
|
|
|
|
|
gpointer data)
|
|
|
|
|
{
|
2016-09-24 06:07:04 -07:00
|
|
|
GimpDisplay *display;
|
|
|
|
|
GimpImage *image;
|
|
|
|
|
GtkWidget *dialog;
|
2006-03-28 09:55:52 -08:00
|
|
|
return_if_no_display (display, data);
|
2005-04-04 15:34:29 -07:00
|
|
|
|
2009-10-06 10:20:44 -07:00
|
|
|
image = gimp_display_get_image (display);
|
2005-04-04 15:34:29 -07:00
|
|
|
|
2016-09-24 06:07:04 -07:00
|
|
|
#define PROPERTIES_DIALOG_KEY "gimp-image-properties-dialog"
|
|
|
|
|
|
|
|
|
|
dialog = dialogs_get_dialog (G_OBJECT (image), PROPERTIES_DIALOG_KEY);
|
|
|
|
|
|
|
|
|
|
if (! dialog)
|
|
|
|
|
{
|
|
|
|
|
GimpDisplayShell *shell = gimp_display_get_shell (display);
|
|
|
|
|
|
|
|
|
|
dialog = image_properties_dialog_new (image,
|
|
|
|
|
action_data_get_context (data),
|
|
|
|
|
gtk_widget_get_toplevel (GTK_WIDGET (shell)));
|
2005-04-04 15:34:29 -07:00
|
|
|
|
2016-09-24 06:07:04 -07:00
|
|
|
dialogs_attach_dialog (G_OBJECT (image), PROPERTIES_DIALOG_KEY, dialog);
|
|
|
|
|
}
|
2005-04-04 15:34:29 -07:00
|
|
|
|
|
|
|
|
gtk_window_present (GTK_WINDOW (dialog));
|
|
|
|
|
}
|
|
|
|
|
|
2003-01-10 09:55:53 -08:00
|
|
|
|
2001-06-26 05:09:43 -07:00
|
|
|
/* private functions */
|
|
|
|
|
|
2016-09-29 13:43:37 -07:00
|
|
|
static void
|
|
|
|
|
image_convert_rgb_callback (GtkWidget *dialog,
|
|
|
|
|
GimpImage *image,
|
|
|
|
|
GimpColorProfile *new_profile,
|
2016-09-29 14:06:46 -07:00
|
|
|
GFile *new_file,
|
2016-09-29 13:43:37 -07:00
|
|
|
GimpColorRenderingIntent intent,
|
|
|
|
|
gboolean bpc,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
GimpProgress *progress = user_data;
|
|
|
|
|
GError *error = NULL;
|
|
|
|
|
|
|
|
|
|
progress = gimp_progress_start (progress, FALSE,
|
|
|
|
|
_("Converting to RGB (%s)"),
|
|
|
|
|
gimp_color_profile_get_label (new_profile));
|
|
|
|
|
|
|
|
|
|
if (! gimp_image_convert_type (image, GIMP_RGB, new_profile,
|
|
|
|
|
progress, &error))
|
|
|
|
|
{
|
|
|
|
|
gimp_message (image->gimp, G_OBJECT (dialog),
|
|
|
|
|
GIMP_MESSAGE_ERROR,
|
|
|
|
|
"%s", error->message);
|
|
|
|
|
g_clear_error (&error);
|
|
|
|
|
|
|
|
|
|
if (progress)
|
|
|
|
|
gimp_progress_end (progress);
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (progress)
|
|
|
|
|
gimp_progress_end (progress);
|
|
|
|
|
|
|
|
|
|
gimp_image_flush (image);
|
|
|
|
|
|
|
|
|
|
gtk_widget_destroy (dialog);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
image_convert_gray_callback (GtkWidget *dialog,
|
|
|
|
|
GimpImage *image,
|
|
|
|
|
GimpColorProfile *new_profile,
|
2016-09-29 14:06:46 -07:00
|
|
|
GFile *new_file,
|
2016-09-29 13:43:37 -07:00
|
|
|
GimpColorRenderingIntent intent,
|
|
|
|
|
gboolean bpc,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
GimpProgress *progress = user_data;
|
|
|
|
|
GError *error = NULL;
|
|
|
|
|
|
|
|
|
|
progress = gimp_progress_start (progress, FALSE,
|
|
|
|
|
_("Converting to grayscale (%s)"),
|
|
|
|
|
gimp_color_profile_get_label (new_profile));
|
|
|
|
|
|
|
|
|
|
if (! gimp_image_convert_type (image, GIMP_GRAY, new_profile,
|
|
|
|
|
progress, &error))
|
|
|
|
|
{
|
|
|
|
|
gimp_message (image->gimp, G_OBJECT (dialog),
|
|
|
|
|
GIMP_MESSAGE_ERROR,
|
|
|
|
|
"%s", error->message);
|
|
|
|
|
g_clear_error (&error);
|
|
|
|
|
|
|
|
|
|
if (progress)
|
|
|
|
|
gimp_progress_end (progress);
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (progress)
|
|
|
|
|
gimp_progress_end (progress);
|
|
|
|
|
|
|
|
|
|
gimp_image_flush (image);
|
|
|
|
|
|
|
|
|
|
gtk_widget_destroy (dialog);
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-27 06:43:25 -07:00
|
|
|
static void
|
|
|
|
|
image_convert_indexed_callback (GtkWidget *dialog,
|
|
|
|
|
GimpImage *image,
|
2016-09-27 14:51:33 -07:00
|
|
|
GimpConvertPaletteType palette_type,
|
|
|
|
|
gint max_colors,
|
|
|
|
|
gboolean remove_duplicates,
|
2016-09-27 06:43:25 -07:00
|
|
|
GimpConvertDitherType dither_type,
|
2016-09-27 13:47:06 -07:00
|
|
|
gboolean dither_alpha,
|
|
|
|
|
gboolean dither_text_layers,
|
2016-09-27 06:43:25 -07:00
|
|
|
GimpPalette *custom_palette,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
2016-09-27 15:31:59 -07:00
|
|
|
GimpDialogConfig *config = GIMP_DIALOG_CONFIG (image->gimp->config);
|
|
|
|
|
GimpDisplay *display = user_data;
|
|
|
|
|
GimpProgress *progress;
|
|
|
|
|
GError *error = NULL;
|
|
|
|
|
|
|
|
|
|
g_object_set (config,
|
|
|
|
|
"image-convert-indexed-palette-type", palette_type,
|
|
|
|
|
"image-convert-indexed-max-colors", max_colors,
|
|
|
|
|
"image-convert-indexed-remove-duplicates", remove_duplicates,
|
|
|
|
|
"image-convert-indexed-dither-type", dither_type,
|
|
|
|
|
"image-convert-indexed-dither-alpha", dither_alpha,
|
|
|
|
|
"image-convert-indexed-dither-text-layers", dither_text_layers,
|
|
|
|
|
NULL);
|
2016-09-27 06:43:25 -07:00
|
|
|
|
|
|
|
|
if (image_convert_indexed_custom_palette)
|
|
|
|
|
g_object_remove_weak_pointer (G_OBJECT (image_convert_indexed_custom_palette),
|
|
|
|
|
(gpointer) &image_convert_indexed_custom_palette);
|
|
|
|
|
|
2016-09-27 15:31:59 -07:00
|
|
|
image_convert_indexed_custom_palette = custom_palette;
|
2016-09-27 06:43:25 -07:00
|
|
|
|
|
|
|
|
if (image_convert_indexed_custom_palette)
|
|
|
|
|
g_object_add_weak_pointer (G_OBJECT (image_convert_indexed_custom_palette),
|
|
|
|
|
(gpointer) &image_convert_indexed_custom_palette);
|
|
|
|
|
|
|
|
|
|
progress = gimp_progress_start (GIMP_PROGRESS (display), FALSE,
|
|
|
|
|
_("Converting to indexed colors"));
|
|
|
|
|
|
|
|
|
|
if (! gimp_image_convert_indexed (image,
|
2016-09-27 15:31:59 -07:00
|
|
|
config->image_convert_indexed_palette_type,
|
|
|
|
|
config->image_convert_indexed_max_colors,
|
|
|
|
|
config->image_convert_indexed_remove_duplicates,
|
|
|
|
|
config->image_convert_indexed_dither_type,
|
|
|
|
|
config->image_convert_indexed_dither_alpha,
|
|
|
|
|
config->image_convert_indexed_dither_text_layers,
|
2016-09-27 06:43:25 -07:00
|
|
|
image_convert_indexed_custom_palette,
|
|
|
|
|
progress,
|
|
|
|
|
&error))
|
|
|
|
|
{
|
|
|
|
|
gimp_message_literal (image->gimp, G_OBJECT (display),
|
|
|
|
|
GIMP_MESSAGE_WARNING, error->message);
|
|
|
|
|
g_clear_error (&error);
|
|
|
|
|
|
|
|
|
|
if (progress)
|
|
|
|
|
gimp_progress_end (progress);
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (progress)
|
|
|
|
|
gimp_progress_end (progress);
|
|
|
|
|
|
|
|
|
|
gimp_image_flush (image);
|
|
|
|
|
|
|
|
|
|
gtk_widget_destroy (dialog);
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-26 13:44:34 -07:00
|
|
|
static void
|
|
|
|
|
image_convert_precision_callback (GtkWidget *dialog,
|
|
|
|
|
GimpImage *image,
|
|
|
|
|
GimpPrecision precision,
|
|
|
|
|
GeglDitherMethod layer_dither_method,
|
|
|
|
|
GeglDitherMethod text_layer_dither_method,
|
|
|
|
|
GeglDitherMethod channel_dither_method,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
GimpDialogConfig *config = GIMP_DIALOG_CONFIG (image->gimp->config);
|
|
|
|
|
GimpProgress *progress = user_data;
|
|
|
|
|
const gchar *enum_desc;
|
2016-11-09 04:10:56 -08:00
|
|
|
const Babl *old_format;
|
|
|
|
|
const Babl *new_format;
|
|
|
|
|
gint old_bits;
|
|
|
|
|
gint new_bits;
|
2016-09-26 13:44:34 -07:00
|
|
|
|
|
|
|
|
g_object_set (config,
|
|
|
|
|
"image-convert-precision-layer-dither-method",
|
|
|
|
|
layer_dither_method,
|
|
|
|
|
"image-convert-precision-text-layer-dither-method",
|
|
|
|
|
text_layer_dither_method,
|
|
|
|
|
"image-convert-precision-channel-dither-method",
|
|
|
|
|
channel_dither_method,
|
|
|
|
|
NULL);
|
|
|
|
|
|
2016-11-09 04:10:56 -08:00
|
|
|
/* we do the same dither method checks here *and* in the dialog,
|
|
|
|
|
* because the dialog leaves the passed dither methods untouched if
|
|
|
|
|
* dithering is disabled and passes the original values to the
|
|
|
|
|
* callback, in order not to change the values saved in
|
|
|
|
|
* GimpDialogConfig.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/* random formats with the right precision */
|
|
|
|
|
old_format = gimp_image_get_layer_format (image, FALSE);
|
|
|
|
|
new_format = gimp_babl_format (GIMP_RGB, precision, FALSE);
|
|
|
|
|
|
|
|
|
|
old_bits = (babl_format_get_bytes_per_pixel (old_format) * 8 /
|
|
|
|
|
babl_format_get_n_components (old_format));
|
|
|
|
|
new_bits = (babl_format_get_bytes_per_pixel (new_format) * 8 /
|
|
|
|
|
babl_format_get_n_components (new_format));
|
|
|
|
|
|
2016-11-10 03:11:19 -08:00
|
|
|
if (new_bits >= old_bits ||
|
|
|
|
|
new_bits > CONVERT_PRECISION_DIALOG_MAX_DITHER_BITS)
|
2016-11-09 04:10:56 -08:00
|
|
|
{
|
|
|
|
|
/* don't dither if we are converting to a higher bit depth,
|
2016-11-10 03:11:19 -08:00
|
|
|
* or to more than MAX_DITHER_BITS.
|
2016-11-09 04:10:56 -08:00
|
|
|
*/
|
|
|
|
|
layer_dither_method = GEGL_DITHER_NONE;
|
|
|
|
|
text_layer_dither_method = GEGL_DITHER_NONE;
|
|
|
|
|
channel_dither_method = GEGL_DITHER_NONE;
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-26 13:44:34 -07:00
|
|
|
gimp_enum_get_value (GIMP_TYPE_PRECISION, precision,
|
|
|
|
|
NULL, NULL, &enum_desc, NULL);
|
|
|
|
|
|
|
|
|
|
progress = gimp_progress_start (progress, FALSE,
|
|
|
|
|
_("Converting image to %s"),
|
|
|
|
|
enum_desc);
|
|
|
|
|
|
|
|
|
|
gimp_image_convert_precision (image,
|
|
|
|
|
precision,
|
|
|
|
|
layer_dither_method,
|
|
|
|
|
text_layer_dither_method,
|
|
|
|
|
channel_dither_method,
|
|
|
|
|
progress);
|
|
|
|
|
|
|
|
|
|
if (progress)
|
|
|
|
|
gimp_progress_end (progress);
|
|
|
|
|
|
|
|
|
|
gimp_image_flush (image);
|
|
|
|
|
|
|
|
|
|
gtk_widget_destroy (dialog);
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-29 13:43:37 -07:00
|
|
|
static void
|
|
|
|
|
image_profile_assign_callback (GtkWidget *dialog,
|
|
|
|
|
GimpImage *image,
|
|
|
|
|
GimpColorProfile *new_profile,
|
2016-09-29 14:06:46 -07:00
|
|
|
GFile *new_file,
|
2016-09-29 13:43:37 -07:00
|
|
|
GimpColorRenderingIntent intent,
|
|
|
|
|
gboolean bpc,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
GError *error = NULL;
|
|
|
|
|
|
|
|
|
|
gimp_image_undo_group_start (image,
|
|
|
|
|
GIMP_UNDO_GROUP_PARASITE_ATTACH,
|
|
|
|
|
_("Assign color profile"));
|
|
|
|
|
|
|
|
|
|
if (! gimp_image_set_color_profile (image, new_profile, &error))
|
|
|
|
|
{
|
|
|
|
|
gimp_message (image->gimp, G_OBJECT (dialog),
|
|
|
|
|
GIMP_MESSAGE_ERROR,
|
|
|
|
|
"%s", error->message);
|
|
|
|
|
g_clear_error (&error);
|
|
|
|
|
|
|
|
|
|
gimp_image_undo_group_end (image);
|
|
|
|
|
gimp_image_undo (image);
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gimp_image_set_is_color_managed (image, TRUE, TRUE);
|
|
|
|
|
|
|
|
|
|
/* omg... */
|
|
|
|
|
gimp_image_parasite_detach (image, "icc-profile-name");
|
|
|
|
|
|
|
|
|
|
gimp_image_undo_group_end (image);
|
|
|
|
|
|
|
|
|
|
gimp_image_flush (image);
|
|
|
|
|
|
|
|
|
|
gtk_widget_destroy (dialog);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
image_profile_convert_callback (GtkWidget *dialog,
|
|
|
|
|
GimpImage *image,
|
|
|
|
|
GimpColorProfile *new_profile,
|
2016-09-29 14:06:46 -07:00
|
|
|
GFile *new_file,
|
2016-09-29 13:43:37 -07:00
|
|
|
GimpColorRenderingIntent intent,
|
|
|
|
|
gboolean bpc,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
GimpDialogConfig *config = GIMP_DIALOG_CONFIG (image->gimp->config);
|
|
|
|
|
GimpProgress *progress = user_data;
|
|
|
|
|
GError *error = NULL;
|
|
|
|
|
|
|
|
|
|
g_object_set (config,
|
|
|
|
|
"image-convert-profile-intent", intent,
|
|
|
|
|
"image-convert-profile-black-point-compensation", bpc,
|
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
|
|
progress = gimp_progress_start (progress, FALSE,
|
|
|
|
|
_("Converting to '%s'"),
|
|
|
|
|
gimp_color_profile_get_label (new_profile));
|
|
|
|
|
|
|
|
|
|
if (! gimp_image_convert_color_profile (image, new_profile,
|
|
|
|
|
config->image_convert_profile_intent,
|
|
|
|
|
config->image_convert_profile_bpc,
|
|
|
|
|
progress, &error))
|
|
|
|
|
{
|
|
|
|
|
gimp_message (image->gimp, G_OBJECT (dialog),
|
|
|
|
|
GIMP_MESSAGE_ERROR,
|
|
|
|
|
"%s", error->message);
|
|
|
|
|
g_clear_error (&error);
|
|
|
|
|
|
|
|
|
|
if (progress)
|
|
|
|
|
gimp_progress_end (progress);
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (progress)
|
|
|
|
|
gimp_progress_end (progress);
|
|
|
|
|
|
|
|
|
|
gimp_image_flush (image);
|
|
|
|
|
|
|
|
|
|
gtk_widget_destroy (dialog);
|
|
|
|
|
}
|
|
|
|
|
|
2001-06-26 05:09:43 -07:00
|
|
|
static void
|
2006-05-19 07:50:46 -07:00
|
|
|
image_resize_callback (GtkWidget *dialog,
|
|
|
|
|
GimpViewable *viewable,
|
2016-09-24 06:07:04 -07:00
|
|
|
GimpContext *context,
|
2006-05-19 07:50:46 -07:00
|
|
|
gint width,
|
|
|
|
|
gint height,
|
|
|
|
|
GimpUnit unit,
|
|
|
|
|
gint offset_x,
|
|
|
|
|
gint offset_y,
|
2016-10-19 15:30:10 -07:00
|
|
|
GimpFillType fill_type,
|
2006-05-19 07:50:46 -07:00
|
|
|
GimpItemSet layer_set,
|
2012-09-05 14:26:54 -07:00
|
|
|
gboolean resize_text_layers,
|
2016-09-24 06:07:04 -07:00
|
|
|
gpointer user_data)
|
2001-06-26 05:09:43 -07:00
|
|
|
{
|
2016-09-24 06:07:04 -07:00
|
|
|
GimpDisplay *display = user_data;
|
2001-06-26 05:09:43 -07:00
|
|
|
|
2006-10-14 09:51:30 -07:00
|
|
|
image_resize_unit = unit;
|
|
|
|
|
|
2004-10-27 03:33:08 -07:00
|
|
|
if (width > 0 && height > 0)
|
2001-06-26 05:09:43 -07:00
|
|
|
{
|
2016-10-19 15:30:10 -07:00
|
|
|
GimpImage *image = GIMP_IMAGE (viewable);
|
|
|
|
|
GimpDialogConfig *config = GIMP_DIALOG_CONFIG (image->gimp->config);
|
|
|
|
|
GimpProgress *progress;
|
|
|
|
|
|
|
|
|
|
g_object_set (config,
|
|
|
|
|
"image-resize-fill-type", fill_type,
|
|
|
|
|
"image-resize-layer-set", layer_set,
|
|
|
|
|
"image-resize-resize-text-layers", resize_text_layers,
|
|
|
|
|
NULL);
|
2003-06-03 09:42:46 -07:00
|
|
|
|
2004-10-27 03:33:08 -07:00
|
|
|
gtk_widget_destroy (dialog);
|
|
|
|
|
|
2007-12-25 08:21:40 -08:00
|
|
|
if (width == gimp_image_get_width (image) &&
|
|
|
|
|
height == gimp_image_get_height (image))
|
2004-10-27 03:33:08 -07:00
|
|
|
return;
|
|
|
|
|
|
2014-07-12 14:45:20 -07:00
|
|
|
progress = gimp_progress_start (GIMP_PROGRESS (display), FALSE,
|
|
|
|
|
_("Resizing"));
|
2003-06-03 09:42:46 -07:00
|
|
|
|
2005-02-24 08:39:12 -08:00
|
|
|
gimp_image_resize_with_layers (image,
|
2016-10-09 15:02:16 -07:00
|
|
|
context, fill_type,
|
2005-02-24 08:39:12 -08:00
|
|
|
width, height, offset_x, offset_y,
|
2006-05-19 07:50:46 -07:00
|
|
|
layer_set,
|
2012-09-05 14:26:54 -07:00
|
|
|
resize_text_layers,
|
2005-02-24 08:39:12 -08:00
|
|
|
progress);
|
2003-06-03 09:42:46 -07:00
|
|
|
|
2004-08-10 11:47:21 -07:00
|
|
|
if (progress)
|
|
|
|
|
gimp_progress_end (progress);
|
2003-06-03 09:42:46 -07:00
|
|
|
|
2004-10-27 03:33:08 -07:00
|
|
|
gimp_image_flush (image);
|
2001-06-26 05:09:43 -07:00
|
|
|
}
|
2003-08-21 18:42:57 -07:00
|
|
|
else
|
2001-06-26 05:09:43 -07:00
|
|
|
{
|
2004-11-14 14:01:13 -08:00
|
|
|
g_warning ("Resize Error: "
|
|
|
|
|
"Both width and height must be greater than zero.");
|
2001-06-26 05:09:43 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2004-11-13 14:27:39 -08:00
|
|
|
static void
|
|
|
|
|
image_print_size_callback (GtkWidget *dialog,
|
|
|
|
|
GimpImage *image,
|
|
|
|
|
gdouble xresolution,
|
|
|
|
|
gdouble yresolution,
|
|
|
|
|
GimpUnit resolution_unit,
|
|
|
|
|
gpointer data)
|
|
|
|
|
{
|
2007-12-26 09:33:41 -08:00
|
|
|
gdouble xres;
|
|
|
|
|
gdouble yres;
|
|
|
|
|
|
2004-11-13 14:27:39 -08:00
|
|
|
gtk_widget_destroy (dialog);
|
|
|
|
|
|
2007-12-26 09:33:41 -08:00
|
|
|
gimp_image_get_resolution (image, &xres, &yres);
|
|
|
|
|
|
|
|
|
|
if (xresolution == xres &&
|
|
|
|
|
yresolution == yres &&
|
2007-12-25 08:21:40 -08:00
|
|
|
resolution_unit == gimp_image_get_unit (image))
|
2004-11-14 14:01:13 -08:00
|
|
|
return;
|
|
|
|
|
|
2004-11-13 14:27:39 -08:00
|
|
|
gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_IMAGE_SCALE,
|
|
|
|
|
_("Change Print Size"));
|
|
|
|
|
|
|
|
|
|
gimp_image_set_resolution (image, xresolution, yresolution);
|
|
|
|
|
gimp_image_set_unit (image, resolution_unit);
|
|
|
|
|
|
|
|
|
|
gimp_image_undo_group_end (image);
|
|
|
|
|
|
|
|
|
|
gimp_image_flush (image);
|
|
|
|
|
}
|
|
|
|
|
|
2001-06-26 05:09:43 -07:00
|
|
|
static void
|
2006-10-14 09:51:30 -07:00
|
|
|
image_scale_callback (GtkWidget *dialog,
|
|
|
|
|
GimpViewable *viewable,
|
|
|
|
|
gint width,
|
|
|
|
|
gint height,
|
|
|
|
|
GimpUnit unit,
|
|
|
|
|
GimpInterpolationType interpolation,
|
|
|
|
|
gdouble xresolution,
|
|
|
|
|
gdouble yresolution,
|
|
|
|
|
GimpUnit resolution_unit,
|
|
|
|
|
gpointer user_data)
|
2001-06-26 05:09:43 -07:00
|
|
|
{
|
2016-09-29 13:43:37 -07:00
|
|
|
GimpProgress *progress = user_data;
|
|
|
|
|
GimpImage *image = GIMP_IMAGE (viewable);
|
|
|
|
|
gdouble xres;
|
|
|
|
|
gdouble yres;
|
2003-12-09 03:49:47 -08:00
|
|
|
|
2006-10-14 09:51:30 -07:00
|
|
|
image_scale_unit = unit;
|
|
|
|
|
image_scale_interp = interpolation;
|
2001-06-26 05:09:43 -07:00
|
|
|
|
2007-12-26 09:33:41 -08:00
|
|
|
gimp_image_get_resolution (image, &xres, &yres);
|
|
|
|
|
|
2006-10-14 09:51:30 -07:00
|
|
|
if (width > 0 && height > 0)
|
|
|
|
|
{
|
2016-10-27 12:26:07 -07:00
|
|
|
gtk_widget_destroy (dialog);
|
|
|
|
|
|
2007-12-25 08:21:40 -08:00
|
|
|
if (width == gimp_image_get_width (image) &&
|
|
|
|
|
height == gimp_image_get_height (image) &&
|
2007-12-26 09:33:41 -08:00
|
|
|
xresolution == xres &&
|
|
|
|
|
yresolution == yres &&
|
2007-12-25 08:21:40 -08:00
|
|
|
resolution_unit == gimp_image_get_unit (image))
|
2006-10-14 09:51:30 -07:00
|
|
|
return;
|
2001-06-26 05:09:43 -07:00
|
|
|
|
2006-10-14 09:51:30 -07:00
|
|
|
gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_IMAGE_SCALE,
|
|
|
|
|
_("Scale Image"));
|
2001-06-26 05:09:43 -07:00
|
|
|
|
2006-10-14 09:51:30 -07:00
|
|
|
gimp_image_set_resolution (image, xresolution, yresolution);
|
|
|
|
|
gimp_image_set_unit (image, resolution_unit);
|
|
|
|
|
|
2007-12-25 08:21:40 -08:00
|
|
|
if (width != gimp_image_get_width (image) ||
|
|
|
|
|
height != gimp_image_get_height (image))
|
2004-10-26 18:20:07 -07:00
|
|
|
{
|
2016-09-29 13:43:37 -07:00
|
|
|
progress = gimp_progress_start (progress, FALSE,
|
2014-07-12 14:45:20 -07:00
|
|
|
_("Scaling"));
|
2001-11-16 09:08:41 -08:00
|
|
|
|
2007-02-26 10:53:07 -08:00
|
|
|
gimp_image_scale (image, width, height, interpolation, progress);
|
2001-11-16 09:08:41 -08:00
|
|
|
|
2004-08-10 11:47:21 -07:00
|
|
|
if (progress)
|
|
|
|
|
gimp_progress_end (progress);
|
2004-10-26 18:20:07 -07:00
|
|
|
}
|
2001-06-26 05:09:43 -07:00
|
|
|
|
2006-10-14 09:51:30 -07:00
|
|
|
gimp_image_undo_group_end (image);
|
2003-06-03 09:42:46 -07:00
|
|
|
|
2006-10-14 09:51:30 -07:00
|
|
|
gimp_image_flush (image);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
g_warning ("Scale Error: "
|
|
|
|
|
"Both width and height must be greater than zero.");
|
|
|
|
|
}
|
2001-06-26 05:09:43 -07:00
|
|
|
}
|
2004-05-25 07:37:02 -07:00
|
|
|
|
|
|
|
|
static void
|
2016-09-23 10:44:11 -07:00
|
|
|
image_merge_layers_callback (GtkWidget *dialog,
|
|
|
|
|
GimpImage *image,
|
|
|
|
|
GimpContext *context,
|
|
|
|
|
GimpMergeType merge_type,
|
|
|
|
|
gboolean merge_active_group,
|
app: merge layers in chunks, and show progress
In gimp_image_merge_layers() -- the internal function used by the
various layer-merging/flattenning functions -- process the merged-
layer graph in chunks, using gimp_gegl_apply_operation(), instead
of in one go, using gegl_node_blit_buffer(). Processing in chunks
better utilizes the cache, since it reduces the size of
intermediate buffers, reducing the chances of hitting the swap when
merging large images (see, for example, issue #3012.)
Additionally, this allows us to show progress indication. Have the
relevant gimpimage-merge functions take a GimpProgress, and pass it
down to gimp_image_merge_layers(). Adapt all callers.
(cherry picked from commit e83d8ac4f2dc0260e97a91938ae3e34608efdbf9)
2019-02-25 01:49:04 -08:00
|
|
|
gboolean discard_invisible,
|
|
|
|
|
gpointer user_data)
|
2004-05-25 07:37:02 -07:00
|
|
|
{
|
app: merge layers in chunks, and show progress
In gimp_image_merge_layers() -- the internal function used by the
various layer-merging/flattenning functions -- process the merged-
layer graph in chunks, using gimp_gegl_apply_operation(), instead
of in one go, using gegl_node_blit_buffer(). Processing in chunks
better utilizes the cache, since it reduces the size of
intermediate buffers, reducing the chances of hitting the swap when
merging large images (see, for example, issue #3012.)
Additionally, this allows us to show progress indication. Have the
relevant gimpimage-merge functions take a GimpProgress, and pass it
down to gimp_image_merge_layers(). Adapt all callers.
(cherry picked from commit e83d8ac4f2dc0260e97a91938ae3e34608efdbf9)
2019-02-25 01:49:04 -08:00
|
|
|
GimpDialogConfig *config = GIMP_DIALOG_CONFIG (image->gimp->config);
|
|
|
|
|
GimpDisplay *display = user_data;
|
2016-09-24 03:33:42 -07:00
|
|
|
|
|
|
|
|
g_object_set (config,
|
|
|
|
|
"layer-merge-type", merge_type,
|
|
|
|
|
"layer-merge-active-group-only", merge_active_group,
|
|
|
|
|
"layer-merge-discard-invisible", discard_invisible,
|
|
|
|
|
NULL);
|
2004-10-23 12:13:17 -07:00
|
|
|
|
2016-09-23 10:44:11 -07:00
|
|
|
gimp_image_merge_visible_layers (image,
|
|
|
|
|
context,
|
2016-09-24 03:33:42 -07:00
|
|
|
config->layer_merge_type,
|
|
|
|
|
config->layer_merge_active_group_only,
|
app: merge layers in chunks, and show progress
In gimp_image_merge_layers() -- the internal function used by the
various layer-merging/flattenning functions -- process the merged-
layer graph in chunks, using gimp_gegl_apply_operation(), instead
of in one go, using gegl_node_blit_buffer(). Processing in chunks
better utilizes the cache, since it reduces the size of
intermediate buffers, reducing the chances of hitting the swap when
merging large images (see, for example, issue #3012.)
Additionally, this allows us to show progress indication. Have the
relevant gimpimage-merge functions take a GimpProgress, and pass it
down to gimp_image_merge_layers(). Adapt all callers.
(cherry picked from commit e83d8ac4f2dc0260e97a91938ae3e34608efdbf9)
2019-02-25 01:49:04 -08:00
|
|
|
config->layer_merge_discard_invisible,
|
|
|
|
|
GIMP_PROGRESS (display));
|
2006-04-07 01:01:02 -07:00
|
|
|
|
2016-09-23 10:44:11 -07:00
|
|
|
gimp_image_flush (image);
|
2004-05-25 07:37:02 -07:00
|
|
|
|
2016-09-23 10:44:11 -07:00
|
|
|
gtk_widget_destroy (dialog);
|
2004-05-25 07:37:02 -07:00
|
|
|
}
|