gimp/app/core/gimpprojection-construct.c

771 lines
23 KiB
C
Raw Normal View History

/* 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.
*/
#include "config.h"
an evil temp_hack which lets GimpContext managing the active display 2001-08-14 Michael Natterer <mitch@gimp.org> * app/gdisplay.h: an evil temp_hack which lets GimpContext managing the active display withoug including "gdisplay.h". Will go away as soon ad context properties are registered dynamically. * app/module_db.c: cleaned up the object code in preparation of moving it to core/. * app/path.c: connect to GimpImage's * app/core/gimpobject.[ch]: derive it from GObject, not from GtkObject any more (yeah :-) * app/core/*.c: #include <glib-object.h> instead of <gtk/gtk.h>, removed some remaining GtkObject-isms. (left in a few #include <gtk/gtk.h> where bigger changes are needed to get rid of the UI dependency). * app/core/core-types.h: #include <gdk-pixbuf/gdk-pixbuf.h> here temporarily. * app/core/gimp.c (gimp_create_display): unref the image after creating it's first display. * app/core/gimpbrush.[ch]: disabled the parts of the code which depend on GimpPaintTool. * app/core/gimpbrushgenerated.c * app/core/gimpbrushpipe.c: changed accordingly. * app/core/gimpcontext.[ch]: evil hack (see above) to manage the active display without including "gdisplay.h" * app/core/gimpimage-mask.[ch]: pass a context to gimage_mask_stroke() and get the current tool's PDB string from there. * app/core/gimpedit.c: changed accordingly. * app/core/gimpimage.c: use gimp_image_update() instead of gdisplays_update_full(). * app/gui/color-area.c * app/gui/colormap-dialog.c * app/gui/dialogs-constructors.c * app/gui/edit-commands.c * app/gui/image-commands.c * app/gui/toolbox.c: changed accordingly (don't use Gtk methods on GObjects). * app/gui/menus.c: fix some const warnings by explicit casting. * app/tools/*.[ch]: ported all tools to GObject, some minor cleanup while i was on it. * app/widgets/gimpdialogfactory.[ch]: ported to GObject. * app/widgets/gimplayerlistview.h: added FOO_GET_CLASS() macro. * tools/pdbgen/app.pl: added a "widgets_eek" hack like "tools_eek" which inserts #include "widgets/widgets-types.h" before ordinary includes. * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/edit.pdb * app/pdb/brush_select_cmds.c * app/pdb/edit_cmds.c: changed according to the stuff above.
2001-08-14 22:53:55 +08:00
#include <glib-object.h>
Makefile.am configure.in added stuff for the new library below. 2001-01-23 Michael Natterer <mitch@gimp.org> * Makefile.am * configure.in * gimptool.in: added stuff for the new library below. * libgimpcolor/.cvsignore * libgimpcolor/Makefile.am * libgimpcolor/gimpcolor.h * libgimpcolor/gimpcolorspace.c * libgimpcolor/gimpcolorspace.h * libgimpcolor/gimpcolortypes.h * libgimpcolor/gimphsv.c * libgimpcolor/gimphsv.h * libgimpcolor/gimprgb.c * libgimpcolor/gimprgb.h: new shared library which both the app and plug-ins link against. The library depends only on glib. * libgimpcolor/gimpcolor.def * libgimpcolor/makefile.mingw.in * libgimpcolor/makefile.msc: added Win32 build files which definitely don't work. * libgimp/Makefile.am * libgimp/gimpcolor.[ch] * libgimp/gimpcolorspace.[ch]: removed. * libgimp/gimp.h * libgimp/gimpadaptivesupersample.c * libgimp/gimpbilinear.c * libgimp/gimppalette.c * libgimp/gimptypes.h: include the stuff from libgimpcolor. Plug-Ins don't need to include <libgimpcolor/gimpcolor.h> explicitely. LibGimp depends on libgimpcolor and thus also includes it's headers. * libgimp/gimp.def * libgimp/makefile.mingw.in: fiddled around with Win32 stuff... * app/Makefile.am: link against libgimpcolor.la * app/apptypes.h: include "libgimpcolor/gimpcolortypes.h" * app/asupsample.c * app/channels_dialog.c * app/colormap_dialog.c * app/commands.c * app/convert.c * app/devices.c * app/disp_callbacks.c * app/drawable.c * app/gimpcontext.c * app/gimpdnd.c * app/gimpimage.c * app/gimppalette.c * app/gimprc.c * app/gradient.c * app/libgimp_glue.c * app/palette.c * app/palette_import.c * app/qmask.c * app/xcf.c * app/tools/paint_core.c * app/tools/paintbrush.c * app/tools/pencil.c: include "libgimpcolor/gimpcolor.h" before all gimp includes because it's a standalone library. * plug-ins/FractalExplorer/Makefile.am * plug-ins/Lighting/Makefile.am * plug-ins/MapObject/Makefile.am * plug-ins/bmp/Makefile.am * plug-ins/common/Makefile.am * plug-ins/common/mkgen.pl * plug-ins/dbbrowser/Makefile.am * plug-ins/faxg3/Makefile.am * plug-ins/fits/Makefile.am * plug-ins/flame/Makefile.am * plug-ins/fp/Makefile.am * plug-ins/gap/Makefile.am * plug-ins/gdyntext/Makefile.am * plug-ins/gfig/Makefile.am * plug-ins/gflare/Makefile.am * plug-ins/gfli/Makefile.am * plug-ins/gimpressionist/Makefile.am * plug-ins/helpbrowser/Makefile.am * plug-ins/ifscompose/Makefile.am * plug-ins/imagemap/Makefile.am * plug-ins/maze/Makefile.am * plug-ins/mosaic/Makefile.am * plug-ins/pagecurl/Makefile.am * plug-ins/print/Makefile.am * plug-ins/rcm/Makefile.am * plug-ins/script-fu/Makefile.am * plug-ins/sel2path/Makefile.am * plug-ins/sgi/Makefile.am * plug-ins/webbrowser/Makefile.am * plug-ins/xjt/Makefile.am: add libgimpcolor.la to LDADD. * INSTALL: don't recommend to --disable-shared for development. * TODO.xml: increased some percentages, added plug-in help stuff.
2001-01-24 02:49:44 +08:00
#include "libgimpcolor/gimpcolor.h"
#include "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"
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"
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 "gimpimage-projection.h"
#include "gimplayer.h"
#include "gimplayer-floating-sel.h"
#include "gimplayermask.h"
#include "gimplist.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
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
/* local function prototypes */
static void gimp_image_projection_validate_tile (TileManager *tm,
Tile *tile);
static void gimp_image_construct_layers (GimpImage *gimage,
gint x,
gint y,
gint w,
gint h);
static void gimp_image_construct_channels (GimpImage *gimage,
gint x,
gint y,
gint w,
gint h);
static void gimp_image_initialize_projection (GimpImage *gimage,
gint x,
gint y,
gint w,
gint h);
static void gimp_image_construct (GimpImage *gimage,
gint x,
gint y,
gint w,
gint h);
static void project_intensity (GimpImage *gimage,
GimpLayer *layer,
PixelRegion *src,
PixelRegion *dest,
PixelRegion *mask);
static void project_intensity_alpha (GimpImage *gimage,
GimpLayer *layer,
PixelRegion *src,
PixelRegion *dest,
PixelRegion *mask);
static void project_indexed (GimpImage *gimage,
GimpLayer *layer,
PixelRegion *src,
PixelRegion *dest);
static void project_indexed_alpha (GimpImage *gimage,
GimpLayer *layer,
PixelRegion *src,
PixelRegion *dest,
PixelRegion *mask);
static void project_channel (GimpImage *gimage,
GimpChannel *channel,
PixelRegion *src,
PixelRegion *src2);
/* public functions */
void
gimp_image_projection_allocate (GimpImage *gimage)
{
if (gimage->projection)
gimp_image_projection_free (gimage);
/* Find the number of bytes required for the projection.
* This includes the intensity channels and an alpha channel
* if one doesn't exist.
*/
switch (gimp_image_base_type (gimage))
{
2001-12-11 23:58:07 +08:00
case GIMP_RGB:
case GIMP_INDEXED:
gimage->proj_bytes = 4;
gimage->proj_type = GIMP_RGBA_IMAGE;
break;
2001-12-11 23:58:07 +08:00
case GIMP_GRAY:
gimage->proj_bytes = 2;
gimage->proj_type = GIMP_GRAYA_IMAGE;
break;
default:
g_assert_not_reached ();
}
/* allocate the new projection */
gimage->projection = tile_manager_new (gimage->width, gimage->height,
gimage->proj_bytes);
tile_manager_set_user_data (gimage->projection, (void *) gimage);
tile_manager_set_validate_proc (gimage->projection,
gimp_image_projection_validate_tile);
}
void
gimp_image_projection_free (GimpImage *gimage)
{
g_return_if_fail (GIMP_IS_IMAGE (gimage));
if (gimage->projection)
{
tile_manager_destroy (gimage->projection);
gimage->projection = NULL;
}
}
TileManager *
gimp_image_projection (GimpImage *gimage)
{
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
if ((gimage->projection == NULL) ||
(tile_manager_width (gimage->projection) != gimage->width) ||
(tile_manager_height (gimage->projection) != gimage->height))
{
gimp_image_projection_allocate (gimage);
}
return gimage->projection;
}
GimpImageType
gimp_image_projection_type (const GimpImage *gimage)
{
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), -1);
return gimage->proj_type;
}
gint
gimp_image_projection_bytes (const GimpImage *gimage)
{
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), -1);
return gimage->proj_bytes;
}
gdouble
gimp_image_projection_opacity (const GimpImage *gimage)
{
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), GIMP_OPACITY_OPAQUE);
return GIMP_OPACITY_OPAQUE;
}
guchar *
gimp_image_projection_get_color_at (GimpImage *gimage,
gint x,
gint y)
{
Tile *tile;
guchar *src;
guchar *dest;
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
if (x < 0 || y < 0 || x >= gimage->width || y >= gimage->height)
return NULL;
dest = g_new (guchar, 5);
tile = tile_manager_get_tile (gimp_image_projection (gimage), x, y,
TRUE, FALSE);
src = tile_data_pointer (tile, x % TILE_WIDTH, y % TILE_HEIGHT);
gimp_image_get_color (gimage, gimp_image_projection_type (gimage), dest, src);
if (GIMP_IMAGE_TYPE_HAS_ALPHA (gimp_image_projection_type (gimage)))
dest[3] = src[gimp_image_projection_bytes (gimage) - 1];
else
dest[3] = 255;
comment typo fix, plus add %D* to default image-title-format string, so Fri Oct 1 12:46:12 1999 Austin Donnelly <austin@gimp.org> * gimprc.in: comment typo fix, plus add %D* to default image-title-format string, so people get a '*' in the titlebar if their image is dirty. * app/fileops.c: initialise filename before using it. * app/gdisplay.c: empty parameter list () is K&R - should be stronger (void) in ANSI C. * app/gimpdrawable.c: gimp_drawable_{dirty,clean} functions removed - no one uses them anyway. Parasite undo type is proper parasite undo type, not MISC_UNDO. * app/gimpdrawableP.h: drawable dirty bit removed. * app/gimpimage.c: don't change the resolution if there's no difference from the old one. Call gdisplay_shrink_wrap() to re-calculate scale factors and refresh the display on resolution change. Layer undo doesn't have sub-types anymore, uses main UndoType instead. * app/layer.h: Remove LayerUndoType * app/qmask.c: fix qmask undo so it actually works. * app/undo.h: new types for undo_push_layer{,_mask} and undo_push_qmask. * app/undo.c: change way group boundaries are represented: each Undo has a group_boundary boolean set to TRUE if this is the start or the end of a group, and the type of the Undo is the group's type. Within a group, each Undo keeps its own type. This allows pop funcs and free funcs to do type-specific things (eg needed by layer and channel stuff). Don't maintain per-drawable dirty flags anymore. Floating sel to layer and layer rename now uses meaningful undo types. * app/undo_types.h: more specific undo types: LAYER_{ADD,REMOVE}_UNDO, LAYER_MASK_{ADD,REMOVE}_UNDO, LAYER_RENAME_UNDO, and PARASITE_{ATTACH,DETACH}_UNDO. * app/undo_history.c: oops - undo stack was being placed into gtk list in wrong order. * app/edit_selection.c: push more descriptive LAYER_DISPLACE_UNDO rather than MISC_UNDO. * app/layers_dialog.c: better tagging of undo types
1999-10-02 02:43:24 +08:00
dest[4] = 0;
tile_release (tile, FALSE);
comment typo fix, plus add %D* to default image-title-format string, so Fri Oct 1 12:46:12 1999 Austin Donnelly <austin@gimp.org> * gimprc.in: comment typo fix, plus add %D* to default image-title-format string, so people get a '*' in the titlebar if their image is dirty. * app/fileops.c: initialise filename before using it. * app/gdisplay.c: empty parameter list () is K&R - should be stronger (void) in ANSI C. * app/gimpdrawable.c: gimp_drawable_{dirty,clean} functions removed - no one uses them anyway. Parasite undo type is proper parasite undo type, not MISC_UNDO. * app/gimpdrawableP.h: drawable dirty bit removed. * app/gimpimage.c: don't change the resolution if there's no difference from the old one. Call gdisplay_shrink_wrap() to re-calculate scale factors and refresh the display on resolution change. Layer undo doesn't have sub-types anymore, uses main UndoType instead. * app/layer.h: Remove LayerUndoType * app/qmask.c: fix qmask undo so it actually works. * app/undo.h: new types for undo_push_layer{,_mask} and undo_push_qmask. * app/undo.c: change way group boundaries are represented: each Undo has a group_boundary boolean set to TRUE if this is the start or the end of a group, and the type of the Undo is the group's type. Within a group, each Undo keeps its own type. This allows pop funcs and free funcs to do type-specific things (eg needed by layer and channel stuff). Don't maintain per-drawable dirty flags anymore. Floating sel to layer and layer rename now uses meaningful undo types. * app/undo_types.h: more specific undo types: LAYER_{ADD,REMOVE}_UNDO, LAYER_MASK_{ADD,REMOVE}_UNDO, LAYER_RENAME_UNDO, and PARASITE_{ATTACH,DETACH}_UNDO. * app/undo_history.c: oops - undo stack was being placed into gtk list in wrong order. * app/edit_selection.c: push more descriptive LAYER_DISPLACE_UNDO rather than MISC_UNDO. * app/layers_dialog.c: better tagging of undo types
1999-10-02 02:43:24 +08:00
return dest;
}
void
gimp_image_invalidate (GimpImage *gimage,
gint x,
gint y,
gint w,
gint h,
gint x1,
gint y1,
gint x2,
gint y2)
{
Tile *tile;
TileManager *tm;
gint i, j;
gint startx, starty;
gint endx, endy;
gint tilex, tiley;
g_return_if_fail (GIMP_IS_IMAGE (gimage));
tm = gimp_image_projection (gimage);
startx = x;
starty = y;
endx = x + w;
endy = y + h;
/* invalidate all tiles which are located outside of the displayed area
* all tiles inside the displayed area are constructed.
*/
for (i = y; i < (y + h); i += (TILE_HEIGHT - (i % TILE_HEIGHT)))
for (j = x; j < (x + w); j += (TILE_WIDTH - (j % TILE_WIDTH)))
{
tile = tile_manager_get_tile (tm, j, i, FALSE, FALSE);
Add default to Cancel button, remove unset GTK_RECEIVES_DEFAULT from Sat Feb 20 16:12:33 CST 1999 Shawn T. Amundson <amundson@gimp.org> * app/tips_dialog.c: Add default to Cancel button, remove unset GTK_RECEIVES_DEFAULT from prev/next buttons (they are like toolbar buttons), changed abreviated prev to previous, prev/next button are now same size, cancel button is in a button box. Added vboxes where necessary to prevent prev/next and check button from filling vertically. * app/app_procs.c: when splashscreen dialog is larger than the logo, (due to huge font), center logo. * app/file_new_dialog.c: patch from Marco Lamb <lm@geocities.com> disallows resizing, changes vertical expanding of widgets to not occur * app/palette.c: patch from Marco Lamb <lm@geocities.com>. Makes +/- buttons for zoom pixmaps (eventually, these can be replaced with a magnifying glass with a little +/- I think), so that they no longer expand as they did before. I modified his patch so it did not create a misused toolbar. I did some other stuff here too, moved Close button to the left, made it the window's default, and unset GTK_RECEIVES_DEFAULT off of the non-bottom buttons. * app/actionarea.c: another patch from Marco Lamb <lm@geocities.com>. This one changes buttons to be put in a button box which is right justified. If we decide later that spread is better, we can change this easy enough. * app/tools/zoom_in.xpm, app/tools/zoom_out.xpm: + and - graphics. * libgimp/gimpunit.h libgimp/gimpunit.c: New files from Michael Natterer <mitschel@cs.tu-berlin.de>, gimp_unit_* routines. * app/gimage.h app/gimpimage.h app/gimpimage.c app/gimpimageP.h app/xcf.c: Patches from Michael Natterer <mitschel@cs.tu-berlin.de>, which keep a unit assocated with an image.
1999-02-21 10:08:15 +08:00
/* check if the tile is outside the bounds */
if ((MIN ((j + tile_ewidth(tile)), x2) - MAX (j, x1)) <= 0)
{
tile_invalidate_tile (&tile, tm, j, i);
if (j < x1)
startx = MAX (startx, (j + tile_ewidth(tile)));
else
endx = MIN (endx, j);
}
else if (MIN ((i + tile_eheight(tile)), y2) - MAX (i, y1) <= 0)
{
tile_invalidate_tile (&tile, tm, j, i);
if (i < y1)
starty = MAX (starty, (i + tile_eheight(tile)));
else
endy = MIN (endy, i);
}
else
{
/* If the tile is not valid, make sure we get the entire tile
* in the construction extents
*/
if (tile_is_valid (tile) == FALSE)
{
tilex = j - (j % TILE_WIDTH);
tiley = i - (i % TILE_HEIGHT);
startx = MIN (startx, tilex);
endx = MAX (endx, tilex + tile_ewidth (tile));
starty = MIN (starty, tiley);
endy = MAX (endy, tiley + tile_eheight (tile));
tile_mark_valid (tile); /* hmmmmmmm..... */
}
}
}
if ((endx - startx) > 0 && (endy - starty) > 0)
gimp_image_construct (gimage,
startx, starty,
(endx - startx), (endy - starty));
Add default to Cancel button, remove unset GTK_RECEIVES_DEFAULT from Sat Feb 20 16:12:33 CST 1999 Shawn T. Amundson <amundson@gimp.org> * app/tips_dialog.c: Add default to Cancel button, remove unset GTK_RECEIVES_DEFAULT from prev/next buttons (they are like toolbar buttons), changed abreviated prev to previous, prev/next button are now same size, cancel button is in a button box. Added vboxes where necessary to prevent prev/next and check button from filling vertically. * app/app_procs.c: when splashscreen dialog is larger than the logo, (due to huge font), center logo. * app/file_new_dialog.c: patch from Marco Lamb <lm@geocities.com> disallows resizing, changes vertical expanding of widgets to not occur * app/palette.c: patch from Marco Lamb <lm@geocities.com>. Makes +/- buttons for zoom pixmaps (eventually, these can be replaced with a magnifying glass with a little +/- I think), so that they no longer expand as they did before. I modified his patch so it did not create a misused toolbar. I did some other stuff here too, moved Close button to the left, made it the window's default, and unset GTK_RECEIVES_DEFAULT off of the non-bottom buttons. * app/actionarea.c: another patch from Marco Lamb <lm@geocities.com>. This one changes buttons to be put in a button box which is right justified. If we decide later that spread is better, we can change this easy enough. * app/tools/zoom_in.xpm, app/tools/zoom_out.xpm: + and - graphics. * libgimp/gimpunit.h libgimp/gimpunit.c: New files from Michael Natterer <mitschel@cs.tu-berlin.de>, gimp_unit_* routines. * app/gimage.h app/gimpimage.h app/gimpimage.c app/gimpimageP.h app/xcf.c: Patches from Michael Natterer <mitschel@cs.tu-berlin.de>, which keep a unit assocated with an image.
1999-02-21 10:08:15 +08:00
}
void
gimp_image_invalidate_without_render (GimpImage *gimage,
gint x,
gint y,
gint w,
gint h,
gint x1,
gint y1,
gint x2,
gint y2)
{
Tile *tile;
TileManager *tm;
gint i, j;
g_return_if_fail (GIMP_IS_IMAGE (gimage));
tm = gimp_image_projection (gimage);
/* invalidate all tiles which are located outside of the displayed area
* all tiles inside the displayed area are constructed.
*/
for (i = y; i < (y + h); i += (TILE_HEIGHT - (i % TILE_HEIGHT)))
for (j = x; j < (x + w); j += (TILE_WIDTH - (j % TILE_WIDTH)))
{
tile = tile_manager_get_tile (tm, j, i, FALSE, FALSE);
/* check if the tile is outside the bounds */
if ((MIN ((j + tile_ewidth(tile)), x2) - MAX (j, x1)) <= 0)
{
tile_invalidate_tile (&tile, tm, j, i);
}
else if (MIN ((i + tile_eheight(tile)), y2) - MAX (i, y1) <= 0)
{
tile_invalidate_tile (&tile, tm, j, i);
}
}
}
/* private functions */
static void
gimp_image_projection_validate_tile (TileManager *tm,
Tile *tile)
{
GimpImage *gimage;
gint x, y;
gint w, h;
/* Get the gimage from the tilemanager */
gimage = (GimpImage *) tile_manager_get_user_data (tm);
gimp_set_busy_until_idle (gimage->gimp);
/* Find the coordinates of this tile */
tile_manager_get_tile_coordinates (tm, tile, &x, &y);
w = tile_ewidth (tile);
h = tile_eheight (tile);
gimp_image_construct (gimage, x, y, w, h);
}
static void
gimp_image_construct_layers (GimpImage *gimage,
gint x,
gint y,
gint w,
gint h)
{
GimpLayer *layer;
gint x1, y1, x2, y2;
PixelRegion src1PR, src2PR, maskPR;
PixelRegion * mask;
GList *list;
GList *reverse_list;
gint off_x;
gint off_y;
/* composite the floating selection if it exists */
if ((layer = gimp_image_floating_sel (gimage)))
floating_sel_composite (layer, x, y, w, h, FALSE);
reverse_list = NULL;
for (list = GIMP_LIST (gimage->layers)->list;
list;
list = g_list_next (list))
{
layer = (GimpLayer *) list->data;
/* only add layers that are visible and not floating selections
* to the list
*/
if (! gimp_layer_is_floating_sel (layer) &&
gimp_drawable_get_visible (GIMP_DRAWABLE (layer)))
{
reverse_list = g_list_prepend (reverse_list, layer);
}
}
for (list = reverse_list; list; list = g_list_next (list))
{
layer = (GimpLayer *) list->data;
gimp_drawable_offsets (GIMP_DRAWABLE (layer), &off_x, &off_y);
x1 = CLAMP (off_x, x, x + w);
y1 = CLAMP (off_y, y, y + h);
x2 = CLAMP (off_x + gimp_drawable_width (GIMP_DRAWABLE (layer)),
x, x + w);
y2 = CLAMP (off_y + gimp_drawable_height (GIMP_DRAWABLE (layer)),
y, y + h);
/* configure the pixel regions */
pixel_region_init (&src1PR, gimp_image_projection (gimage),
x1, y1, (x2 - x1), (y2 - y1),
TRUE);
/* If we're showing the layer mask instead of the layer... */
if (layer->mask && layer->mask->show_mask)
{
pixel_region_init (&src2PR,
gimp_drawable_data (GIMP_DRAWABLE (layer->mask)),
(x1 - off_x), (y1 - off_y),
(x2 - x1), (y2 - y1), FALSE);
copy_gray_to_region (&src2PR, &src1PR);
}
/* Otherwise, normal */
else
{
pixel_region_init (&src2PR,
gimp_drawable_data (GIMP_DRAWABLE (layer)),
(x1 - off_x), (y1 - off_y),
(x2 - x1), (y2 - y1), FALSE);
if (layer->mask && layer->mask->apply_mask)
{
pixel_region_init (&maskPR,
gimp_drawable_data (GIMP_DRAWABLE (layer->mask)),
(x1 - off_x), (y1 - off_y),
(x2 - x1), (y2 - y1), FALSE);
mask = &maskPR;
}
else
mask = NULL;
/* Based on the type of the layer, project the layer onto the
* projection image...
*/
switch (gimp_drawable_type (GIMP_DRAWABLE (layer)))
{
case GIMP_RGB_IMAGE: case GIMP_GRAY_IMAGE:
/* no mask possible */
project_intensity (gimage, layer, &src2PR, &src1PR, mask);
break;
case GIMP_RGBA_IMAGE: case GIMP_GRAYA_IMAGE:
project_intensity_alpha (gimage, layer, &src2PR, &src1PR, mask);
break;
case GIMP_INDEXED_IMAGE:
/* no mask possible */
project_indexed (gimage, layer, &src2PR, &src1PR);
break;
case GIMP_INDEXEDA_IMAGE:
project_indexed_alpha (gimage, layer, &src2PR, &src1PR, mask);
break;
default:
break;
}
}
gimage->construct_flag = TRUE; /* something was projected */
}
g_list_free (reverse_list);
}
static void
gimp_image_construct_channels (GimpImage *gimage,
gint x,
gint y,
gint w,
gint h)
{
GimpChannel *channel;
PixelRegion src1PR;
PixelRegion src2PR;
GList *list;
GList *reverse_list = NULL;
/* reverse the channel list */
for (list = GIMP_LIST (gimage->channels)->list;
list;
list = g_list_next (list))
{
reverse_list = g_list_prepend (reverse_list, list->data);
}
for (list = reverse_list; list; list = g_list_next (list))
{
channel = (GimpChannel *) list->data;
if (gimp_drawable_get_visible (GIMP_DRAWABLE (channel)))
{
/* configure the pixel regions */
pixel_region_init (&src1PR,
gimp_image_projection (gimage),
x, y, w, h,
TRUE);
pixel_region_init (&src2PR,
gimp_drawable_data (GIMP_DRAWABLE (channel)),
x, y, w, h,
FALSE);
project_channel (gimage, channel, &src1PR, &src2PR);
gimage->construct_flag = TRUE;
}
}
g_list_free (reverse_list);
}
static void
gimp_image_initialize_projection (GimpImage *gimage,
gint x,
gint y,
gint w,
gint h)
{
GList *list;
GimpLayer *layer;
gint coverage = 0;
PixelRegion PR;
guchar clear[4] = { 0, 0, 0, 0 };
/* this function determines whether a visible layer
* provides complete coverage over the image. If not,
* the projection is initialized to transparent
*/
for (list = GIMP_LIST (gimage->layers)->list;
list;
list = g_list_next (list))
{
gint off_x, off_y;
layer = (GimpLayer *) list->data;
gimp_drawable_offsets (GIMP_DRAWABLE (layer), &off_x, &off_y);
if (gimp_drawable_get_visible (GIMP_DRAWABLE (layer)) &&
! gimp_drawable_has_alpha (GIMP_DRAWABLE (layer)) &&
(off_x <= x) &&
(off_y <= y) &&
(off_x + gimp_drawable_width (GIMP_DRAWABLE (layer)) >= x + w) &&
(off_y + gimp_drawable_height (GIMP_DRAWABLE (layer)) >= y + h))
{
coverage = 1;
break;
}
}
if (!coverage)
{
pixel_region_init (&PR, gimp_image_projection (gimage),
x, y, w, h, TRUE);
color_region (&PR, clear);
}
}
static void
gimp_image_construct (GimpImage *gimage,
gint x,
gint y,
gint w,
gint h)
{
g_return_if_fail (GIMP_IS_IMAGE (gimage));
#if 0
gint xoff;
gint yoff;
/* set the construct flag, used to determine if anything
* has been written to the gimage raw image yet.
*/
gimage->construct_flag = FALSE;
if (gimage->layers)
{
gimp_drawable_offsets (GIMP_DRAWABLE ((GimpLayer*) gimage->layers->data),
&xoff, &yoff);
}
if ((gimage->layers) && /* There's a layer. */
(! g_slist_next (gimage->layers)) && /* It's the only layer. */
(gimp_drawable_has_alpha (GIMP_DRAWABLE (gimage->layers->data))) &&
/* It's !flat. */
(gimp_drawable_get_visible (GIMP_DRAWABLE (gimage->layers->data))) &&
/* It's visible. */
(gimp_drawable_width (GIMP_DRAWABLE (gimage->layers->data)) ==
gimage->width) &&
(gimp_drawable_height (GIMP_DRAWABLE (gimage->layers->data)) ==
gimage->height) && /* Covers all. */
(!gimp_drawable_is_indexed (GIMP_DRAWABLE (gimage->layers->data))) &&
/* Not indexed. */
(((GimpLayer *)(gimage->layers->data))->opacity == GIMP_OPACITY_OPAQUE)
/* Opaque */
)
{
gint xoff;
gint yoff;
gimp_drawable_offsets (GIMP_DRAWABLE (gimage->layers->data),
&xoff, &yoff);
if ((xoff==0) && (yoff==0)) /* Starts at 0,0 */
{
PixelRegion srcPR, destPR;
gpointer pr;
g_warning("Can use cow-projection hack. Yay!");
pixel_region_init (&srcPR, gimp_drawable_data
(GIMP_DRAWABLE (gimage->layers->data)),
x, y, w,h, FALSE);
pixel_region_init (&destPR,
gimp_image_projection (gimage),
x, y, w,h, TRUE);
for (pr = pixel_regions_register (2, &srcPR, &destPR);
pr != NULL;
pr = pixel_regions_process (pr))
{
tile_manager_map_over_tile (destPR.tiles,
destPR.curtile, srcPR.curtile);
}
gimage->construct_flag = TRUE;
gimp_image_construct_channels (gimage, x, y, w, h);
return;
}
}
#else
gimage->construct_flag = FALSE;
#endif
/* First, determine if the projection image needs to be
* initialized--this is the case when there are no visible
* layers that cover the entire canvas--either because layers
* are offset or only a floating selection is visible
*/
gimp_image_initialize_projection (gimage, x, y, w, h);
/* call functions which process the list of layers and
* the list of channels
*/
gimp_image_construct_layers (gimage, x, y, w, h);
gimp_image_construct_channels (gimage, x, y, w, h);
}
static void
project_intensity (GimpImage *gimage,
GimpLayer *layer,
PixelRegion *src,
PixelRegion *dest,
PixelRegion *mask)
{
if (! gimage->construct_flag)
initial_region (src, dest, mask, NULL,
layer->opacity * 255.999,
layer->mode,
gimage->visible,
INITIAL_INTENSITY);
else
combine_regions (dest, src, dest, mask, NULL,
layer->opacity * 255.999,
layer->mode,
gimage->visible,
COMBINE_INTEN_A_INTEN);
}
static void
project_intensity_alpha (GimpImage *gimage,
GimpLayer *layer,
PixelRegion *src,
PixelRegion *dest,
PixelRegion *mask)
{
if (! gimage->construct_flag)
initial_region (src, dest, mask, NULL,
layer->opacity * 255.999,
layer->mode,
gimage->visible,
INITIAL_INTENSITY_ALPHA);
else
combine_regions (dest, src, dest, mask, NULL,
layer->opacity * 255.999,
layer->mode,
gimage->visible,
COMBINE_INTEN_A_INTEN_A);
}
static void
project_indexed (GimpImage *gimage,
GimpLayer *layer,
PixelRegion *src,
PixelRegion *dest)
{
if (! gimage->construct_flag)
initial_region (src, dest, NULL, gimage->cmap,
layer->opacity * 255.999,
layer->mode,
gimage->visible,
INITIAL_INDEXED);
else
g_warning ("%s: unable to project indexed image.", G_GNUC_PRETTY_FUNCTION);
}
static void
project_indexed_alpha (GimpImage *gimage,
GimpLayer *layer,
PixelRegion *src,
PixelRegion *dest,
PixelRegion *mask)
{
if (! gimage->construct_flag)
initial_region (src, dest, mask, gimage->cmap,
layer->opacity * 255.999,
layer->mode,
gimage->visible,
INITIAL_INDEXED_ALPHA);
else
combine_regions (dest, src, dest, mask, gimage->cmap,
layer->opacity * 255.999,
layer->mode,
gimage->visible,
COMBINE_INTEN_A_INDEXED_A);
}
static void
project_channel (GimpImage *gimage,
GimpChannel *channel,
PixelRegion *src,
PixelRegion *src2)
{
guchar col[3];
guchar opacity;
gint type;
gimp_rgba_get_uchar (&channel->color,
&col[0], &col[1], &col[2], &opacity);
if (! gimage->construct_flag)
{
type = (channel->show_masked) ?
INITIAL_CHANNEL_MASK : INITIAL_CHANNEL_SELECTION;
initial_region (src2, src, NULL, col,
opacity,
GIMP_NORMAL_MODE,
NULL,
type);
}
else
{
type = (channel->show_masked) ?
COMBINE_INTEN_A_CHANNEL_MASK : COMBINE_INTEN_A_CHANNEL_SELECTION;
combine_regions (src, src2, src, NULL, col,
opacity,
GIMP_NORMAL_MODE,
NULL,
type);
}
}