1998-06-28 18:39:58 +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.
|
|
|
|
*/
|
2000-12-11 11:33:25 +08:00
|
|
|
|
2000-04-28 01:27:28 +08:00
|
|
|
#include "config.h"
|
|
|
|
|
2001-08-14 22:53:55 +08:00
|
|
|
#include <glib-object.h>
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2001-01-24 02:49:44 +08:00
|
|
|
#include "libgimpcolor/gimpcolor.h"
|
|
|
|
|
2001-05-10 06:34:59 +08:00
|
|
|
#include "core-types.h"
|
|
|
|
|
2001-05-15 19:25:25 +08:00
|
|
|
#include "base/pixel-region.h"
|
|
|
|
#include "base/tile-manager.h"
|
|
|
|
#include "base/tile.h"
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2001-04-07 23:58:26 +08:00
|
|
|
#include "paint-funcs/paint-funcs.h"
|
|
|
|
|
2001-07-05 03:31:35 +08:00
|
|
|
#include "gimp.h"
|
2000-12-29 23:22:01 +08:00
|
|
|
#include "gimpimage.h"
|
2001-11-28 11:08:03 +08:00
|
|
|
#include "gimpimage-projection.h"
|
2001-02-02 02:44:22 +08:00
|
|
|
#include "gimplayer.h"
|
2002-02-22 06:19:45 +08:00
|
|
|
#include "gimplayer-floating-sel.h"
|
2001-01-29 00:44:22 +08:00
|
|
|
#include "gimplayermask.h"
|
2001-02-19 21:06:09 +08:00
|
|
|
#include "gimplist.h"
|
2001-07-05 03:31:35 +08:00
|
|
|
|
2001-05-15 19:25:25 +08:00
|
|
|
|
2001-11-28 11:08:03 +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)
|
1998-06-28 18:39:58 +08:00
|
|
|
{
|
|
|
|
if (gimage->projection)
|
2001-11-28 11:08:03 +08:00
|
|
|
gimp_image_projection_free (gimage);
|
1998-06-28 18:39:58 +08:00
|
|
|
|
|
|
|
/* 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:
|
1998-06-28 18:39:58 +08:00
|
|
|
gimage->proj_bytes = 4;
|
2001-12-12 02:11:56 +08:00
|
|
|
gimage->proj_type = GIMP_RGBA_IMAGE;
|
1998-06-28 18:39:58 +08:00
|
|
|
break;
|
2001-12-11 23:58:07 +08:00
|
|
|
case GIMP_GRAY:
|
1998-06-28 18:39:58 +08:00
|
|
|
gimage->proj_bytes = 2;
|
2001-12-12 02:11:56 +08:00
|
|
|
gimage->proj_type = GIMP_GRAYA_IMAGE;
|
1998-06-28 18:39:58 +08:00
|
|
|
break;
|
|
|
|
default:
|
1999-08-22 19:45:31 +08:00
|
|
|
g_assert_not_reached ();
|
1998-06-28 18:39:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* allocate the new projection */
|
2001-01-15 12:37:01 +08:00
|
|
|
gimage->projection = tile_manager_new (gimage->width, gimage->height,
|
|
|
|
gimage->proj_bytes);
|
1998-07-29 07:13:36 +08:00
|
|
|
tile_manager_set_user_data (gimage->projection, (void *) gimage);
|
2001-11-28 11:08:03 +08:00
|
|
|
tile_manager_set_validate_proc (gimage->projection,
|
|
|
|
gimp_image_projection_validate_tile);
|
1998-06-28 18:39:58 +08:00
|
|
|
}
|
|
|
|
|
2001-11-28 11:08:03 +08:00
|
|
|
void
|
|
|
|
gimp_image_projection_free (GimpImage *gimage)
|
1998-06-28 18:39:58 +08:00
|
|
|
{
|
2001-08-11 22:39:19 +08:00
|
|
|
g_return_if_fail (GIMP_IS_IMAGE (gimage));
|
1998-06-28 18:39:58 +08:00
|
|
|
|
2001-08-11 22:39:19 +08:00
|
|
|
if (gimage->projection)
|
|
|
|
{
|
|
|
|
tile_manager_destroy (gimage->projection);
|
|
|
|
gimage->projection = NULL;
|
|
|
|
}
|
1998-06-28 18:39:58 +08:00
|
|
|
}
|
|
|
|
|
2001-11-28 11:08:03 +08:00
|
|
|
TileManager *
|
|
|
|
gimp_image_projection (GimpImage *gimage)
|
1998-06-28 18:39:58 +08:00
|
|
|
{
|
2001-11-28 11:08:03 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
|
1998-06-28 18:39:58 +08:00
|
|
|
|
2001-11-28 11:08:03 +08:00
|
|
|
if ((gimage->projection == NULL) ||
|
|
|
|
(tile_manager_width (gimage->projection) != gimage->width) ||
|
|
|
|
(tile_manager_height (gimage->projection) != gimage->height))
|
1998-06-28 18:39:58 +08:00
|
|
|
{
|
2001-11-28 11:08:03 +08:00
|
|
|
gimp_image_projection_allocate (gimage);
|
1998-06-28 18:39:58 +08:00
|
|
|
}
|
2001-11-28 11:08:03 +08:00
|
|
|
|
|
|
|
return gimage->projection;
|
1998-06-28 18:39:58 +08:00
|
|
|
}
|
|
|
|
|
2001-11-28 11:08:03 +08:00
|
|
|
GimpImageType
|
|
|
|
gimp_image_projection_type (const GimpImage *gimage)
|
2001-04-13 22:50:43 +08:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), -1);
|
|
|
|
|
2001-11-28 11:08:03 +08:00
|
|
|
return gimage->proj_type;
|
2001-04-13 22:50:43 +08:00
|
|
|
}
|
|
|
|
|
2001-11-28 11:08:03 +08:00
|
|
|
gint
|
|
|
|
gimp_image_projection_bytes (const GimpImage *gimage)
|
2001-04-13 22:50:43 +08:00
|
|
|
{
|
2001-11-28 11:08:03 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), -1);
|
2001-04-13 22:50:43 +08:00
|
|
|
|
2001-11-28 11:08:03 +08:00
|
|
|
return gimage->proj_bytes;
|
2001-04-13 22:50:43 +08:00
|
|
|
}
|
|
|
|
|
2002-03-04 22:52:54 +08:00
|
|
|
gdouble
|
2001-11-28 11:08:03 +08:00
|
|
|
gimp_image_projection_opacity (const GimpImage *gimage)
|
1998-06-28 18:39:58 +08:00
|
|
|
{
|
2002-03-04 22:52:54 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), GIMP_OPACITY_OPAQUE);
|
2001-08-11 22:39:19 +08:00
|
|
|
|
2002-03-04 22:52:54 +08:00
|
|
|
return GIMP_OPACITY_OPAQUE;
|
2001-01-14 11:55:56 +08:00
|
|
|
}
|
1998-06-28 18:39:58 +08:00
|
|
|
|
2001-11-28 11:08:03 +08:00
|
|
|
guchar *
|
|
|
|
gimp_image_projection_get_color_at (GimpImage *gimage,
|
|
|
|
gint x,
|
|
|
|
gint y)
|
1998-10-05 18:05:29 +08:00
|
|
|
{
|
2001-11-28 11:08:03 +08:00
|
|
|
Tile *tile;
|
|
|
|
guchar *src;
|
|
|
|
guchar *dest;
|
2001-08-11 22:39:19 +08:00
|
|
|
|
2001-11-28 11:08:03 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
|
2000-01-08 18:55:05 +08:00
|
|
|
|
2001-11-28 11:08:03 +08:00
|
|
|
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
|
|
|
|
2001-11-28 11:08:03 +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
|
|
|
|
2001-11-28 11:08:03 +08:00
|
|
|
return dest;
|
1998-10-05 18:05:29 +08:00
|
|
|
}
|
|
|
|
|
1998-11-15 07:28:47 +08:00
|
|
|
void
|
2001-11-28 11:08:03 +08:00
|
|
|
gimp_image_invalidate (GimpImage *gimage,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint w,
|
|
|
|
gint h,
|
|
|
|
gint x1,
|
|
|
|
gint y1,
|
|
|
|
gint x2,
|
|
|
|
gint y2)
|
1998-10-05 18:05:29 +08:00
|
|
|
{
|
2001-11-28 11:08:03 +08:00
|
|
|
Tile *tile;
|
|
|
|
TileManager *tm;
|
|
|
|
gint i, j;
|
|
|
|
gint startx, starty;
|
|
|
|
gint endx, endy;
|
|
|
|
gint tilex, tiley;
|
|
|
|
|
2001-08-11 22:39:19 +08:00
|
|
|
g_return_if_fail (GIMP_IS_IMAGE (gimage));
|
1999-08-22 19:45:31 +08:00
|
|
|
|
2001-11-28 11:08:03 +08:00
|
|
|
tm = gimp_image_projection (gimage);
|
1998-10-05 18:05:29 +08:00
|
|
|
|
2001-11-28 11:08:03 +08:00
|
|
|
startx = x;
|
|
|
|
starty = y;
|
|
|
|
endx = x + w;
|
|
|
|
endy = y + h;
|
1999-09-30 00:44:52 +08:00
|
|
|
|
2001-11-28 11:08:03 +08:00
|
|
|
/* 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
|
|
|
|
2001-11-28 11:08:03 +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..... */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-08-11 22:39:19 +08:00
|
|
|
|
2001-11-28 11:08:03 +08:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2001-11-11 03:10:28 +08:00
|
|
|
void
|
2001-11-28 11:08:03 +08:00
|
|
|
gimp_image_invalidate_without_render (GimpImage *gimage,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint w,
|
|
|
|
gint h,
|
|
|
|
gint x1,
|
|
|
|
gint y1,
|
|
|
|
gint x2,
|
|
|
|
gint y2)
|
2001-11-11 03:10:28 +08:00
|
|
|
{
|
2001-11-28 11:08:03 +08:00
|
|
|
Tile *tile;
|
|
|
|
TileManager *tm;
|
|
|
|
gint i, j;
|
2001-11-11 03:10:28 +08:00
|
|
|
|
2001-11-28 11:08:03 +08:00
|
|
|
g_return_if_fail (GIMP_IS_IMAGE (gimage));
|
2001-11-11 03:10:28 +08:00
|
|
|
|
2001-11-28 11:08:03 +08:00
|
|
|
tm = gimp_image_projection (gimage);
|
2001-11-11 03:10:28 +08:00
|
|
|
|
2001-11-28 11:08:03 +08:00
|
|
|
/* 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);
|
2001-11-11 03:10:28 +08:00
|
|
|
|
2001-11-28 11:08:03 +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);
|
|
|
|
}
|
|
|
|
else if (MIN ((i + tile_eheight(tile)), y2) - MAX (i, y1) <= 0)
|
|
|
|
{
|
|
|
|
tile_invalidate_tile (&tile, tm, j, i);
|
|
|
|
}
|
|
|
|
}
|
2001-11-11 03:10:28 +08:00
|
|
|
}
|
|
|
|
|
2001-08-11 22:39:19 +08:00
|
|
|
|
2001-11-28 11:08:03 +08:00
|
|
|
/* private functions */
|
1998-10-27 17:26:38 +08:00
|
|
|
|
2001-11-28 11:08:03 +08:00
|
|
|
static void
|
|
|
|
gimp_image_projection_validate_tile (TileManager *tm,
|
|
|
|
Tile *tile)
|
1998-10-27 17:26:38 +08:00
|
|
|
{
|
2001-11-28 11:08:03 +08:00
|
|
|
GimpImage *gimage;
|
|
|
|
gint x, y;
|
|
|
|
gint w, h;
|
1998-10-05 18:05:29 +08:00
|
|
|
|
2001-11-28 11:08:03 +08:00
|
|
|
/* Get the gimage from the tilemanager */
|
|
|
|
gimage = (GimpImage *) tile_manager_get_user_data (tm);
|
2001-08-11 22:39:19 +08:00
|
|
|
|
2001-11-28 11:08:03 +08:00
|
|
|
gimp_set_busy_until_idle (gimage->gimp);
|
2000-12-29 00:19:55 +08:00
|
|
|
|
2001-11-28 11:08:03 +08:00
|
|
|
/* Find the coordinates of this tile */
|
|
|
|
tile_manager_get_tile_coordinates (tm, tile, &x, &y);
|
|
|
|
w = tile_ewidth (tile);
|
|
|
|
h = tile_eheight (tile);
|
2001-08-11 22:39:19 +08:00
|
|
|
|
2001-11-28 11:08:03 +08:00
|
|
|
gimp_image_construct (gimage, x, y, w, h);
|
2000-12-29 00:19:55 +08:00
|
|
|
}
|
|
|
|
|
2001-11-28 11:08:03 +08:00
|
|
|
static void
|
|
|
|
gimp_image_construct_layers (GimpImage *gimage,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint w,
|
|
|
|
gint h)
|
1998-06-28 18:39:58 +08:00
|
|
|
{
|
2001-01-29 10:45:02 +08:00
|
|
|
GimpLayer *layer;
|
2001-11-28 11:08:03 +08:00
|
|
|
gint x1, y1, x2, y2;
|
|
|
|
PixelRegion src1PR, src2PR, maskPR;
|
|
|
|
PixelRegion * mask;
|
2001-02-19 21:06:09 +08:00
|
|
|
GList *list;
|
2001-11-28 11:08:03 +08:00
|
|
|
GList *reverse_list;
|
|
|
|
gint off_x;
|
|
|
|
gint off_y;
|
1998-06-28 18:39:58 +08:00
|
|
|
|
2001-11-28 11:08:03 +08:00
|
|
|
/* composite the floating selection if it exists */
|
|
|
|
if ((layer = gimp_image_floating_sel (gimage)))
|
|
|
|
floating_sel_composite (layer, x, y, w, h, FALSE);
|
1998-06-28 18:39:58 +08:00
|
|
|
|
|
|
|
|
2001-11-28 11:08:03 +08:00
|
|
|
reverse_list = NULL;
|
1998-06-28 18:39:58 +08:00
|
|
|
|
2001-11-28 11:08:03 +08:00
|
|
|
for (list = GIMP_LIST (gimage->layers)->list;
|
2001-02-19 21:06:09 +08:00
|
|
|
list;
|
|
|
|
list = g_list_next (list))
|
1998-06-28 18:39:58 +08:00
|
|
|
{
|
2001-11-28 11:08:03 +08:00
|
|
|
layer = (GimpLayer *) list->data;
|
1999-07-10 02:15:39 +08:00
|
|
|
|
2001-11-28 11:08:03 +08:00
|
|
|
/* 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);
|
|
|
|
}
|
1999-07-10 02:15:39 +08:00
|
|
|
}
|
|
|
|
|
2001-11-28 11:08:03 +08:00
|
|
|
for (list = reverse_list; list; list = g_list_next (list))
|
1999-07-10 02:15:39 +08:00
|
|
|
{
|
2001-11-28 11:08:03 +08:00
|
|
|
layer = (GimpLayer *) list->data;
|
1999-07-10 02:15:39 +08:00
|
|
|
|
2001-11-28 11:08:03 +08:00
|
|
|
gimp_drawable_offsets (GIMP_DRAWABLE (layer), &off_x, &off_y);
|
1999-07-10 02:15:39 +08:00
|
|
|
|
2001-11-28 11:08:03 +08:00
|
|
|
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);
|
2000-12-28 02:15:37 +08:00
|
|
|
|
2001-11-28 11:08:03 +08:00
|
|
|
/* 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);
|
2000-12-28 02:15:37 +08:00
|
|
|
|
2001-11-28 11:08:03 +08:00
|
|
|
copy_gray_to_region (&src2PR, &src1PR);
|
1999-07-10 02:15:39 +08:00
|
|
|
}
|
2001-11-28 11:08:03 +08:00
|
|
|
/* Otherwise, normal */
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pixel_region_init (&src2PR,
|
|
|
|
gimp_drawable_data (GIMP_DRAWABLE (layer)),
|
|
|
|
(x1 - off_x), (y1 - off_y),
|
|
|
|
(x2 - x1), (y2 - y1), FALSE);
|
1998-06-28 18:39:58 +08:00
|
|
|
|
2001-11-28 11:08:03 +08:00
|
|
|
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;
|
1998-06-28 18:39:58 +08:00
|
|
|
|
2001-11-28 11:08:03 +08:00
|
|
|
/* Based on the type of the layer, project the layer onto the
|
|
|
|
* projection image...
|
|
|
|
*/
|
|
|
|
switch (gimp_drawable_type (GIMP_DRAWABLE (layer)))
|
|
|
|
{
|
2001-12-12 02:11:56 +08:00
|
|
|
case GIMP_RGB_IMAGE: case GIMP_GRAY_IMAGE:
|
2001-11-28 11:08:03 +08:00
|
|
|
/* no mask possible */
|
|
|
|
project_intensity (gimage, layer, &src2PR, &src1PR, mask);
|
|
|
|
break;
|
2000-12-28 02:15:37 +08:00
|
|
|
|
2001-12-12 02:11:56 +08:00
|
|
|
case GIMP_RGBA_IMAGE: case GIMP_GRAYA_IMAGE:
|
2001-11-28 11:08:03 +08:00
|
|
|
project_intensity_alpha (gimage, layer, &src2PR, &src1PR, mask);
|
|
|
|
break;
|
1998-06-28 18:39:58 +08:00
|
|
|
|
2001-12-12 02:11:56 +08:00
|
|
|
case GIMP_INDEXED_IMAGE:
|
2001-11-28 11:08:03 +08:00
|
|
|
/* no mask possible */
|
|
|
|
project_indexed (gimage, layer, &src2PR, &src1PR);
|
|
|
|
break;
|
1998-06-28 18:39:58 +08:00
|
|
|
|
2001-12-12 02:11:56 +08:00
|
|
|
case GIMP_INDEXEDA_IMAGE:
|
2001-11-28 11:08:03 +08:00
|
|
|
project_indexed_alpha (gimage, layer, &src2PR, &src1PR, mask);
|
|
|
|
break;
|
1998-06-28 18:39:58 +08:00
|
|
|
|
2001-11-28 11:08:03 +08:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2001-05-07 01:56:10 +08:00
|
|
|
|
2001-11-28 11:08:03 +08:00
|
|
|
gimage->construct_flag = TRUE; /* something was projected */
|
|
|
|
}
|
1999-01-11 07:36:29 +08:00
|
|
|
|
2001-11-28 11:08:03 +08:00
|
|
|
g_list_free (reverse_list);
|
1998-06-28 18:39:58 +08:00
|
|
|
}
|
|
|
|
|
2001-11-28 11:08:03 +08:00
|
|
|
static void
|
|
|
|
gimp_image_construct_channels (GimpImage *gimage,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint w,
|
|
|
|
gint h)
|
1998-06-28 18:39:58 +08:00
|
|
|
{
|
2001-01-29 10:45:02 +08:00
|
|
|
GimpChannel *channel;
|
2001-11-28 11:08:03 +08:00
|
|
|
PixelRegion src1PR;
|
|
|
|
PixelRegion src2PR;
|
2001-02-19 21:06:09 +08:00
|
|
|
GList *list;
|
2001-11-28 11:08:03 +08:00
|
|
|
GList *reverse_list = NULL;
|
2000-02-27 02:46:08 +08:00
|
|
|
|
2001-11-28 11:08:03 +08:00
|
|
|
/* reverse the channel list */
|
2001-02-19 21:06:09 +08:00
|
|
|
for (list = GIMP_LIST (gimage->channels)->list;
|
|
|
|
list;
|
|
|
|
list = g_list_next (list))
|
1998-06-28 18:39:58 +08:00
|
|
|
{
|
2001-11-28 11:08:03 +08:00
|
|
|
reverse_list = g_list_prepend (reverse_list, list->data);
|
1998-06-28 18:39:58 +08:00
|
|
|
}
|
|
|
|
|
2001-11-28 11:08:03 +08:00
|
|
|
for (list = reverse_list; list; list = g_list_next (list))
|
1998-06-28 18:39:58 +08:00
|
|
|
{
|
2001-11-28 11:08:03 +08:00
|
|
|
channel = (GimpChannel *) list->data;
|
2001-01-29 07:25:25 +08:00
|
|
|
|
2001-11-28 11:08:03 +08:00
|
|
|
if (gimp_drawable_get_visible (GIMP_DRAWABLE (channel)))
|
2000-02-27 02:46:08 +08:00
|
|
|
{
|
2001-11-28 11:08:03 +08:00
|
|
|
/* 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);
|
1998-06-28 18:39:58 +08:00
|
|
|
|
2001-11-28 11:08:03 +08:00
|
|
|
project_channel (gimage, channel, &src1PR, &src2PR);
|
1999-01-18 04:41:38 +08:00
|
|
|
|
2001-11-28 11:08:03 +08:00
|
|
|
gimage->construct_flag = TRUE;
|
1999-01-18 04:41:38 +08:00
|
|
|
}
|
|
|
|
}
|
1999-01-18 01:03:54 +08:00
|
|
|
|
2001-11-28 11:08:03 +08:00
|
|
|
g_list_free (reverse_list);
|
1998-06-28 18:39:58 +08:00
|
|
|
}
|
|
|
|
|
2001-11-28 11:08:03 +08:00
|
|
|
static void
|
|
|
|
gimp_image_initialize_projection (GimpImage *gimage,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint w,
|
|
|
|
gint h)
|
2001-06-05 07:11:31 +08:00
|
|
|
{
|
|
|
|
|
2001-11-28 11:08:03 +08:00
|
|
|
GList *list;
|
|
|
|
GimpLayer *layer;
|
|
|
|
gint coverage = 0;
|
|
|
|
PixelRegion PR;
|
|
|
|
guchar clear[4] = { 0, 0, 0, 0 };
|
2001-06-05 07:11:31 +08:00
|
|
|
|
2001-11-28 11:08:03 +08:00
|
|
|
/* 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;
|
2001-06-05 07:11:31 +08:00
|
|
|
list = g_list_next (list))
|
|
|
|
{
|
2001-11-28 11:08:03 +08:00
|
|
|
gint off_x, off_y;
|
2001-06-05 07:11:31 +08:00
|
|
|
|
|
|
|
layer = (GimpLayer *) list->data;
|
2001-11-28 11:08:03 +08:00
|
|
|
gimp_drawable_offsets (GIMP_DRAWABLE (layer), &off_x, &off_y);
|
2001-06-05 07:11:31 +08:00
|
|
|
|
2001-11-28 11:08:03 +08:00
|
|
|
if (gimp_drawable_get_visible (GIMP_DRAWABLE (layer)) &&
|
2002-02-01 00:47:20 +08:00
|
|
|
! gimp_drawable_has_alpha (GIMP_DRAWABLE (layer)) &&
|
2001-11-28 11:08:03 +08:00
|
|
|
(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;
|
|
|
|
}
|
2001-06-05 07:11:31 +08:00
|
|
|
}
|
|
|
|
|
2001-11-28 11:08:03 +08:00
|
|
|
if (!coverage)
|
2001-08-11 22:39:19 +08:00
|
|
|
{
|
2001-11-28 11:08:03 +08:00
|
|
|
pixel_region_init (&PR, gimp_image_projection (gimage),
|
|
|
|
x, y, w, h, TRUE);
|
|
|
|
color_region (&PR, clear);
|
2001-08-11 22:39:19 +08:00
|
|
|
}
|
1998-06-28 18:39:58 +08:00
|
|
|
}
|
|
|
|
|
2001-11-28 11:08:03 +08:00
|
|
|
static void
|
|
|
|
gimp_image_construct (GimpImage *gimage,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint w,
|
|
|
|
gint h)
|
1998-06-28 18:39:58 +08:00
|
|
|
{
|
2001-08-11 22:39:19 +08:00
|
|
|
g_return_if_fail (GIMP_IS_IMAGE (gimage));
|
|
|
|
|
2001-11-28 11:08:03 +08:00
|
|
|
#if 0
|
|
|
|
gint xoff;
|
|
|
|
gint yoff;
|
|
|
|
|
|
|
|
/* set the construct flag, used to determine if anything
|
|
|
|
* has been written to the gimage raw image yet.
|
1998-06-28 18:39:58 +08:00
|
|
|
*/
|
2001-11-28 11:08:03 +08:00
|
|
|
gimage->construct_flag = FALSE;
|
|
|
|
|
|
|
|
if (gimage->layers)
|
1998-06-28 18:39:58 +08:00
|
|
|
{
|
2001-11-28 11:08:03 +08:00
|
|
|
gimp_drawable_offsets (GIMP_DRAWABLE ((GimpLayer*) gimage->layers->data),
|
|
|
|
&xoff, &yoff);
|
1998-06-28 18:39:58 +08:00
|
|
|
}
|
|
|
|
|
2001-11-28 11:08:03 +08:00
|
|
|
if ((gimage->layers) && /* There's a layer. */
|
|
|
|
(! g_slist_next (gimage->layers)) && /* It's the only layer. */
|
2002-02-01 00:47:20 +08:00
|
|
|
(gimp_drawable_has_alpha (GIMP_DRAWABLE (gimage->layers->data))) &&
|
2001-11-28 11:08:03 +08:00
|
|
|
/* 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. */
|
2002-03-04 22:52:54 +08:00
|
|
|
(((GimpLayer *)(gimage->layers->data))->opacity == GIMP_OPACITY_OPAQUE)
|
2001-11-28 11:08:03 +08:00
|
|
|
/* Opaque */
|
|
|
|
)
|
1998-06-28 18:39:58 +08:00
|
|
|
{
|
2001-11-28 11:08:03 +08:00
|
|
|
gint xoff;
|
|
|
|
gint yoff;
|
|
|
|
|
|
|
|
gimp_drawable_offsets (GIMP_DRAWABLE (gimage->layers->data),
|
|
|
|
&xoff, &yoff);
|
1998-06-28 18:39:58 +08:00
|
|
|
|
2001-11-28 11:08:03 +08:00
|
|
|
if ((xoff==0) && (yoff==0)) /* Starts at 0,0 */
|
|
|
|
{
|
|
|
|
PixelRegion srcPR, destPR;
|
|
|
|
gpointer pr;
|
|
|
|
|
|
|
|
g_warning("Can use cow-projection hack. Yay!");
|
1998-06-28 18:39:58 +08:00
|
|
|
|
2001-11-28 11:08:03 +08:00
|
|
|
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);
|
1998-06-28 18:39:58 +08:00
|
|
|
|
2001-11-28 11:08:03 +08:00
|
|
|
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);
|
|
|
|
}
|
1998-06-28 18:39:58 +08:00
|
|
|
|
2001-11-28 11:08:03 +08:00
|
|
|
gimage->construct_flag = TRUE;
|
|
|
|
gimp_image_construct_channels (gimage, x, y, w, h);
|
1998-06-28 18:39:58 +08:00
|
|
|
|
2001-11-28 11:08:03 +08:00
|
|
|
return;
|
|
|
|
}
|
1998-06-28 18:39:58 +08:00
|
|
|
}
|
2001-11-28 11:08:03 +08:00
|
|
|
#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)
|
2002-03-04 22:52:54 +08:00
|
|
|
initial_region (src, dest, mask, NULL,
|
|
|
|
layer->opacity * 255.999,
|
|
|
|
layer->mode,
|
|
|
|
gimage->visible,
|
|
|
|
INITIAL_INTENSITY);
|
1998-06-28 18:39:58 +08:00
|
|
|
else
|
2002-03-04 22:52:54 +08:00
|
|
|
combine_regions (dest, src, dest, mask, NULL,
|
|
|
|
layer->opacity * 255.999,
|
|
|
|
layer->mode,
|
|
|
|
gimage->visible,
|
|
|
|
COMBINE_INTEN_A_INTEN);
|
1998-06-28 18:39:58 +08:00
|
|
|
}
|
|
|
|
|
2001-11-28 11:08:03 +08:00
|
|
|
static void
|
|
|
|
project_intensity_alpha (GimpImage *gimage,
|
|
|
|
GimpLayer *layer,
|
|
|
|
PixelRegion *src,
|
|
|
|
PixelRegion *dest,
|
|
|
|
PixelRegion *mask)
|
|
|
|
{
|
|
|
|
if (! gimage->construct_flag)
|
2002-03-04 22:52:54 +08:00
|
|
|
initial_region (src, dest, mask, NULL,
|
|
|
|
layer->opacity * 255.999,
|
|
|
|
layer->mode,
|
|
|
|
gimage->visible,
|
|
|
|
INITIAL_INTENSITY_ALPHA);
|
2001-11-28 11:08:03 +08:00
|
|
|
else
|
2002-03-04 22:52:54 +08:00
|
|
|
combine_regions (dest, src, dest, mask, NULL,
|
|
|
|
layer->opacity * 255.999,
|
|
|
|
layer->mode,
|
|
|
|
gimage->visible,
|
|
|
|
COMBINE_INTEN_A_INTEN_A);
|
2001-11-28 11:08:03 +08:00
|
|
|
}
|
1998-06-28 18:39:58 +08:00
|
|
|
|
2001-11-28 11:08:03 +08:00
|
|
|
static void
|
|
|
|
project_indexed (GimpImage *gimage,
|
|
|
|
GimpLayer *layer,
|
|
|
|
PixelRegion *src,
|
|
|
|
PixelRegion *dest)
|
1998-06-28 18:39:58 +08:00
|
|
|
{
|
2001-11-28 11:08:03 +08:00
|
|
|
if (! gimage->construct_flag)
|
2002-03-04 22:52:54 +08:00
|
|
|
initial_region (src, dest, NULL, gimage->cmap,
|
|
|
|
layer->opacity * 255.999,
|
|
|
|
layer->mode,
|
|
|
|
gimage->visible,
|
|
|
|
INITIAL_INDEXED);
|
2001-11-28 11:08:03 +08:00
|
|
|
else
|
|
|
|
g_warning ("%s: unable to project indexed image.", G_GNUC_PRETTY_FUNCTION);
|
|
|
|
}
|
1998-06-28 18:39:58 +08:00
|
|
|
|
2001-11-28 11:08:03 +08:00
|
|
|
static void
|
|
|
|
project_indexed_alpha (GimpImage *gimage,
|
|
|
|
GimpLayer *layer,
|
|
|
|
PixelRegion *src,
|
|
|
|
PixelRegion *dest,
|
|
|
|
PixelRegion *mask)
|
|
|
|
{
|
|
|
|
if (! gimage->construct_flag)
|
2002-03-04 22:52:54 +08:00
|
|
|
initial_region (src, dest, mask, gimage->cmap,
|
|
|
|
layer->opacity * 255.999,
|
|
|
|
layer->mode,
|
|
|
|
gimage->visible,
|
|
|
|
INITIAL_INDEXED_ALPHA);
|
2001-11-28 11:08:03 +08:00
|
|
|
else
|
2002-03-04 22:52:54 +08:00
|
|
|
combine_regions (dest, src, dest, mask, gimage->cmap,
|
|
|
|
layer->opacity * 255.999,
|
|
|
|
layer->mode,
|
|
|
|
gimage->visible,
|
|
|
|
COMBINE_INTEN_A_INDEXED_A);
|
2001-11-28 11:08:03 +08:00
|
|
|
}
|
2001-08-11 22:39:19 +08:00
|
|
|
|
2001-11-28 11:08:03 +08:00
|
|
|
static void
|
|
|
|
project_channel (GimpImage *gimage,
|
|
|
|
GimpChannel *channel,
|
|
|
|
PixelRegion *src,
|
|
|
|
PixelRegion *src2)
|
|
|
|
{
|
|
|
|
guchar col[3];
|
|
|
|
guchar opacity;
|
|
|
|
gint type;
|
1998-06-28 18:39:58 +08:00
|
|
|
|
2001-11-28 11:08:03 +08:00
|
|
|
gimp_rgba_get_uchar (&channel->color,
|
|
|
|
&col[0], &col[1], &col[2], &opacity);
|
1998-06-28 18:39:58 +08:00
|
|
|
|
2001-11-28 11:08:03 +08:00
|
|
|
if (! gimage->construct_flag)
|
1998-06-28 18:39:58 +08:00
|
|
|
{
|
2001-11-28 11:08:03 +08:00
|
|
|
type = (channel->show_masked) ?
|
|
|
|
INITIAL_CHANNEL_MASK : INITIAL_CHANNEL_SELECTION;
|
1998-06-28 18:39:58 +08:00
|
|
|
|
2002-03-04 22:52:54 +08:00
|
|
|
initial_region (src2, src, NULL, col,
|
|
|
|
opacity,
|
|
|
|
GIMP_NORMAL_MODE,
|
|
|
|
NULL,
|
|
|
|
type);
|
1998-06-28 18:39:58 +08:00
|
|
|
}
|
2001-11-28 11:08:03 +08:00
|
|
|
else
|
1998-06-28 18:39:58 +08:00
|
|
|
{
|
2001-11-28 11:08:03 +08:00
|
|
|
type = (channel->show_masked) ?
|
|
|
|
COMBINE_INTEN_A_CHANNEL_MASK : COMBINE_INTEN_A_CHANNEL_SELECTION;
|
1998-06-28 18:39:58 +08:00
|
|
|
|
2002-03-04 22:52:54 +08:00
|
|
|
combine_regions (src, src2, src, NULL, col,
|
|
|
|
opacity,
|
|
|
|
GIMP_NORMAL_MODE,
|
|
|
|
NULL,
|
|
|
|
type);
|
1998-06-28 18:39:58 +08:00
|
|
|
}
|
|
|
|
}
|