gimp/app/core/gimpimage-resize.c

328 lines
9.8 KiB
C
Raw Normal View History

/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* 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
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gegl.h>
#include "libgimpbase/gimpbase.h"
#include "core-types.h"
app/core/Makefile.am app/core/core-types.h added an "application object" 2001-07-04 Michael Natterer <mitch@gimp.org> * app/core/Makefile.am * app/core/core-types.h * app/core/gimp.[ch]: added an "application object" called Gimp. Currently, it contains the image list, the clipboard, the data factories, the procedural hashtable and the tool info list. It's the toplevel object of the core object system. Finally, creating a Gimp object will return a standalone gimp core engine instance with no other global states/variables involved. * app/app_procs.[ch]: allocate a "Gimp" instance called "the_gimp" :) Removed stuff which is now done by the "Gimp" object. Merged gimp_init() into app_init() because gimp_init() is taken now. * app/context_manager.[ch]: removed stuff done by "Gimp". * app/batch.[ch] * app/gimage.[ch] * app/xcf/xcf-load.[ch] * app/xcf/xcf.[ch] * app/core/gimpedit.[ch] * app/tools/tool_manager.[ch]: pass around an additional "Gimp" argument. * app/pdb/procedural_db.[ch]: pass a "Gimp" pointer as first parameter to all internal procedures and to all procedural_db_* functions. * app/core/gimpcontext.[ch] * app/core/gimpimage.[ch]: added a "Gimp" pointer to the structs. * app/devices.c * app/errors.c * app/file-open.c * app/file-save.c * app/gimphelp.c * app/gimpunit.c * app/image_new.c * app/main.c * app/nav_window.c * app/plug_in.c * app/base/base.c * app/core/gimpdatafactory.c * app/core/gimpimage-duplicate.c * app/core/gimpimage-mask.c * app/core/gimptoolinfo.[ch] * app/gui/brush-select.c * app/gui/convert-dialog.c * app/gui/dialogs-constructors.c * app/gui/edit-commands.c * app/gui/file-open-dialog.c * app/gui/file-save-dialog.c * app/gui/gradient-editor.c * app/gui/gradient-select.c * app/gui/gui.c * app/gui/image-commands.c * app/gui/info-window.c * app/gui/menus.c * app/gui/palette-editor.c * app/gui/palette-import-dialog.c * app/gui/palette-select.c * app/gui/paths-dialog.c * app/gui/pattern-select.c * app/gui/preferences-dialog.c * app/gui/test-commands.c * app/gui/toolbox.c * app/gui/tools-commands.c * app/tools/gimpbezierselecttool.c * app/tools/gimpbucketfilltool.c * app/tools/gimppainttool.h * app/tools/gimptexttool.c * app/tools/gimptransformtool.h * app/widgets/gimpbufferview.c * app/widgets/gimpcontainerview-utils.c * app/widgets/gimpcursor.c * app/widgets/gimpdnd.c * app/widgets/gimpimagedock.c: changed accordingly. Cleaned up lots of includes. Many files still access the global "the_gimp" variable exported by app_procs.h. * tools/pdbgen/app.pl * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/brushes.pdb * tools/pdbgen/pdb/convert.pdb * tools/pdbgen/pdb/edit.pdb * tools/pdbgen/pdb/fileops.pdb * tools/pdbgen/pdb/gradient_select.pdb * tools/pdbgen/pdb/gradients.pdb * tools/pdbgen/pdb/image.pdb * tools/pdbgen/pdb/palette.pdb * tools/pdbgen/pdb/pattern_select.pdb * tools/pdbgen/pdb/patterns.pdb * tools/pdbgen/pdb/procedural_db.pdb: changed accordingly. Don't use "the_gimp" here because all procedures get passed a "Gimp" pointer now. * app/pdb/*: regenerated.
2001-07-05 03:31:35 +08:00
#include "gimp.h"
#include "gimpcontainer.h"
Get rid of the "current_context" which was in fact just a bunch of global 2004-04-15 Michael Natterer <mitch@gimp.org> Get rid of the "current_context" which was in fact just a bunch of global variables. Instead, pass the needed context all the way from the GUI and the PDB to the core. This is a prerequisite for macro recording and generally helps separating the various subsystems from each other. Work in progress... * app/core/gimp.[ch]: removed member "current_context" and gimp_[get|set]_current_context(). * app/core/gimp-edit.[ch] * app/core/gimpdrawable-blend.[ch] * app/core/gimpdrawable-bucket-fill.[ch] * app/core/gimpdrawable-offset.[ch] * app/core/gimpdrawable-transform.[ch] * app/core/gimpimage-crop.[ch] * app/core/gimpimage-flip.[ch] * app/core/gimpimage-merge.[ch] * app/core/gimpimage-resize.[ch] * app/core/gimpimage-rotate.[ch] * app/core/gimpimage.[ch] * app/core/gimpimagefile.[ch] * app/core/gimpitem-linked.[ch] * app/core/gimpitem.[ch] * app/core/gimplayer.[ch] * app/core/gimpselection.[ch] * app/core/gimptemplate.[ch] * app/file/file-open.[ch] * app/file/file-save.[ch] * app/pdb/procedural_db.[ch] * app/text/gimptext-compat.[ch] * app/text/gimptextlayer-transform.[ch] * app/gui/brush-select.[ch] * app/gui/font-select.[ch] * app/gui/gradient-select.[ch] * app/gui/palette-select.[ch] * app/gui/pattern-select.[ch]: added tons of "GimpContext *context" parameters and use the passed context instead of gimp_get_current_context(). * app/app_procs.c * app/batch.c * app/core/gimpchannel.c * app/core/gimpdrawable.c * app/paint/gimperaser.c * app/paint/gimppaintbrush.c * app/plug-in/plug-in-message.c * app/plug-in/plug-ins.c * app/text/gimptextlayer.c * app/tools/gimpblendtool.c * app/tools/gimpbucketfilltool.c * app/tools/gimpcroptool.c * app/tools/gimpeditselectiontool.c * app/tools/gimpfliptool.c * app/tools/gimpinktool.c * app/tools/gimptransformtool.c * app/vectors/gimpvectors.c * app/gui/convert-dialog.c * app/gui/drawable-commands.c * app/gui/edit-commands.c * app/gui/file-commands.c * app/gui/file-new-dialog.c * app/gui/file-open-dialog.c * app/gui/file-save-dialog.c * app/gui/image-commands.c * app/gui/layers-commands.c * app/gui/offset-dialog.c * app/gui/select-commands.c * app/gui/vectors-commands.c * app/widgets/gimpdnd.c * app/widgets/gimpdocumentview.c * app/widgets/gimphelp.c * app/widgets/gimpthumbbox.c: pass gimp_get_user_context() or GIMP_CONTEXT(tool_options) or whatever is the right context to the changed core functions. * tools/pdbgen/app.pl: pass "GimpContext *context" to all generated PDB invokers. * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/brushes.pdb * tools/pdbgen/pdb/drawable.pdb * tools/pdbgen/pdb/edit.pdb * tools/pdbgen/pdb/font_select.pdb * tools/pdbgen/pdb/gradient_select.pdb * tools/pdbgen/pdb/gradients.pdb * tools/pdbgen/pdb/image.pdb * tools/pdbgen/pdb/layer.pdb * tools/pdbgen/pdb/paint_tools.pdb * tools/pdbgen/pdb/palette.pdb * tools/pdbgen/pdb/palette_select.pdb * tools/pdbgen/pdb/palettes.pdb * tools/pdbgen/pdb/paths.pdb * tools/pdbgen/pdb/pattern_select.pdb * tools/pdbgen/pdb/patterns.pdb * tools/pdbgen/pdb/selection.pdb * tools/pdbgen/pdb/text_tool.pdb * tools/pdbgen/pdb/transform_tools.pdb: pass the new context parameter to the changed core functions. * app/pdb/*_cmds.c: regenerated.
2004-04-15 07:37:34 +08:00
#include "gimpcontext.h"
#include "gimpguide.h"
app/Makefile.am app/channel_pvt.h app/drawable_pvt.h app/gdisplayF.h 2000-12-29 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/channel_pvt.h * app/drawable_pvt.h * app/gdisplayF.h * app/gimpdrawableP.h * app/gimpimageP.h * app/layer_pvt.h * app/toolsF.h: removed these files. * app/apptypes.h * tools/pdbgen/enums.pl: added tons of opaque typedefs and enums. * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/brushes.pdb * tools/pdbgen/pdb/channel.pdb * tools/pdbgen/pdb/color.pdb * tools/pdbgen/pdb/convert.pdb * tools/pdbgen/pdb/display.pdb * tools/pdbgen/pdb/drawable.pdb * tools/pdbgen/pdb/fileops.pdb * tools/pdbgen/pdb/gradient_select.pdb * tools/pdbgen/pdb/gradients.pdb * tools/pdbgen/pdb/help.pdb * tools/pdbgen/pdb/image.pdb * tools/pdbgen/pdb/layer.pdb * tools/pdbgen/pdb/pattern_select.pdb * tools/pdbgen/pdb/patterns.pdb * tools/pdbgen/pdb/selection.pdb * tools/pdbgen/pdb/tools.pdb * app/*: chainsaw #include cleanup: - Never (never!!) include stuff in header files except where we need access to structures' contents (like derived objects). - Added prototypes and proper formating in many files. - The #include order in *all* *.c files is as follows: #include "config.h" #include <system stuff> #include <gtk/gtk.h> #include "apptypes.h" #include "gimp stuff" #include "libgimp stuff" #include "libgimp/gimpintl.h" By following this scheme we can easily see a file's dependencies from it's #include's and can grep for the inclusion to find out where a file is used. * tools/pdbgen/app.pl: changed to follow the include scheme above. * libgimp/Makefile.am * libgimp/gimpuitypes.h: new file, included from libgimp/gimpui.h and from app/apptypes.h. * libgimp/gimpcolorbutton.[ch] * libgimp/gimpdialog.[ch] * libgimp/gimphelpui.[ch] * libgimp/gimpparasite.[ch] * libgimp/gimppatheditor.[ch] * libgimp/gimpprotocol.c * libgimp/gimpquerybox.[ch] * libgimp/gimpsizeentry.[ch] * libgimp/gimptypes.h * libgimp/gimpui.h * libgimp/gimpunit.h * libgimp/gimpunitmenu.[ch] * libgimp/gimpwidgets.[ch]: changed accordingly. * plug-ins/FractalExplorer/Dialogs.c * plug-ins/gdyntext/message_window.c * plug-ins/imagemap/imap_default_dialog.c * plug-ins/imagemap/imap_file.c: these files used to include "libgimp/gimpui.h" without including "libgimp/gimp.h". This is no longer possible because the libgimpui headers don't inlcude "libgimp/gimpunit.h" any more.
2000-12-29 23:22:01 +08:00
#include "gimpimage.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-29 01:51:06 +08:00
#include "gimpimage-guides.h"
#include "gimpimage-item-list.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-29 01:51:06 +08:00
#include "gimpimage-resize.h"
#include "gimpimage-sample-points.h"
#include "gimpimage-undo.h"
Moved the undo step implementations to the core and pass around lots of 2003-02-14 Michael Natterer <mitch@gimp.org> Moved the undo step implementations to the core and pass around lots of "const gchar *undo_desc". Fixes bug #104367. * app/Makefile.am * app/undo.[ch]: removed... * app/core/Makefile.am * app/core/gimpimage-undo-push.[ch]: ...and added here. * app/paint/Makefile.am * app/tools/Makefile.am * app/paint/gimppaintcore-undo.[ch] * app/tools/gimptransformtool-undo.[ch]: new files for the paint and transform undos. * app/core/gimppaintinfo.[ch]: added a blurb. * app/paint/gimpairbrush.c * app/paint/gimpclone.c * app/paint/gimpconvolve.c * app/paint/gimpdodgeburn.c * app/paint/gimperaser.c * app/paint/gimppaintbrush.c * app/paint/gimppaintcore.c * app/paint/gimppencil.c * app/paint/gimpsmudge.c * app/paint/paint-types.h * app/paint/paint.c: pass the blurb when registering the core. * app/core/gimpdrawable.[ch] * app/core/gimpimage.[ch] * app/core/gimpimage-mask-select.[ch] * app/core/gimpimage-mask.[ch] * app/core/gimpimagemap.[ch] * app/core/gimplayer-floating-sel.[ch]: added "undo_desc" parameters to all undo pushing helper functions. * app/undo_history.c * app/core/gimpchannel.c * app/core/gimpdrawable-blend.c * app/core/gimpdrawable-bucket-fill.c * app/core/gimpdrawable-desaturate.c * app/core/gimpdrawable-equalize.c * app/core/gimpdrawable-invert.c * app/core/gimpdrawable-offset.c * app/core/gimpdrawable-transform.c * app/core/gimpedit.c * app/core/gimpimage-convert.c * app/core/gimpimage-crop.c * app/core/gimpimage-guides.c * app/core/gimpimage-merge.c * app/core/gimpimage-qmask.c * app/core/gimpimage-resize.c * app/core/gimpimage-scale.c * app/core/gimpimage-undo.c * app/core/gimpitem.c * app/core/gimplayer.c * app/core/gimplayermask.c * app/display/gimpdisplayshell-dnd.c * app/file/file-open.c * app/file/file-save.c * app/gui/channels-commands.c * app/gui/file-commands.c * app/gui/file-open-dialog.c * app/gui/image-commands.c * app/gui/layers-commands.c * app/gui/paths-dialog.c * app/gui/select-commands.c * app/gui/vectors-commands.c * app/text/gimptext-compat.c * app/tools/gimpbezierselecttool.c * app/tools/gimpbucketfilltool.c * app/tools/gimpeditselectiontool.c * app/tools/gimpfreeselecttool.c * app/tools/gimpfuzzyselecttool.c * app/tools/gimpimagemaptool.c * app/tools/gimpinktool.c * app/tools/gimpiscissorstool.c * app/tools/gimpmeasuretool.c * app/tools/gimpmovetool.c * app/tools/gimppainttool.c * app/tools/gimprectselecttool.c * app/tools/gimptexttool.c * app/tools/gimptransformtool.c * app/widgets/gimpchannellistview.c * app/widgets/gimpdrawablelistview.c * app/widgets/gimpselectioneditor.c * tools/pdbgen/pdb/color.pdb * tools/pdbgen/pdb/drawable.pdb * tools/pdbgen/pdb/guides.pdb * tools/pdbgen/pdb/layer.pdb * tools/pdbgen/pdb/selection.pdb * tools/pdbgen/pdb/selection_tools.pdb: changed accordingly: pass "undo_desc" strings, changed includes or simply removed inclusion of "undo.h". Some random cleanups. * tools/pdbgen/pdb/guides.pdb: cleaned up a lot. Fixed gimp_image_find_next_guide() to not return guides with position < 0 (and made it shorter and readable). * app/pdb/color_cmds.c * app/pdb/drawable_cmds.c * app/pdb/guides_cmds.c * app/pdb/layer_cmds.c * app/pdb/selection_cmds.c * app/pdb/selection_tools_cmds.c: regenerated.
2003-02-14 22:14:29 +08:00
#include "gimpimage-undo-push.h"
#include "gimplayer.h"
#include "gimpobjectqueue.h"
Redid the whole internal progress stuff: don't pass around 2004-08-10 Michael Natterer <mitch@gimp.org> Redid the whole internal progress stuff: don't pass around progress_callback and progress_data; instead, provide a pointer to a GimpProgressInterface which can be implemented by a variety of backends. Addresses (but not yet fixes) bugs #6010, #97266 and #135185. * app/display/Makefile.am * app/display/gimpprogress.[ch]: removed the old progress hack. * app/core/Makefile.am * app/core/core-types.h * app/core/gimpprogress.[ch]: implement GimpProgressInterface. * app/widgets/Makefile.am * app/widgets/widgets-types.h * app/widgets/gimpprogressdialog.[ch]: the standalone progress dialog as widget implementing GimpProgressInterface. * app/display/gimpdisplay.c * app/display/gimpstatusbar.[ch] * app/widgets/gimpfiledialog.[ch] * app/widgets/gimpthumbbox.[ch]: added GimpProgressInterface implementation to these classes. * app/core/gimp-gui.[ch] * app/gui/gui-vtable.c: replaced the old progress vtable entries by two new to create and destroy a GimpProgressDialog in case no other progress is available. * app/pdb/procedural_db.[ch] * app/plug-in/plug-in-run.[ch] * tools/pdbgen/app.pl: pass a GimpProgress to all PDB wrappers and all plug-ins. * app/plug-in/plug-in.[ch] * app/plug-in/plug-ins.c * app/plug-in/plug-in-message.c * app/plug-in/plug-in-progress.c: handle the case there the plug-in was crated with a progress as well as the case where it wasn't. * app/app_procs.c * app/batch.c * app/xcf/xcf.c * app/file/file-open.[ch] * app/file/file-save.[ch] * app/widgets/gimphelp.c * app/widgets/gimpbrushselect.c * app/widgets/gimpfontselect.c * app/widgets/gimpgradientselect.c * app/widgets/gimppaletteselect.c * app/widgets/gimppatternselect.c: changed accordingly. * app/core/gimpimagefile.[ch] * app/display/gimpdisplayshell-dnd.c * app/gui/file-open-dialog.c * app/gui/file-open-location-dialog.c * app/gui/file-save-dialog.c * app/widgets/gimplayertreeview.c * app/widgets/gimptoolbox-dnd.c: pass a GimpProgress to all file related functions. Embed the progress in the file dialog where possible. * app/core/gimpdrawable-blend.[ch] * app/core/gimpdrawable-transform.[ch] * app/core/gimpimage-convert.[ch] * app/core/gimpimage-flip.[ch] * app/core/gimpimage-resize.[ch] * app/core/gimpimage-rotate.[ch] * app/core/gimpimage-scale.[ch] * app/core/gimpitem-linked.[ch] * app/core/gimpitem.[ch] * app/core/gimpchannel.c * app/core/gimpdrawable.c * app/core/gimplayer.c * app/core/gimpselection.c * app/vectors/gimpvectors.c: replaced callback/data by GimpProgress. * app/tools/gimpblendtool.c * app/tools/gimptransformtool.c * app/gui/convert-dialog.c * app/actions/documents-commands.c * app/actions/file-commands.c * app/actions/image-commands.c * app/actions/layers-commands.c * app/actions/plug-in-commands.c * app/actions/vectors-commands.c * tools/pdbgen/pdb/convert.pdb * tools/pdbgen/pdb/edit.pdb * tools/pdbgen/pdb/image.pdb * tools/pdbgen/pdb/layer.pdb: changed callers accordingly. * app/pdb/*_cmds.c: regenerated.
2004-08-11 02:47:21 +08:00
#include "gimpprogress.h"
#include "gimpsamplepoint.h"
app/core/Makefile.am app/core/core-types.h added an "application object" 2001-07-04 Michael Natterer <mitch@gimp.org> * app/core/Makefile.am * app/core/core-types.h * app/core/gimp.[ch]: added an "application object" called Gimp. Currently, it contains the image list, the clipboard, the data factories, the procedural hashtable and the tool info list. It's the toplevel object of the core object system. Finally, creating a Gimp object will return a standalone gimp core engine instance with no other global states/variables involved. * app/app_procs.[ch]: allocate a "Gimp" instance called "the_gimp" :) Removed stuff which is now done by the "Gimp" object. Merged gimp_init() into app_init() because gimp_init() is taken now. * app/context_manager.[ch]: removed stuff done by "Gimp". * app/batch.[ch] * app/gimage.[ch] * app/xcf/xcf-load.[ch] * app/xcf/xcf.[ch] * app/core/gimpedit.[ch] * app/tools/tool_manager.[ch]: pass around an additional "Gimp" argument. * app/pdb/procedural_db.[ch]: pass a "Gimp" pointer as first parameter to all internal procedures and to all procedural_db_* functions. * app/core/gimpcontext.[ch] * app/core/gimpimage.[ch]: added a "Gimp" pointer to the structs. * app/devices.c * app/errors.c * app/file-open.c * app/file-save.c * app/gimphelp.c * app/gimpunit.c * app/image_new.c * app/main.c * app/nav_window.c * app/plug_in.c * app/base/base.c * app/core/gimpdatafactory.c * app/core/gimpimage-duplicate.c * app/core/gimpimage-mask.c * app/core/gimptoolinfo.[ch] * app/gui/brush-select.c * app/gui/convert-dialog.c * app/gui/dialogs-constructors.c * app/gui/edit-commands.c * app/gui/file-open-dialog.c * app/gui/file-save-dialog.c * app/gui/gradient-editor.c * app/gui/gradient-select.c * app/gui/gui.c * app/gui/image-commands.c * app/gui/info-window.c * app/gui/menus.c * app/gui/palette-editor.c * app/gui/palette-import-dialog.c * app/gui/palette-select.c * app/gui/paths-dialog.c * app/gui/pattern-select.c * app/gui/preferences-dialog.c * app/gui/test-commands.c * app/gui/toolbox.c * app/gui/tools-commands.c * app/tools/gimpbezierselecttool.c * app/tools/gimpbucketfilltool.c * app/tools/gimppainttool.h * app/tools/gimptexttool.c * app/tools/gimptransformtool.h * app/widgets/gimpbufferview.c * app/widgets/gimpcontainerview-utils.c * app/widgets/gimpcursor.c * app/widgets/gimpdnd.c * app/widgets/gimpimagedock.c: changed accordingly. Cleaned up lots of includes. Many files still access the global "the_gimp" variable exported by app_procs.h. * tools/pdbgen/app.pl * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/brushes.pdb * tools/pdbgen/pdb/convert.pdb * tools/pdbgen/pdb/edit.pdb * tools/pdbgen/pdb/fileops.pdb * tools/pdbgen/pdb/gradient_select.pdb * tools/pdbgen/pdb/gradients.pdb * tools/pdbgen/pdb/image.pdb * tools/pdbgen/pdb/palette.pdb * tools/pdbgen/pdb/pattern_select.pdb * tools/pdbgen/pdb/patterns.pdb * tools/pdbgen/pdb/procedural_db.pdb: changed accordingly. Don't use "the_gimp" here because all procedures get passed a "Gimp" pointer now. * app/pdb/*: regenerated.
2001-07-05 03:31:35 +08:00
#include "text/gimptextlayer.h"
#include "gimp-intl.h"
void
gimp_image_resize (GimpImage *image,
Redid the whole internal progress stuff: don't pass around 2004-08-10 Michael Natterer <mitch@gimp.org> Redid the whole internal progress stuff: don't pass around progress_callback and progress_data; instead, provide a pointer to a GimpProgressInterface which can be implemented by a variety of backends. Addresses (but not yet fixes) bugs #6010, #97266 and #135185. * app/display/Makefile.am * app/display/gimpprogress.[ch]: removed the old progress hack. * app/core/Makefile.am * app/core/core-types.h * app/core/gimpprogress.[ch]: implement GimpProgressInterface. * app/widgets/Makefile.am * app/widgets/widgets-types.h * app/widgets/gimpprogressdialog.[ch]: the standalone progress dialog as widget implementing GimpProgressInterface. * app/display/gimpdisplay.c * app/display/gimpstatusbar.[ch] * app/widgets/gimpfiledialog.[ch] * app/widgets/gimpthumbbox.[ch]: added GimpProgressInterface implementation to these classes. * app/core/gimp-gui.[ch] * app/gui/gui-vtable.c: replaced the old progress vtable entries by two new to create and destroy a GimpProgressDialog in case no other progress is available. * app/pdb/procedural_db.[ch] * app/plug-in/plug-in-run.[ch] * tools/pdbgen/app.pl: pass a GimpProgress to all PDB wrappers and all plug-ins. * app/plug-in/plug-in.[ch] * app/plug-in/plug-ins.c * app/plug-in/plug-in-message.c * app/plug-in/plug-in-progress.c: handle the case there the plug-in was crated with a progress as well as the case where it wasn't. * app/app_procs.c * app/batch.c * app/xcf/xcf.c * app/file/file-open.[ch] * app/file/file-save.[ch] * app/widgets/gimphelp.c * app/widgets/gimpbrushselect.c * app/widgets/gimpfontselect.c * app/widgets/gimpgradientselect.c * app/widgets/gimppaletteselect.c * app/widgets/gimppatternselect.c: changed accordingly. * app/core/gimpimagefile.[ch] * app/display/gimpdisplayshell-dnd.c * app/gui/file-open-dialog.c * app/gui/file-open-location-dialog.c * app/gui/file-save-dialog.c * app/widgets/gimplayertreeview.c * app/widgets/gimptoolbox-dnd.c: pass a GimpProgress to all file related functions. Embed the progress in the file dialog where possible. * app/core/gimpdrawable-blend.[ch] * app/core/gimpdrawable-transform.[ch] * app/core/gimpimage-convert.[ch] * app/core/gimpimage-flip.[ch] * app/core/gimpimage-resize.[ch] * app/core/gimpimage-rotate.[ch] * app/core/gimpimage-scale.[ch] * app/core/gimpitem-linked.[ch] * app/core/gimpitem.[ch] * app/core/gimpchannel.c * app/core/gimpdrawable.c * app/core/gimplayer.c * app/core/gimpselection.c * app/vectors/gimpvectors.c: replaced callback/data by GimpProgress. * app/tools/gimpblendtool.c * app/tools/gimptransformtool.c * app/gui/convert-dialog.c * app/actions/documents-commands.c * app/actions/file-commands.c * app/actions/image-commands.c * app/actions/layers-commands.c * app/actions/plug-in-commands.c * app/actions/vectors-commands.c * tools/pdbgen/pdb/convert.pdb * tools/pdbgen/pdb/edit.pdb * tools/pdbgen/pdb/image.pdb * tools/pdbgen/pdb/layer.pdb: changed callers accordingly. * app/pdb/*_cmds.c: regenerated.
2004-08-11 02:47:21 +08:00
GimpContext *context,
gint new_width,
gint new_height,
gint offset_x,
gint offset_y,
Redid the whole internal progress stuff: don't pass around 2004-08-10 Michael Natterer <mitch@gimp.org> Redid the whole internal progress stuff: don't pass around progress_callback and progress_data; instead, provide a pointer to a GimpProgressInterface which can be implemented by a variety of backends. Addresses (but not yet fixes) bugs #6010, #97266 and #135185. * app/display/Makefile.am * app/display/gimpprogress.[ch]: removed the old progress hack. * app/core/Makefile.am * app/core/core-types.h * app/core/gimpprogress.[ch]: implement GimpProgressInterface. * app/widgets/Makefile.am * app/widgets/widgets-types.h * app/widgets/gimpprogressdialog.[ch]: the standalone progress dialog as widget implementing GimpProgressInterface. * app/display/gimpdisplay.c * app/display/gimpstatusbar.[ch] * app/widgets/gimpfiledialog.[ch] * app/widgets/gimpthumbbox.[ch]: added GimpProgressInterface implementation to these classes. * app/core/gimp-gui.[ch] * app/gui/gui-vtable.c: replaced the old progress vtable entries by two new to create and destroy a GimpProgressDialog in case no other progress is available. * app/pdb/procedural_db.[ch] * app/plug-in/plug-in-run.[ch] * tools/pdbgen/app.pl: pass a GimpProgress to all PDB wrappers and all plug-ins. * app/plug-in/plug-in.[ch] * app/plug-in/plug-ins.c * app/plug-in/plug-in-message.c * app/plug-in/plug-in-progress.c: handle the case there the plug-in was crated with a progress as well as the case where it wasn't. * app/app_procs.c * app/batch.c * app/xcf/xcf.c * app/file/file-open.[ch] * app/file/file-save.[ch] * app/widgets/gimphelp.c * app/widgets/gimpbrushselect.c * app/widgets/gimpfontselect.c * app/widgets/gimpgradientselect.c * app/widgets/gimppaletteselect.c * app/widgets/gimppatternselect.c: changed accordingly. * app/core/gimpimagefile.[ch] * app/display/gimpdisplayshell-dnd.c * app/gui/file-open-dialog.c * app/gui/file-open-location-dialog.c * app/gui/file-save-dialog.c * app/widgets/gimplayertreeview.c * app/widgets/gimptoolbox-dnd.c: pass a GimpProgress to all file related functions. Embed the progress in the file dialog where possible. * app/core/gimpdrawable-blend.[ch] * app/core/gimpdrawable-transform.[ch] * app/core/gimpimage-convert.[ch] * app/core/gimpimage-flip.[ch] * app/core/gimpimage-resize.[ch] * app/core/gimpimage-rotate.[ch] * app/core/gimpimage-scale.[ch] * app/core/gimpitem-linked.[ch] * app/core/gimpitem.[ch] * app/core/gimpchannel.c * app/core/gimpdrawable.c * app/core/gimplayer.c * app/core/gimpselection.c * app/vectors/gimpvectors.c: replaced callback/data by GimpProgress. * app/tools/gimpblendtool.c * app/tools/gimptransformtool.c * app/gui/convert-dialog.c * app/actions/documents-commands.c * app/actions/file-commands.c * app/actions/image-commands.c * app/actions/layers-commands.c * app/actions/plug-in-commands.c * app/actions/vectors-commands.c * tools/pdbgen/pdb/convert.pdb * tools/pdbgen/pdb/edit.pdb * tools/pdbgen/pdb/image.pdb * tools/pdbgen/pdb/layer.pdb: changed callers accordingly. * app/pdb/*_cmds.c: regenerated.
2004-08-11 02:47:21 +08:00
GimpProgress *progress)
{
gimp_image_resize_with_layers (image, context, GIMP_FILL_TRANSPARENT,
new_width, new_height, offset_x, offset_y,
GIMP_ITEM_SET_NONE, TRUE,
progress);
}
void
gimp_image_resize_with_layers (GimpImage *image,
GimpContext *context,
GimpFillType fill_type,
gint new_width,
gint new_height,
gint offset_x,
gint offset_y,
GimpItemSet layer_set,
gboolean resize_text_layers,
GimpProgress *progress)
{
GimpObjectQueue *queue;
GList *resize_layers;
GList *list;
GimpItem *item;
gint old_width, old_height;
g_return_if_fail (GIMP_IS_IMAGE (image));
Get rid of the "current_context" which was in fact just a bunch of global 2004-04-15 Michael Natterer <mitch@gimp.org> Get rid of the "current_context" which was in fact just a bunch of global variables. Instead, pass the needed context all the way from the GUI and the PDB to the core. This is a prerequisite for macro recording and generally helps separating the various subsystems from each other. Work in progress... * app/core/gimp.[ch]: removed member "current_context" and gimp_[get|set]_current_context(). * app/core/gimp-edit.[ch] * app/core/gimpdrawable-blend.[ch] * app/core/gimpdrawable-bucket-fill.[ch] * app/core/gimpdrawable-offset.[ch] * app/core/gimpdrawable-transform.[ch] * app/core/gimpimage-crop.[ch] * app/core/gimpimage-flip.[ch] * app/core/gimpimage-merge.[ch] * app/core/gimpimage-resize.[ch] * app/core/gimpimage-rotate.[ch] * app/core/gimpimage.[ch] * app/core/gimpimagefile.[ch] * app/core/gimpitem-linked.[ch] * app/core/gimpitem.[ch] * app/core/gimplayer.[ch] * app/core/gimpselection.[ch] * app/core/gimptemplate.[ch] * app/file/file-open.[ch] * app/file/file-save.[ch] * app/pdb/procedural_db.[ch] * app/text/gimptext-compat.[ch] * app/text/gimptextlayer-transform.[ch] * app/gui/brush-select.[ch] * app/gui/font-select.[ch] * app/gui/gradient-select.[ch] * app/gui/palette-select.[ch] * app/gui/pattern-select.[ch]: added tons of "GimpContext *context" parameters and use the passed context instead of gimp_get_current_context(). * app/app_procs.c * app/batch.c * app/core/gimpchannel.c * app/core/gimpdrawable.c * app/paint/gimperaser.c * app/paint/gimppaintbrush.c * app/plug-in/plug-in-message.c * app/plug-in/plug-ins.c * app/text/gimptextlayer.c * app/tools/gimpblendtool.c * app/tools/gimpbucketfilltool.c * app/tools/gimpcroptool.c * app/tools/gimpeditselectiontool.c * app/tools/gimpfliptool.c * app/tools/gimpinktool.c * app/tools/gimptransformtool.c * app/vectors/gimpvectors.c * app/gui/convert-dialog.c * app/gui/drawable-commands.c * app/gui/edit-commands.c * app/gui/file-commands.c * app/gui/file-new-dialog.c * app/gui/file-open-dialog.c * app/gui/file-save-dialog.c * app/gui/image-commands.c * app/gui/layers-commands.c * app/gui/offset-dialog.c * app/gui/select-commands.c * app/gui/vectors-commands.c * app/widgets/gimpdnd.c * app/widgets/gimpdocumentview.c * app/widgets/gimphelp.c * app/widgets/gimpthumbbox.c: pass gimp_get_user_context() or GIMP_CONTEXT(tool_options) or whatever is the right context to the changed core functions. * tools/pdbgen/app.pl: pass "GimpContext *context" to all generated PDB invokers. * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/brushes.pdb * tools/pdbgen/pdb/drawable.pdb * tools/pdbgen/pdb/edit.pdb * tools/pdbgen/pdb/font_select.pdb * tools/pdbgen/pdb/gradient_select.pdb * tools/pdbgen/pdb/gradients.pdb * tools/pdbgen/pdb/image.pdb * tools/pdbgen/pdb/layer.pdb * tools/pdbgen/pdb/paint_tools.pdb * tools/pdbgen/pdb/palette.pdb * tools/pdbgen/pdb/palette_select.pdb * tools/pdbgen/pdb/palettes.pdb * tools/pdbgen/pdb/paths.pdb * tools/pdbgen/pdb/pattern_select.pdb * tools/pdbgen/pdb/patterns.pdb * tools/pdbgen/pdb/selection.pdb * tools/pdbgen/pdb/text_tool.pdb * tools/pdbgen/pdb/transform_tools.pdb: pass the new context parameter to the changed core functions. * app/pdb/*_cmds.c: regenerated.
2004-04-15 07:37:34 +08:00
g_return_if_fail (GIMP_IS_CONTEXT (context));
g_return_if_fail (new_width > 0 && new_height > 0);
Redid the whole internal progress stuff: don't pass around 2004-08-10 Michael Natterer <mitch@gimp.org> Redid the whole internal progress stuff: don't pass around progress_callback and progress_data; instead, provide a pointer to a GimpProgressInterface which can be implemented by a variety of backends. Addresses (but not yet fixes) bugs #6010, #97266 and #135185. * app/display/Makefile.am * app/display/gimpprogress.[ch]: removed the old progress hack. * app/core/Makefile.am * app/core/core-types.h * app/core/gimpprogress.[ch]: implement GimpProgressInterface. * app/widgets/Makefile.am * app/widgets/widgets-types.h * app/widgets/gimpprogressdialog.[ch]: the standalone progress dialog as widget implementing GimpProgressInterface. * app/display/gimpdisplay.c * app/display/gimpstatusbar.[ch] * app/widgets/gimpfiledialog.[ch] * app/widgets/gimpthumbbox.[ch]: added GimpProgressInterface implementation to these classes. * app/core/gimp-gui.[ch] * app/gui/gui-vtable.c: replaced the old progress vtable entries by two new to create and destroy a GimpProgressDialog in case no other progress is available. * app/pdb/procedural_db.[ch] * app/plug-in/plug-in-run.[ch] * tools/pdbgen/app.pl: pass a GimpProgress to all PDB wrappers and all plug-ins. * app/plug-in/plug-in.[ch] * app/plug-in/plug-ins.c * app/plug-in/plug-in-message.c * app/plug-in/plug-in-progress.c: handle the case there the plug-in was crated with a progress as well as the case where it wasn't. * app/app_procs.c * app/batch.c * app/xcf/xcf.c * app/file/file-open.[ch] * app/file/file-save.[ch] * app/widgets/gimphelp.c * app/widgets/gimpbrushselect.c * app/widgets/gimpfontselect.c * app/widgets/gimpgradientselect.c * app/widgets/gimppaletteselect.c * app/widgets/gimppatternselect.c: changed accordingly. * app/core/gimpimagefile.[ch] * app/display/gimpdisplayshell-dnd.c * app/gui/file-open-dialog.c * app/gui/file-open-location-dialog.c * app/gui/file-save-dialog.c * app/widgets/gimplayertreeview.c * app/widgets/gimptoolbox-dnd.c: pass a GimpProgress to all file related functions. Embed the progress in the file dialog where possible. * app/core/gimpdrawable-blend.[ch] * app/core/gimpdrawable-transform.[ch] * app/core/gimpimage-convert.[ch] * app/core/gimpimage-flip.[ch] * app/core/gimpimage-resize.[ch] * app/core/gimpimage-rotate.[ch] * app/core/gimpimage-scale.[ch] * app/core/gimpitem-linked.[ch] * app/core/gimpitem.[ch] * app/core/gimpchannel.c * app/core/gimpdrawable.c * app/core/gimplayer.c * app/core/gimpselection.c * app/vectors/gimpvectors.c: replaced callback/data by GimpProgress. * app/tools/gimpblendtool.c * app/tools/gimptransformtool.c * app/gui/convert-dialog.c * app/actions/documents-commands.c * app/actions/file-commands.c * app/actions/image-commands.c * app/actions/layers-commands.c * app/actions/plug-in-commands.c * app/actions/vectors-commands.c * tools/pdbgen/pdb/convert.pdb * tools/pdbgen/pdb/edit.pdb * tools/pdbgen/pdb/image.pdb * tools/pdbgen/pdb/layer.pdb: changed callers accordingly. * app/pdb/*_cmds.c: regenerated.
2004-08-11 02:47:21 +08:00
g_return_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress));
gimp_set_busy (image->gimp);
g_object_freeze_notify (G_OBJECT (image));
gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_IMAGE_RESIZE,
C_("undo-type", "Resize Image"));
resize_layers = gimp_image_item_list_get_list (image,
GIMP_ITEM_TYPE_LAYERS,
layer_set);
app/actions/channels-commands.c app/actions/colormap-actions.c 2007-12-25 Michael Natterer <mitch@gimp.org> * app/actions/channels-commands.c * app/actions/colormap-actions.c * app/actions/colormap-commands.c * app/actions/image-commands.c * app/core/gimp-edit.c * app/core/gimpdrawable-preview.c * app/core/gimpimage-colorhash.c * app/core/gimpimage-colormap.c * app/core/gimpimage-convert.c * app/core/gimpimage-crop.c * app/core/gimpimage-duplicate.c * app/core/gimpimage-flip.c * app/core/gimpimage-guides.c * app/core/gimpimage-merge.c * app/core/gimpimage-preview.c * app/core/gimpimage-quick-mask.c * app/core/gimpimage-resize.c * app/core/gimpimage-rotate.c * app/core/gimpimage-sample-points.c * app/core/gimpimage-scale.c * app/core/gimpimage-snap.c * app/core/gimpimage.c * app/core/gimpimagefile.c * app/core/gimpimageundo.c * app/core/gimpitem-preview.c * app/core/gimpitem.c * app/core/gimplayer.c * app/core/gimppalette-import.c * app/core/gimpprojection-construct.c * app/core/gimpprojection.c * app/core/gimpselection.c * app/core/gimpundo.c * app/dialogs/layer-options-dialog.c * app/dialogs/print-size-dialog.c * app/display/gimpdisplay.c * app/display/gimpdisplayshell-draw.c * app/display/gimpdisplayshell-scale.c * app/display/gimpdisplayshell-scroll.c * app/display/gimpdisplayshell-title.c * app/display/gimpdisplayshell-transform.c * app/display/gimpdisplayshell.c * app/display/gimpstatusbar.c * app/file/file-open.c * app/paint/gimppaintoptions.c * app/tools/gimpaligntool.c * app/tools/gimpcolortool.c * app/tools/gimpeditselectiontool.c * app/tools/gimpiscissorstool.c * app/tools/gimpmeasuretool.c * app/tools/gimpmovetool.c * app/tools/gimpperspectiveclonetool.c * app/tools/gimprectangleselecttool.c * app/tools/gimprectangletool.c * app/tools/gimprotatetool.c * app/vectors/gimpvectors-export.c * app/vectors/gimpvectors-import.c * app/vectors/gimpvectors.c * app/widgets/gimpimagepropview.c * app/widgets/gimpnavigationview.c * app/widgets/gimpselectioneditor.c * app/widgets/gimpviewrendererdrawable.c * app/widgets/gimpviewrendererimage.c * app/xcf/xcf-load.c * app/xcf/xcf-save.c * tools/pdbgen/pdb/guides.pdb * tools/pdbgen/pdb/image.pdb: use accessors for many image properties. * app/pdb/guides_cmds.c * app/pdb/image_cmds.c: regenerated. svn path=/trunk/; revision=24432
2007-12-26 00:21:40 +08:00
old_width = gimp_image_get_width (image);
old_height = gimp_image_get_height (image);
/* Push the image size to the stack */
gimp_image_undo_push_image_size (image, NULL,
-offset_x, -offset_y,
new_width, new_height);
/* Set the new width and height */
g_object_set (image,
"width", new_width,
"height", new_height,
NULL);
/* Reposition all layers */
for (list = gimp_image_get_layer_iter (image);
list;
list = g_list_next (list))
{
GimpItem *item = list->data;
gimp_item_translate (item, offset_x, offset_y, TRUE);
}
queue = gimp_object_queue_new (progress);
progress = GIMP_PROGRESS (queue);
for (list = resize_layers; list; list = g_list_next (list))
{
GimpItem *item = list->data;
/* group layers can't be resized here */
if (gimp_viewable_get_children (GIMP_VIEWABLE (item)))
continue;
if (! resize_text_layers && gimp_item_is_text_layer (item))
continue;
Bug 795410 - Deleting a layer group and then undoing the deletion ... ... raises a CRITICAL gimp_item_{start,end}_move() currently serves two different purposes: It is used by GimpLayer to suspend/resume mask resizing of the layer's ancestors; this is necessary whenever an operation on a layer might affect the size of its ancestors. It is also used by GimpGroupLayer to suspend/resume its own mask resizing; this, on the other hand, is only necessary before applying one of the transformation functions to the group, so that mask modification is handled by GimpLayer. In other words, the effects of gimp_item_{start,end}_move() on group layers are only necessary in a subset of the cases in which these functions are used. While in itself this isn't a problem, it does cause issues when removing a group layer: gimp_image_remove_layer() calls gimp_item_start_move() before removing the layer, and gimp_item_end_move() afterwards. While the former function is called while the layer is still attached to the image, the latter function is called after the layer is no longer attached. Since GimpGroupLayer pushes an undo step in response to these calls, only the call to start_move() results in an undo step, while the call to end_move() doesn't, resulting in an unbalanced GIMP_UNDO_GROUP_LAYER_START_MOVE undo step on the stack. This causes problems when undoing the operation. Add gimp_item_{start,end}_transform() functions, and corresponding GimpItem::{start,end}_transform() virtual functions, which are more specialized versions of gimp_item_{start,end}_move(), which should be used instead of the former before/after transforming an item; in other cases, such as when removing ot reordering an item, gimp_item_{start,end}_move() should still be used. The default implementation of GimpItem::{start,end}_transform() calls gimp_item_{start,end}_move(), respectively, so subclasses that override these functions don't have to do that themselves. In GimpGroupLayer, override GimpItem::{start,end}_transform(), instead of GimpItem::{start,end}_move(), for the same purpose of suspending mask resize. This avoids these functions from being called when removing a layer group, fixing the bug.
2018-04-22 15:39:40 +08:00
/* note that we call gimp_item_start_move(), and not
* gimp_item_start_transform(). see the comment in gimp_item_resize()
* for more information.
*/
gimp_item_start_move (item, TRUE);
gimp_object_queue_push (queue, item);
}
g_list_free (resize_layers);
gimp_object_queue_push (queue, gimp_image_get_mask (image));
gimp_object_queue_push_container (queue, gimp_image_get_channels (image));
gimp_object_queue_push_container (queue, gimp_image_get_vectors (image));
/* Resize all resize_layers, channels (including selection mask), and
* vectors
*/
while ((item = gimp_object_queue_pop (queue)))
{
if (GIMP_IS_LAYER (item))
{
gint old_offset_x;
gint old_offset_y;
gimp_item_get_offset (item, &old_offset_x, &old_offset_y);
gimp_item_resize (item, context, fill_type,
new_width, new_height,
old_offset_x, old_offset_y);
gimp_item_end_move (item, TRUE);
}
else
{
gimp_item_resize (item, context, GIMP_FILL_TRANSPARENT,
new_width, new_height, offset_x, offset_y);
}
}
/* Reposition or remove all guides */
list = gimp_image_get_guides (image);
while (list)
{
GimpGuide *guide = list->data;
gboolean remove_guide = FALSE;
gint new_position = gimp_guide_get_position (guide);
list = g_list_next (list);
switch (gimp_guide_get_orientation (guide))
{
case GIMP_ORIENTATION_HORIZONTAL:
new_position += offset_y;
if (new_position < 0 || new_position > new_height)
remove_guide = TRUE;
break;
case GIMP_ORIENTATION_VERTICAL:
new_position += offset_x;
if (new_position < 0 || new_position > new_width)
remove_guide = TRUE;
break;
default:
break;
}
if (remove_guide)
gimp_image_remove_guide (image, guide, TRUE);
else if (new_position != gimp_guide_get_position (guide))
gimp_image_move_guide (image, guide, new_position, TRUE);
}
/* Reposition or remove sample points */
list = gimp_image_get_sample_points (image);
while (list)
{
GimpSamplePoint *sample_point = list->data;
gboolean remove_sample_point = FALSE;
gint old_x;
gint old_y;
gint new_x;
gint new_y;
list = g_list_next (list);
gimp_sample_point_get_position (sample_point, &old_x, &old_y);
new_y = old_y + offset_y;
if ((new_y < 0) || (new_y >= new_height))
remove_sample_point = TRUE;
new_x = old_x + offset_x;
if ((new_x < 0) || (new_x >= new_width))
remove_sample_point = TRUE;
if (remove_sample_point)
gimp_image_remove_sample_point (image, sample_point, TRUE);
else if (new_x != old_x || new_y != old_y)
gimp_image_move_sample_point (image, sample_point,
new_x, new_y, TRUE);
}
g_object_unref (queue);
gimp_image_undo_group_end (image);
gimp_image_size_changed_detailed (image,
offset_x, offset_y,
old_width, old_height);
Further work for completing bug #362915 that makes changes to the image 2008-08-03 Martin Nordholts <martinn@svn.gnome.org> Further work for completing bug #362915 that makes changes to the image size (e.g when cropping) be much more nicely handled by display shell. * app/core/gimpimage.[ch]: Add new signal GimpImage::size-changed-detailed that is emited whenever GimpViewable::size-changed is. The new signal provides additional information, namely the previous origin relative to the current origin. Cliens choose what specific signal to listen to depending on how much info they need. * app/display/gimpdisplayshell-handlers.c: Connect to GimpImage::size-changed-detailed instead of GimpViewable::size-changed since the shell wants information about the previous image origin. (gimp_display_shell_resolution_changed_handler): Use gimp_display_shell_scale_resize() instead to avoid display garbage. * app/display/gimpdisplayshell-scale.[ch]: Add new utility function gimp_display_shell_center_image_on_next_size_allocate(). * app/display/gimpdisplayshell-scroll.[ch] (gimp_display_shell_handle_size_changed_detailed): New function that replaces logic in gimp_display_shell_handle_size_changed and that takes previous-origin of the image into account and adjusts the offset so that the image content that remains doesn't move. If the window is resized on image resize, just center the image afterwards. * app/core/gimpimage-undo-push.[ch] (gimp_image_undo_push_image_size): Add previous-origin paremeters. * app/core/gimpimageundo.[ch]: Add and manage previous-origin properties so that the display shell offset can be appropriately adjusted also when undoing. * app/core/gimpundo.h * app/core/gimpimage-undo.c: Add previous_origin members to the undo accumulator and emit that information when the size of the image changes due to the undo. * app/core/gimpimage-crop.c (gimp_image_crop) * app/core/gimpimage-scale.c (gimp_image_scale) * app/core/gimpimage-rotate.c (gimp_image_rotate) * app/core/gimpimage-resize.c (gimp_image_resize_with_layers): Supply information about the previous-origin of the image to the size-changed signals and the undo system. svn path=/trunk/; revision=26354
2008-08-03 19:35:53 +08:00
g_object_thaw_notify (G_OBJECT (image));
gimp_unset_busy (image->gimp);
}
void
gimp_image_resize_to_layers (GimpImage *image,
GimpContext *context,
gint *offset_x,
gint *offset_y,
gint *new_width,
gint *new_height,
GimpProgress *progress)
{
GList *list;
GimpItem *item;
gint x, y;
gint width, height;
g_return_if_fail (GIMP_IS_IMAGE (image));
g_return_if_fail (GIMP_IS_CONTEXT (context));
g_return_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress));
list = gimp_image_get_layer_iter (image);
if (! list)
return;
/* figure out starting values */
item = list->data;
x = gimp_item_get_offset_x (item);
y = gimp_item_get_offset_y (item);
width = gimp_item_get_width (item);
height = gimp_item_get_height (item);
/* Respect all layers */
for (list = g_list_next (list); list; list = g_list_next (list))
{
item = list->data;
gimp_rectangle_union (x, y,
width, height,
gimp_item_get_offset_x (item),
gimp_item_get_offset_y (item),
gimp_item_get_width (item),
gimp_item_get_height (item),
&x, &y,
&width, &height);
}
gimp_image_resize (image, context,
width, height, -x, -y,
progress);
if (offset_x)
*offset_x = -x;
if (offset_y)
*offset_y = -y;
if (new_width)
*new_width = width;
if (new_height)
*new_height = height;
}
void
gimp_image_resize_to_selection (GimpImage *image,
GimpContext *context,
GimpProgress *progress)
{
GimpChannel *selection = gimp_image_get_mask (image);
gint x, y, w, h;
if (gimp_item_bounds (GIMP_ITEM (selection), &x, &y, &w, &h))
{
gimp_image_resize (image, context,
w, h, -x, -y,
progress);
}
}