gimp/app/image_map.c

415 lines
11 KiB
C
Raw Normal View History

1997-11-25 06:05:25 +08:00
/* The GIMP -- an 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 2 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1997-11-25 06:05:25 +08:00
*/
#include "config.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 <gtk/gtk.h>
#include "core/core-types.h"
new directory app/base/ 2001-05-15 Michael Natterer <mitch@gimp.org> * configure.in: new directory app/base/ * app/Makefile.am * app/boundary.[ch] * app/brush_scale.[ch] * app/gimpchecks.h * app/gimplut.[ch] * app/pixel_processor.[ch] * app/pixel_region.[ch] * app/pixel_surround.[ch] * app/temp_buf.[ch] * app/tile.[ch] * app/tile_cache.[ch] * app/tile_manager.[ch] * app/tile_manager_pvt.h * app/tile_pvt.h * app/tile_swap.[ch]: moved to base/ * app/base/Makefile.am * app/base/base-types.h * app/base/*: new directory for the sub-object pixel maniplation and storage stuff. Does not include Gtk+ or anything outside base/. Did some cleanup in all files. * app/appenums.h * app/apptypes.h * app/core/gimpimage.h: removed types which are now in base/base-types.h. * app/base/base-config.[ch] * app/gimprc.[ch]: put the config variables for base/ to their own file so base/ doesn not have to include gimprc.h (does not yet work, i.e. the variables are un-configurable right now) * app/main.c: set a log handler for "Gimp-Base". * app/paint-funcs/Makefile.am * app/paint-funcs/paint-funcs.[ch]: removed the color hash which maps RGB to color indices because it's a totally standalone system which has nothing to do with the paint-funcs and introduced a GimpImage dependency. paint-funcs/ should be considered on the same sub-object (glib-only) level as base/, only in a different directory. * app/core/Makefile.am * app/core/gimpimage-colorhash.[ch]: put the color hash here. * app/gimage.c: don't invalidate the color hash here... * app/core/gimpimage.c: ... but in the colormap_changed() default inplementation. Initialize the hash in class_init(). * tools/pdbgen/Makefile.am: scan app/base/base-types.h for enums. * tools/pdbgen/enums.pl: regenerated. * app/[lots] * app/core/[of] * app/gui/[files] * app/pdb/[all] * app/tools/[over] * app/widgets/[the] * tools/pdbgen/pdb/[place]: changed #includes accordingly. And use base_config->value instead of the stuff from gimprc.h.
2001-05-15 19:25:25 +08:00
#include "base/pixel-region.h"
#include "base/tile-manager.h"
#include "base/tile.h"
#include "paint-funcs/paint-funcs.h"
#include "core/gimpdrawable.h"
#include "core/gimpimage.h"
1997-11-25 06:05:25 +08:00
#include "gdisplay.h"
#include "image_map.h"
1997-11-25 06:05:25 +08:00
#define WAITING 0
#define WORKING 1
#define WORK_DELAY 1
struct _ImageMap
1997-11-25 06:05:25 +08:00
{
GDisplay *gdisp;
GimpDrawable *drawable;
TileManager *undo_tiles;
ImageMapApplyFunc apply_func;
gpointer user_data;
PixelRegion srcPR, destPR;
void *pr;
gint state;
gint idle;
};
1997-11-25 06:05:25 +08:00
/**************************/
/* Function definitions */
static gint
image_map_do (gpointer data)
{
ImageMap *image_map;
GimpImage *gimage;
PixelRegion shadowPR;
gint x, y, w, h;
1997-11-25 06:05:25 +08:00
image_map = (ImageMap *) data;
1997-11-25 06:05:25 +08:00
if (! (gimage = gimp_drawable_gimage (image_map->drawable)))
1997-11-25 06:05:25 +08:00
{
image_map->state = WAITING;
1997-11-25 06:05:25 +08:00
return FALSE;
}
/* Process the pixel regions and apply the image mapping */
(* image_map->apply_func) (&image_map->srcPR,
&image_map->destPR,
image_map->user_data);
1997-11-25 06:05:25 +08:00
x = image_map->destPR.x;
y = image_map->destPR.y;
w = image_map->destPR.w;
h = image_map->destPR.h;
1997-11-25 06:05:25 +08:00
/* apply the results */
pixel_region_init (&shadowPR, gimage->shadow, x, y, w, h, FALSE);
gimp_image_apply_image (gimage, image_map->drawable, &shadowPR,
FALSE, OPAQUE_OPACITY, REPLACE_MODE, NULL, x, y);
1997-11-25 06:05:25 +08:00
/* display the results */
if (image_map->gdisp)
1997-11-25 06:05:25 +08:00
{
app/Makefile.am removed. 2001-07-08 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/drawable.[ch]: removed. * app/core/gimpdrawable.[ch]: added the functions here. Made an end to the myth that FG/BG and the undo system (!!!) are not really part of the core. * app/disp_callbacks.c * app/floating_sel.c * app/image_map.c * app/qmask.c * app/undo.c * app/core/gimpchannel.c * app/core/gimpdrawable-desaturate.c * app/core/gimpdrawable-equalize.c * app/core/gimpdrawable-invert.c * app/core/gimpdrawable-offset.c * app/core/gimpedit.c * app/core/gimpimage-duplicate.c * app/core/gimpimage-mask.c * app/core/gimpimage-new.c * app/core/gimpimage.[ch] * app/core/gimplayer.c * app/core/gimplayermask.c * app/gui/channels-commands.c * app/gui/gui.c * app/gui/layers-commands.c * app/tools/gimpairbrushtool.c * app/tools/gimpbezierselecttool.c * app/tools/gimpblendtool.c * app/tools/gimpbrightnesscontrasttool.c * app/tools/gimpbucketfilltool.c * app/tools/gimpclonetool.c * app/tools/gimpcolorbalancetool.c * app/tools/gimpconvolvetool.c * app/tools/gimpcurvestool.c * app/tools/gimphistogramtool.c * app/tools/gimphuesaturationtool.c * app/tools/gimpinktool.c * app/tools/gimpiscissorstool.c * app/tools/gimplevelstool.c * app/tools/gimppainttool.c * app/tools/gimpposterizetool.c * app/tools/gimpscaletool.c * app/tools/gimpthresholdtool.c * app/tools/gimptransformtool.c * app/tools/tool_manager.c * app/widgets/gimpchannellistitem.c * app/widgets/gimpchannellistview.c * app/widgets/gimpdrawablelistitem.c * app/widgets/gimplayerlistitem.c * app/widgets/gimplayerlistview.c * app/pdb/channel_cmds.c * app/pdb/color_cmds.c * app/pdb/drawable_cmds.c * app/pdb/edit_cmds.c * app/pdb/floating_sel_cmds.c * app/pdb/image_cmds.c * app/pdb/layer_cmds.c * app/pdb/parasite_cmds.c * app/pdb/selection_cmds.c * app/pdb/text_tool_cmds.c * app/pdb/tools_cmds.c * tools/pdbgen/pdb.pl * tools/pdbgen/pdb/color.pdb * tools/pdbgen/pdb/drawable.pdb: changed accordingly. Misc small fixes and cleanups.
2001-07-08 06:49:01 +08:00
gimp_drawable_update (image_map->drawable,
x, y,
w, h);
gdisplay_flush_now (image_map->gdisp);
1997-11-25 06:05:25 +08:00
}
image_map->pr = pixel_regions_process (image_map->pr);
1997-11-25 06:05:25 +08:00
if (image_map->pr == NULL)
1997-11-25 06:05:25 +08:00
{
image_map->state = WAITING;
1997-11-25 06:05:25 +08:00
gdisplays_flush ();
1997-11-25 06:05:25 +08:00
return FALSE;
}
return TRUE;
1997-11-25 06:05:25 +08:00
}
ImageMap *
image_map_create (GDisplay *gdisp,
GimpDrawable *drawable)
1997-11-25 06:05:25 +08:00
{
ImageMap *image_map;
g_return_val_if_fail (gdisp != NULL, NULL);
g_return_val_if_fail (drawable != NULL, NULL);
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
1997-11-25 06:05:25 +08:00
image_map = g_new0 (ImageMap, 1);
1997-11-25 06:05:25 +08:00
image_map->gdisp = gdisp;
image_map->drawable = drawable;
image_map->undo_tiles = NULL;
image_map->state = WAITING;
/* Interactive tools based on image_map disable the undo stack
* to avert any unintented undo interaction through the UI
*/
gimp_image_undo_freeze (image_map->gdisp->gimage);
gdisplay_set_menu_sensitivity (image_map->gdisp);
return image_map;
1997-11-25 06:05:25 +08:00
}
void
image_map_apply (ImageMap *image_map,
1997-11-25 06:05:25 +08:00
ImageMapApplyFunc apply_func,
gpointer apply_data)
1997-11-25 06:05:25 +08:00
{
gint x1, y1;
gint x2, y2;
gint offset_x, offset_y;
gint width, height;
1997-11-25 06:05:25 +08:00
g_return_if_fail (image_map != NULL);
g_return_if_fail (apply_func != NULL);
image_map->apply_func = apply_func;
image_map->user_data = apply_data;
1997-11-25 06:05:25 +08:00
/* If we're still working, remove the timer */
if (image_map->state == WORKING)
1997-11-25 06:05:25 +08:00
{
gtk_idle_remove (image_map->idle);
pixel_regions_process_stop (image_map->pr);
image_map->pr = NULL;
1997-11-25 06:05:25 +08:00
}
/* Make sure the drawable is still valid */
if (! gimp_drawable_gimage (image_map->drawable))
1997-11-25 06:05:25 +08:00
return;
/* The application should occur only within selection bounds */
gimp_drawable_mask_bounds (image_map->drawable, &x1, &y1, &x2, &y2);
1997-11-25 06:05:25 +08:00
/* If undo tiles don't exist, or change size, (re)allocate */
if (image_map->undo_tiles)
{
tile_manager_get_offsets (image_map->undo_tiles, &offset_x, &offset_y);
width = tile_manager_width (image_map->undo_tiles);
height = tile_manager_height (image_map->undo_tiles);
}
else
{
offset_x = offset_y = width = height = 0;
}
if (! image_map->undo_tiles ||
offset_x != x1 || offset_y != y1 ||
width != (x2 - x1) || height != (y2 - y1))
1997-11-25 06:05:25 +08:00
{
/* If either the extents changed or the tiles don't exist,
* allocate new
*/
if (! image_map->undo_tiles ||
width != (x2 - x1) || height != (y2 - y1))
1997-11-25 06:05:25 +08:00
{
/* Destroy old tiles--If they exist */
if (image_map->undo_tiles != NULL)
tile_manager_destroy (image_map->undo_tiles);
1997-11-25 06:05:25 +08:00
/* Allocate new tiles */
image_map->undo_tiles =
app/channel.[ch] app/drawable.[ch] app/gdisplay.[ch] app/gimpdrawable.[ch] 2001-01-14 Michael Natterer <mitch@gimp.org> * app/channel.[ch] * app/drawable.[ch] * app/gdisplay.[ch] * app/gimpdrawable.[ch] * app/layer.[ch]: - Removed all "typedef drawable_function gimp_drawable_function". - Renamed all *_get_ID() functions to *_get_by_ID(). - For symmetry reasons, renamed drawable_ID() to gimp_drawable_get_ID(). - Removed the *_get_ID() functions of GimpLayer, GimpLayerMask and GimpChannel. * app/airbrush.c * app/bezier_select.c * app/blend.c * app/brightness_contrast.c * app/bucket_fill.c * app/by_color_select.c * app/clone.c * app/color_balance.c * app/color_picker.c * app/convert.c * app/convolve.c * app/crop.c * app/curves.c * app/desaturate.c * app/dodgeburn.c * app/edit_selection.c * app/eraser.c * app/fileops.c * app/flip_tool.c * app/floating_sel.c * app/fuzzy_select.c * app/gimage.c * app/gimage_mask.c * app/gimphistogram.c * app/gimpimage.c * app/global_edit.c * app/histogram_tool.c * app/hue_saturation.c * app/image_map.c * app/ink.c * app/invert.c * app/layer_select.c * app/layers_dialog.c * app/levels.c * app/paint_core.c * app/paintbrush.c * app/pencil.c * app/plug_in.c * app/posterize.c * app/scan_convert.c * app/smudge.c * app/text_tool.c * app/threshold.c * app/transform_core.c * app/undo.c * app/undo_history.c * app/channel_cmds.c * app/channel_ops_cmds.c * app/color_cmds.c * app/display_cmds.c * app/drawable_cmds.c * app/edit_cmds.c * app/floating_sel_cmds.c * app/image_cmds.c * app/layer_cmds.c * app/parasite_cmds.c * app/selection_cmds.c * app/text_tool_cmds.c * app/tools_cmds.c * libgimp/gimpdrawable_pdb.c * tools/pdbgen/pdb.pl * tools/pdbgen/pdb/channel_ops.pdb * tools/pdbgen/pdb/color.pdb * tools/pdbgen/pdb/drawable.pdb * tools/pdbgen/pdb/edit.pdb * tools/pdbgen/pdb/image.pdb * tools/pdbgen/pdb/selection.pdb * tools/pdbgen/pdb/tools.pdb: changed accordingly.
2001-01-15 05:11:52 +08:00
tile_manager_new ((x2 - x1), (y2 - y1),
gimp_drawable_bytes (image_map->drawable));
1997-11-25 06:05:25 +08:00
}
/* Copy from the image to the new tiles */
pixel_region_init (&image_map->srcPR,
gimp_drawable_data (image_map->drawable),
1997-11-25 06:05:25 +08:00
x1, y1, (x2 - x1), (y2 - y1), FALSE);
pixel_region_init (&image_map->destPR, image_map->undo_tiles,
1997-11-25 06:05:25 +08:00
0, 0, (x2 - x1), (y2 - y1), TRUE);
copy_region (&image_map->srcPR, &image_map->destPR);
1997-11-25 06:05:25 +08:00
/* Set the offsets */
tile_manager_set_offsets (image_map->undo_tiles, x1, y1);
1997-11-25 06:05:25 +08:00
}
else /* image_map->undo_tiles exist AND drawable dimensions have not changed... */
{
/* Reset to initial drawable conditions. */
/* Copy from the backup undo tiles to the drawable */
pixel_region_init (&image_map->srcPR, image_map->undo_tiles,
0, 0, width, height, FALSE);
pixel_region_init (&image_map->destPR,
gimp_drawable_data (image_map->drawable),
offset_x, offset_y, width, height, TRUE);
copy_region (&image_map->srcPR, &image_map->destPR);
}
1997-11-25 06:05:25 +08:00
/* Configure the src from the drawable data */
pixel_region_init (&image_map->srcPR, image_map->undo_tiles,
1997-11-25 06:05:25 +08:00
0, 0, (x2 - x1), (y2 - y1), FALSE);
/* Configure the dest as the shadow buffer */
pixel_region_init (&image_map->destPR,
gimp_drawable_shadow (image_map->drawable),
1997-11-25 06:05:25 +08:00
x1, y1, (x2 - x1), (y2 - y1), TRUE);
/* Apply the image transformation to the pixels */
image_map->pr = pixel_regions_register (2, &image_map->srcPR, &image_map->destPR);
1997-11-25 06:05:25 +08:00
/* Start the intermittant work procedure */
image_map->state = WORKING;
image_map->idle = gtk_idle_add (image_map_do, image_map);
1997-11-25 06:05:25 +08:00
}
void
image_map_commit (ImageMap *image_map)
1997-11-25 06:05:25 +08:00
{
gint x1, y1, x2, y2;
1997-11-25 06:05:25 +08:00
g_return_if_fail (image_map != NULL);
1997-11-25 06:05:25 +08:00
if (image_map->state == WORKING)
1997-11-25 06:05:25 +08:00
{
gtk_idle_remove (image_map->idle);
1997-11-25 06:05:25 +08:00
/* Finish the changes */
while (image_map_do (image_map)) ;
}
/* Make sure the drawable is still valid */
if (! gimp_drawable_gimage (image_map->drawable))
1997-11-25 06:05:25 +08:00
return;
/* Interactive phase ends: we can commit an undo frame now */
gimp_image_undo_thaw(image_map->gdisp->gimage);
1997-11-25 06:05:25 +08:00
/* Register an undo step */
if (image_map->undo_tiles)
1997-11-25 06:05:25 +08:00
{
tile_manager_get_offsets (image_map->undo_tiles, &x1, &y1);
x2 = x1 + tile_manager_width (image_map->undo_tiles);
y2 = y1 + tile_manager_height (image_map->undo_tiles);
app/Makefile.am removed. 2001-07-08 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/drawable.[ch]: removed. * app/core/gimpdrawable.[ch]: added the functions here. Made an end to the myth that FG/BG and the undo system (!!!) are not really part of the core. * app/disp_callbacks.c * app/floating_sel.c * app/image_map.c * app/qmask.c * app/undo.c * app/core/gimpchannel.c * app/core/gimpdrawable-desaturate.c * app/core/gimpdrawable-equalize.c * app/core/gimpdrawable-invert.c * app/core/gimpdrawable-offset.c * app/core/gimpedit.c * app/core/gimpimage-duplicate.c * app/core/gimpimage-mask.c * app/core/gimpimage-new.c * app/core/gimpimage.[ch] * app/core/gimplayer.c * app/core/gimplayermask.c * app/gui/channels-commands.c * app/gui/gui.c * app/gui/layers-commands.c * app/tools/gimpairbrushtool.c * app/tools/gimpbezierselecttool.c * app/tools/gimpblendtool.c * app/tools/gimpbrightnesscontrasttool.c * app/tools/gimpbucketfilltool.c * app/tools/gimpclonetool.c * app/tools/gimpcolorbalancetool.c * app/tools/gimpconvolvetool.c * app/tools/gimpcurvestool.c * app/tools/gimphistogramtool.c * app/tools/gimphuesaturationtool.c * app/tools/gimpinktool.c * app/tools/gimpiscissorstool.c * app/tools/gimplevelstool.c * app/tools/gimppainttool.c * app/tools/gimpposterizetool.c * app/tools/gimpscaletool.c * app/tools/gimpthresholdtool.c * app/tools/gimptransformtool.c * app/tools/tool_manager.c * app/widgets/gimpchannellistitem.c * app/widgets/gimpchannellistview.c * app/widgets/gimpdrawablelistitem.c * app/widgets/gimplayerlistitem.c * app/widgets/gimplayerlistview.c * app/pdb/channel_cmds.c * app/pdb/color_cmds.c * app/pdb/drawable_cmds.c * app/pdb/edit_cmds.c * app/pdb/floating_sel_cmds.c * app/pdb/image_cmds.c * app/pdb/layer_cmds.c * app/pdb/parasite_cmds.c * app/pdb/selection_cmds.c * app/pdb/text_tool_cmds.c * app/pdb/tools_cmds.c * tools/pdbgen/pdb.pl * tools/pdbgen/pdb/color.pdb * tools/pdbgen/pdb/drawable.pdb: changed accordingly. Misc small fixes and cleanups.
2001-07-08 06:49:01 +08:00
gimp_drawable_apply_image (image_map->drawable,
x1, y1, x2, y2, image_map->undo_tiles, FALSE);
1997-11-25 06:05:25 +08:00
}
gdisplay_set_menu_sensitivity (image_map->gdisp);
g_free (image_map);
1997-11-25 06:05:25 +08:00
}
void
image_map_clear (ImageMap *image_map)
1997-11-25 06:05:25 +08:00
{
PixelRegion srcPR, destPR;
g_return_if_fail (image_map != NULL);
1997-11-25 06:05:25 +08:00
if (image_map->state == WORKING)
1997-11-25 06:05:25 +08:00
{
gtk_idle_remove (image_map->idle);
pixel_regions_process_stop (image_map->pr);
image_map->pr = NULL;
1997-11-25 06:05:25 +08:00
}
image_map->state = WAITING;
1997-11-25 06:05:25 +08:00
/* Make sure the drawable is still valid */
if (! gimp_drawable_gimage (image_map->drawable))
1997-11-25 06:05:25 +08:00
return;
/* restore the original image */
if (image_map->undo_tiles)
1997-11-25 06:05:25 +08:00
{
gint offset_x;
gint offset_y;
gint width;
gint height;
tile_manager_get_offsets (image_map->undo_tiles, &offset_x, &offset_y);
width = tile_manager_width (image_map->undo_tiles);
height = tile_manager_height (image_map->undo_tiles),
1997-11-25 06:05:25 +08:00
/* Copy from the drawable to the tiles */
pixel_region_init (&srcPR, image_map->undo_tiles,
0, 0, width, height, FALSE);
app/channel.[ch] app/drawable.[ch] app/gdisplay.[ch] app/gimpdrawable.[ch] 2001-01-14 Michael Natterer <mitch@gimp.org> * app/channel.[ch] * app/drawable.[ch] * app/gdisplay.[ch] * app/gimpdrawable.[ch] * app/layer.[ch]: - Removed all "typedef drawable_function gimp_drawable_function". - Renamed all *_get_ID() functions to *_get_by_ID(). - For symmetry reasons, renamed drawable_ID() to gimp_drawable_get_ID(). - Removed the *_get_ID() functions of GimpLayer, GimpLayerMask and GimpChannel. * app/airbrush.c * app/bezier_select.c * app/blend.c * app/brightness_contrast.c * app/bucket_fill.c * app/by_color_select.c * app/clone.c * app/color_balance.c * app/color_picker.c * app/convert.c * app/convolve.c * app/crop.c * app/curves.c * app/desaturate.c * app/dodgeburn.c * app/edit_selection.c * app/eraser.c * app/fileops.c * app/flip_tool.c * app/floating_sel.c * app/fuzzy_select.c * app/gimage.c * app/gimage_mask.c * app/gimphistogram.c * app/gimpimage.c * app/global_edit.c * app/histogram_tool.c * app/hue_saturation.c * app/image_map.c * app/ink.c * app/invert.c * app/layer_select.c * app/layers_dialog.c * app/levels.c * app/paint_core.c * app/paintbrush.c * app/pencil.c * app/plug_in.c * app/posterize.c * app/scan_convert.c * app/smudge.c * app/text_tool.c * app/threshold.c * app/transform_core.c * app/undo.c * app/undo_history.c * app/channel_cmds.c * app/channel_ops_cmds.c * app/color_cmds.c * app/display_cmds.c * app/drawable_cmds.c * app/edit_cmds.c * app/floating_sel_cmds.c * app/image_cmds.c * app/layer_cmds.c * app/parasite_cmds.c * app/selection_cmds.c * app/text_tool_cmds.c * app/tools_cmds.c * libgimp/gimpdrawable_pdb.c * tools/pdbgen/pdb.pl * tools/pdbgen/pdb/channel_ops.pdb * tools/pdbgen/pdb/color.pdb * tools/pdbgen/pdb/drawable.pdb * tools/pdbgen/pdb/edit.pdb * tools/pdbgen/pdb/image.pdb * tools/pdbgen/pdb/selection.pdb * tools/pdbgen/pdb/tools.pdb: changed accordingly.
2001-01-15 05:11:52 +08:00
pixel_region_init (&destPR,
gimp_drawable_data (image_map->drawable),
offset_x, offset_y, width, height, TRUE);
1997-11-25 06:05:25 +08:00
/* if the user has changed the image depth get out quickly */
if (destPR.bytes != srcPR.bytes)
{
1999-12-28 22:09:20 +08:00
g_message ("image depth change, unable to restore original image");
tile_manager_destroy (image_map->undo_tiles);
gimp_image_undo_thaw (image_map->gdisp->gimage);
gdisplay_set_menu_sensitivity (image_map->gdisp);
g_free (image_map);
1997-11-25 06:05:25 +08:00
return;
}
1997-11-25 06:05:25 +08:00
copy_region (&srcPR, &destPR);
/* Update the area */
app/Makefile.am removed. 2001-07-08 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/drawable.[ch]: removed. * app/core/gimpdrawable.[ch]: added the functions here. Made an end to the myth that FG/BG and the undo system (!!!) are not really part of the core. * app/disp_callbacks.c * app/floating_sel.c * app/image_map.c * app/qmask.c * app/undo.c * app/core/gimpchannel.c * app/core/gimpdrawable-desaturate.c * app/core/gimpdrawable-equalize.c * app/core/gimpdrawable-invert.c * app/core/gimpdrawable-offset.c * app/core/gimpedit.c * app/core/gimpimage-duplicate.c * app/core/gimpimage-mask.c * app/core/gimpimage-new.c * app/core/gimpimage.[ch] * app/core/gimplayer.c * app/core/gimplayermask.c * app/gui/channels-commands.c * app/gui/gui.c * app/gui/layers-commands.c * app/tools/gimpairbrushtool.c * app/tools/gimpbezierselecttool.c * app/tools/gimpblendtool.c * app/tools/gimpbrightnesscontrasttool.c * app/tools/gimpbucketfilltool.c * app/tools/gimpclonetool.c * app/tools/gimpcolorbalancetool.c * app/tools/gimpconvolvetool.c * app/tools/gimpcurvestool.c * app/tools/gimphistogramtool.c * app/tools/gimphuesaturationtool.c * app/tools/gimpinktool.c * app/tools/gimpiscissorstool.c * app/tools/gimplevelstool.c * app/tools/gimppainttool.c * app/tools/gimpposterizetool.c * app/tools/gimpscaletool.c * app/tools/gimpthresholdtool.c * app/tools/gimptransformtool.c * app/tools/tool_manager.c * app/widgets/gimpchannellistitem.c * app/widgets/gimpchannellistview.c * app/widgets/gimpdrawablelistitem.c * app/widgets/gimplayerlistitem.c * app/widgets/gimplayerlistview.c * app/pdb/channel_cmds.c * app/pdb/color_cmds.c * app/pdb/drawable_cmds.c * app/pdb/edit_cmds.c * app/pdb/floating_sel_cmds.c * app/pdb/image_cmds.c * app/pdb/layer_cmds.c * app/pdb/parasite_cmds.c * app/pdb/selection_cmds.c * app/pdb/text_tool_cmds.c * app/pdb/tools_cmds.c * tools/pdbgen/pdb.pl * tools/pdbgen/pdb/color.pdb * tools/pdbgen/pdb/drawable.pdb: changed accordingly. Misc small fixes and cleanups.
2001-07-08 06:49:01 +08:00
gimp_drawable_update (image_map->drawable,
offset_x, offset_y,
width, height);
1997-11-25 06:05:25 +08:00
/* Free the undo_tiles tile manager */
tile_manager_destroy (image_map->undo_tiles);
image_map->undo_tiles = NULL;
1997-11-25 06:05:25 +08:00
}
}
1997-11-25 06:05:25 +08:00
void
image_map_abort (ImageMap *image_map)
{
g_return_if_fail (image_map != NULL);
image_map_clear (image_map);
gimp_image_undo_thaw (image_map->gdisp->gimage);
gdisplay_set_menu_sensitivity (image_map->gdisp);
g_free (image_map);
1997-11-25 06:05:25 +08:00
}
app/channel.[ch] app/drawable.[ch] app/gdisplay.[ch] app/gimpdrawable.[ch] 2001-01-14 Michael Natterer <mitch@gimp.org> * app/channel.[ch] * app/drawable.[ch] * app/gdisplay.[ch] * app/gimpdrawable.[ch] * app/layer.[ch]: - Removed all "typedef drawable_function gimp_drawable_function". - Renamed all *_get_ID() functions to *_get_by_ID(). - For symmetry reasons, renamed drawable_ID() to gimp_drawable_get_ID(). - Removed the *_get_ID() functions of GimpLayer, GimpLayerMask and GimpChannel. * app/airbrush.c * app/bezier_select.c * app/blend.c * app/brightness_contrast.c * app/bucket_fill.c * app/by_color_select.c * app/clone.c * app/color_balance.c * app/color_picker.c * app/convert.c * app/convolve.c * app/crop.c * app/curves.c * app/desaturate.c * app/dodgeburn.c * app/edit_selection.c * app/eraser.c * app/fileops.c * app/flip_tool.c * app/floating_sel.c * app/fuzzy_select.c * app/gimage.c * app/gimage_mask.c * app/gimphistogram.c * app/gimpimage.c * app/global_edit.c * app/histogram_tool.c * app/hue_saturation.c * app/image_map.c * app/ink.c * app/invert.c * app/layer_select.c * app/layers_dialog.c * app/levels.c * app/paint_core.c * app/paintbrush.c * app/pencil.c * app/plug_in.c * app/posterize.c * app/scan_convert.c * app/smudge.c * app/text_tool.c * app/threshold.c * app/transform_core.c * app/undo.c * app/undo_history.c * app/channel_cmds.c * app/channel_ops_cmds.c * app/color_cmds.c * app/display_cmds.c * app/drawable_cmds.c * app/edit_cmds.c * app/floating_sel_cmds.c * app/image_cmds.c * app/layer_cmds.c * app/parasite_cmds.c * app/selection_cmds.c * app/text_tool_cmds.c * app/tools_cmds.c * libgimp/gimpdrawable_pdb.c * tools/pdbgen/pdb.pl * tools/pdbgen/pdb/channel_ops.pdb * tools/pdbgen/pdb/color.pdb * tools/pdbgen/pdb/drawable.pdb * tools/pdbgen/pdb/edit.pdb * tools/pdbgen/pdb/image.pdb * tools/pdbgen/pdb/selection.pdb * tools/pdbgen/pdb/tools.pdb: changed accordingly.
2001-01-15 05:11:52 +08:00
guchar *
image_map_get_color_at (ImageMap *image_map,
gint x,
gint y)
{
app/channel.[ch] app/drawable.[ch] app/gdisplay.[ch] app/gimpdrawable.[ch] 2001-01-14 Michael Natterer <mitch@gimp.org> * app/channel.[ch] * app/drawable.[ch] * app/gdisplay.[ch] * app/gimpdrawable.[ch] * app/layer.[ch]: - Removed all "typedef drawable_function gimp_drawable_function". - Renamed all *_get_ID() functions to *_get_by_ID(). - For symmetry reasons, renamed drawable_ID() to gimp_drawable_get_ID(). - Removed the *_get_ID() functions of GimpLayer, GimpLayerMask and GimpChannel. * app/airbrush.c * app/bezier_select.c * app/blend.c * app/brightness_contrast.c * app/bucket_fill.c * app/by_color_select.c * app/clone.c * app/color_balance.c * app/color_picker.c * app/convert.c * app/convolve.c * app/crop.c * app/curves.c * app/desaturate.c * app/dodgeburn.c * app/edit_selection.c * app/eraser.c * app/fileops.c * app/flip_tool.c * app/floating_sel.c * app/fuzzy_select.c * app/gimage.c * app/gimage_mask.c * app/gimphistogram.c * app/gimpimage.c * app/global_edit.c * app/histogram_tool.c * app/hue_saturation.c * app/image_map.c * app/ink.c * app/invert.c * app/layer_select.c * app/layers_dialog.c * app/levels.c * app/paint_core.c * app/paintbrush.c * app/pencil.c * app/plug_in.c * app/posterize.c * app/scan_convert.c * app/smudge.c * app/text_tool.c * app/threshold.c * app/transform_core.c * app/undo.c * app/undo_history.c * app/channel_cmds.c * app/channel_ops_cmds.c * app/color_cmds.c * app/display_cmds.c * app/drawable_cmds.c * app/edit_cmds.c * app/floating_sel_cmds.c * app/image_cmds.c * app/layer_cmds.c * app/parasite_cmds.c * app/selection_cmds.c * app/text_tool_cmds.c * app/tools_cmds.c * libgimp/gimpdrawable_pdb.c * tools/pdbgen/pdb.pl * tools/pdbgen/pdb/channel_ops.pdb * tools/pdbgen/pdb/color.pdb * tools/pdbgen/pdb/drawable.pdb * tools/pdbgen/pdb/edit.pdb * tools/pdbgen/pdb/image.pdb * tools/pdbgen/pdb/selection.pdb * tools/pdbgen/pdb/tools.pdb: changed accordingly.
2001-01-15 05:11:52 +08:00
Tile *tile;
guchar *src;
guchar *dest;
g_return_val_if_fail (image_map != NULL, NULL);
if (x >= 0 && x < gimp_drawable_width (image_map->drawable) &&
y >= 0 && y < gimp_drawable_height (image_map->drawable))
{
/* Check if done damage to original image */
if (! image_map->undo_tiles)
return (gimp_drawable_get_color_at (image_map->drawable, x, y));
if (! image_map ||
(! gimp_drawable_gimage (image_map->drawable) &&
gimp_drawable_is_indexed (image_map->drawable)) ||
x < 0 || y < 0 ||
x >= tile_manager_width (image_map->undo_tiles) ||
y >= tile_manager_height (image_map->undo_tiles))
{
return NULL;
}
app/channel.[ch] app/drawable.[ch] app/gdisplay.[ch] app/gimpdrawable.[ch] 2001-01-14 Michael Natterer <mitch@gimp.org> * app/channel.[ch] * app/drawable.[ch] * app/gdisplay.[ch] * app/gimpdrawable.[ch] * app/layer.[ch]: - Removed all "typedef drawable_function gimp_drawable_function". - Renamed all *_get_ID() functions to *_get_by_ID(). - For symmetry reasons, renamed drawable_ID() to gimp_drawable_get_ID(). - Removed the *_get_ID() functions of GimpLayer, GimpLayerMask and GimpChannel. * app/airbrush.c * app/bezier_select.c * app/blend.c * app/brightness_contrast.c * app/bucket_fill.c * app/by_color_select.c * app/clone.c * app/color_balance.c * app/color_picker.c * app/convert.c * app/convolve.c * app/crop.c * app/curves.c * app/desaturate.c * app/dodgeburn.c * app/edit_selection.c * app/eraser.c * app/fileops.c * app/flip_tool.c * app/floating_sel.c * app/fuzzy_select.c * app/gimage.c * app/gimage_mask.c * app/gimphistogram.c * app/gimpimage.c * app/global_edit.c * app/histogram_tool.c * app/hue_saturation.c * app/image_map.c * app/ink.c * app/invert.c * app/layer_select.c * app/layers_dialog.c * app/levels.c * app/paint_core.c * app/paintbrush.c * app/pencil.c * app/plug_in.c * app/posterize.c * app/scan_convert.c * app/smudge.c * app/text_tool.c * app/threshold.c * app/transform_core.c * app/undo.c * app/undo_history.c * app/channel_cmds.c * app/channel_ops_cmds.c * app/color_cmds.c * app/display_cmds.c * app/drawable_cmds.c * app/edit_cmds.c * app/floating_sel_cmds.c * app/image_cmds.c * app/layer_cmds.c * app/parasite_cmds.c * app/selection_cmds.c * app/text_tool_cmds.c * app/tools_cmds.c * libgimp/gimpdrawable_pdb.c * tools/pdbgen/pdb.pl * tools/pdbgen/pdb/channel_ops.pdb * tools/pdbgen/pdb/color.pdb * tools/pdbgen/pdb/drawable.pdb * tools/pdbgen/pdb/edit.pdb * tools/pdbgen/pdb/image.pdb * tools/pdbgen/pdb/selection.pdb * tools/pdbgen/pdb/tools.pdb: changed accordingly.
2001-01-15 05:11:52 +08:00
dest = g_new (guchar, 5);
tile = tile_manager_get_tile (image_map->undo_tiles, x, y,
TRUE, FALSE);
src = tile_data_pointer (tile, x % TILE_WIDTH, y % TILE_HEIGHT);
gimp_image_get_color (gimp_drawable_gimage (image_map->drawable),
gimp_drawable_type (image_map->drawable),
app/channel.[ch] app/drawable.[ch] app/gdisplay.[ch] app/gimpdrawable.[ch] 2001-01-14 Michael Natterer <mitch@gimp.org> * app/channel.[ch] * app/drawable.[ch] * app/gdisplay.[ch] * app/gimpdrawable.[ch] * app/layer.[ch]: - Removed all "typedef drawable_function gimp_drawable_function". - Renamed all *_get_ID() functions to *_get_by_ID(). - For symmetry reasons, renamed drawable_ID() to gimp_drawable_get_ID(). - Removed the *_get_ID() functions of GimpLayer, GimpLayerMask and GimpChannel. * app/airbrush.c * app/bezier_select.c * app/blend.c * app/brightness_contrast.c * app/bucket_fill.c * app/by_color_select.c * app/clone.c * app/color_balance.c * app/color_picker.c * app/convert.c * app/convolve.c * app/crop.c * app/curves.c * app/desaturate.c * app/dodgeburn.c * app/edit_selection.c * app/eraser.c * app/fileops.c * app/flip_tool.c * app/floating_sel.c * app/fuzzy_select.c * app/gimage.c * app/gimage_mask.c * app/gimphistogram.c * app/gimpimage.c * app/global_edit.c * app/histogram_tool.c * app/hue_saturation.c * app/image_map.c * app/ink.c * app/invert.c * app/layer_select.c * app/layers_dialog.c * app/levels.c * app/paint_core.c * app/paintbrush.c * app/pencil.c * app/plug_in.c * app/posterize.c * app/scan_convert.c * app/smudge.c * app/text_tool.c * app/threshold.c * app/transform_core.c * app/undo.c * app/undo_history.c * app/channel_cmds.c * app/channel_ops_cmds.c * app/color_cmds.c * app/display_cmds.c * app/drawable_cmds.c * app/edit_cmds.c * app/floating_sel_cmds.c * app/image_cmds.c * app/layer_cmds.c * app/parasite_cmds.c * app/selection_cmds.c * app/text_tool_cmds.c * app/tools_cmds.c * libgimp/gimpdrawable_pdb.c * tools/pdbgen/pdb.pl * tools/pdbgen/pdb/channel_ops.pdb * tools/pdbgen/pdb/color.pdb * tools/pdbgen/pdb/drawable.pdb * tools/pdbgen/pdb/edit.pdb * tools/pdbgen/pdb/image.pdb * tools/pdbgen/pdb/selection.pdb * tools/pdbgen/pdb/tools.pdb: changed accordingly.
2001-01-15 05:11:52 +08:00
dest, src);
if (GIMP_IMAGE_TYPE_HAS_ALPHA (gimp_drawable_type (image_map->drawable)))
dest[3] = src[gimp_drawable_bytes (image_map->drawable) - 1];
else
dest[3] = 255;
if (gimp_drawable_is_indexed (image_map->drawable))
dest[4] = src[0];
else
dest[4] = 0;
tile_release (tile, FALSE);
return dest;
}
else /* out of bounds error */
{
return NULL;
}
}