2006-12-10 05:33:38 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
1998-06-28 18:39:58 +08:00
|
|
|
* 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"
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2001-04-07 23:58:26 +08:00
|
|
|
#include "paint-funcs/paint-funcs.h"
|
|
|
|
|
2005-04-29 18:49:11 +08:00
|
|
|
#include "gimpdrawable.h"
|
2000-12-29 23:22:01 +08:00
|
|
|
#include "gimpimage.h"
|
2007-12-26 00:21:40 +08:00
|
|
|
#include "gimpimage-colormap.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"
|
2004-07-14 00:36:29 +08:00
|
|
|
#include "gimpprojection.h"
|
|
|
|
#include "gimpprojection-construct.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 */
|
|
|
|
|
2004-07-14 00:36:29 +08:00
|
|
|
static void gimp_projection_construct_layers (GimpProjection *proj,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint w,
|
|
|
|
gint h);
|
|
|
|
static void gimp_projection_construct_channels (GimpProjection *proj,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint w,
|
|
|
|
gint h);
|
|
|
|
static void gimp_projection_initialize (GimpProjection *proj,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint w,
|
|
|
|
gint h);
|
|
|
|
|
|
|
|
static void project_intensity (GimpProjection *proj,
|
|
|
|
GimpLayer *layer,
|
|
|
|
PixelRegion *src,
|
|
|
|
PixelRegion *dest,
|
|
|
|
PixelRegion *mask);
|
|
|
|
static void project_intensity_alpha (GimpProjection *proj,
|
|
|
|
GimpLayer *layer,
|
|
|
|
PixelRegion *src,
|
|
|
|
PixelRegion *dest,
|
|
|
|
PixelRegion *mask);
|
|
|
|
static void project_indexed (GimpProjection *proj,
|
|
|
|
GimpLayer *layer,
|
|
|
|
PixelRegion *src,
|
2006-05-24 03:18:00 +08:00
|
|
|
PixelRegion *dest,
|
|
|
|
PixelRegion *mask);
|
2004-07-14 00:36:29 +08:00
|
|
|
static void project_indexed_alpha (GimpProjection *proj,
|
|
|
|
GimpLayer *layer,
|
|
|
|
PixelRegion *src,
|
|
|
|
PixelRegion *dest,
|
|
|
|
PixelRegion *mask);
|
|
|
|
static void project_channel (GimpProjection *proj,
|
|
|
|
GimpChannel *channel,
|
|
|
|
PixelRegion *src,
|
|
|
|
PixelRegion *src2);
|
2001-11-28 11:08:03 +08:00
|
|
|
|
|
|
|
|
|
|
|
/* public functions */
|
|
|
|
|
|
|
|
void
|
2004-07-14 00:36:29 +08:00
|
|
|
gimp_projection_construct (GimpProjection *proj,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint w,
|
|
|
|
gint h)
|
1998-06-28 18:39:58 +08:00
|
|
|
{
|
2004-07-14 00:36:29 +08:00
|
|
|
g_return_if_fail (GIMP_IS_PROJECTION (proj));
|
2003-12-04 20:18:41 +08:00
|
|
|
|
2004-07-14 00:36:29 +08:00
|
|
|
#if 0
|
2006-03-29 01:08:36 +08:00
|
|
|
GimpImage *image = proj->image;
|
1998-06-28 18:39:58 +08:00
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
if ((gimp_container_num_children (image->layers) == 1)) /* a single layer */
|
1998-06-28 18:39:58 +08:00
|
|
|
{
|
2005-04-29 18:49:11 +08:00
|
|
|
GimpDrawable *layer;
|
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
layer = GIMP_DRAWABLE (gimp_container_get_child_by_index (image->layers,
|
2005-04-29 18:49:11 +08:00
|
|
|
0));
|
2005-05-31 22:49:01 +08:00
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
if (gimp_drawable_has_alpha (layer) &&
|
|
|
|
(gimp_item_get_visible (GIMP_ITEM (layer))) &&
|
|
|
|
(gimp_item_width (GIMP_ITEM (layer)) == image->width) &&
|
|
|
|
(gimp_item_height (GIMP_ITEM (layer)) == image->height) &&
|
|
|
|
(! gimp_drawable_is_indexed (layer)) &&
|
2005-04-29 18:49:11 +08:00
|
|
|
(gimp_layer_get_opacity (GIMP_LAYER (layer)) == GIMP_OPACITY_OPAQUE))
|
|
|
|
{
|
|
|
|
gint xoff;
|
|
|
|
gint yoff;
|
|
|
|
|
|
|
|
gimp_item_offsets (GIMP_ITEM (layer), &xoff, &yoff);
|
|
|
|
|
|
|
|
if (xoff == 0 && yoff == 0)
|
|
|
|
{
|
|
|
|
PixelRegion srcPR, destPR;
|
|
|
|
|
2005-04-29 22:06:08 +08:00
|
|
|
g_printerr ("cow-projection!");
|
2005-04-29 18:49:11 +08:00
|
|
|
|
2006-04-07 17:21:18 +08:00
|
|
|
pixel_region_init (&srcPR, gimp_drawable_get_tiles (layer),
|
2005-04-29 18:49:11 +08:00
|
|
|
x, y, w,h, FALSE);
|
|
|
|
pixel_region_init (&destPR, gimp_projection_get_tiles (proj),
|
|
|
|
x, y, w,h, TRUE);
|
|
|
|
|
2005-04-29 22:06:08 +08:00
|
|
|
copy_region (&srcPR, &destPR);
|
2005-04-29 18:49:11 +08:00
|
|
|
|
|
|
|
proj->construct_flag = TRUE;
|
|
|
|
|
|
|
|
gimp_projection_construct_channels (proj, x, y, w, h);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
2006-04-12 20:49:29 +08:00
|
|
|
}
|
2004-07-14 00:36:29 +08:00
|
|
|
}
|
|
|
|
#endif
|
1999-09-30 00:44:52 +08:00
|
|
|
|
2005-04-29 18:49:11 +08:00
|
|
|
proj->construct_flag = FALSE;
|
|
|
|
|
2004-07-14 00:36:29 +08:00
|
|
|
/* 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
|
2001-11-28 11:08:03 +08:00
|
|
|
*/
|
2004-07-14 00:36:29 +08:00
|
|
|
gimp_projection_initialize (proj, x, y, w, h);
|
2001-11-11 03:10:28 +08:00
|
|
|
|
2004-07-14 00:36:29 +08:00
|
|
|
/* call functions which process the list of layers and
|
|
|
|
* the list of channels
|
2001-11-28 11:08:03 +08:00
|
|
|
*/
|
2004-07-14 00:36:29 +08:00
|
|
|
gimp_projection_construct_layers (proj, x, y, w, h);
|
|
|
|
gimp_projection_construct_channels (proj, x, y, w, h);
|
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
|
2004-07-14 00:36:29 +08:00
|
|
|
gimp_projection_construct_layers (GimpProjection *proj,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint w,
|
|
|
|
gint h)
|
1998-06-28 18:39:58 +08:00
|
|
|
{
|
2005-05-31 22:49:01 +08:00
|
|
|
GimpLayer *layer;
|
|
|
|
GList *list;
|
|
|
|
GList *reverse_list;
|
|
|
|
gint x1, y1, x2, y2;
|
|
|
|
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 */
|
2006-03-29 01:08:36 +08:00
|
|
|
if ((layer = gimp_image_floating_sel (proj->image)))
|
2001-11-28 11:08:03 +08:00
|
|
|
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
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
for (list = GIMP_LIST (proj->image->layers)->list;
|
2003-09-12 03:52:29 +08:00
|
|
|
list;
|
2001-02-19 21:06:09 +08:00
|
|
|
list = g_list_next (list))
|
1998-06-28 18:39:58 +08:00
|
|
|
{
|
2005-05-31 22:49:01 +08:00
|
|
|
layer = list->data;
|
1999-07-10 02:15:39 +08:00
|
|
|
|
2003-09-12 03:52:29 +08:00
|
|
|
/* only add layers that are visible and not floating selections
|
2001-11-28 11:08:03 +08:00
|
|
|
* to the list
|
|
|
|
*/
|
2003-09-12 03:52:29 +08:00
|
|
|
if (! gimp_layer_is_floating_sel (layer) &&
|
2006-04-12 20:49:29 +08:00
|
|
|
gimp_item_get_visible (GIMP_ITEM (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
|
|
|
{
|
2007-12-24 00:58:41 +08:00
|
|
|
GimpLayerMask *mask;
|
|
|
|
PixelRegion src1PR;
|
|
|
|
PixelRegion src2PR;
|
|
|
|
PixelRegion maskPR;
|
2005-05-31 22:49:01 +08:00
|
|
|
|
|
|
|
layer = list->data;
|
2007-12-24 00:58:41 +08:00
|
|
|
mask = gimp_layer_get_mask (layer);
|
1999-07-10 02:15:39 +08:00
|
|
|
|
2003-05-08 22:06:03 +08:00
|
|
|
gimp_item_offsets (GIMP_ITEM (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);
|
2003-05-08 21:12:46 +08:00
|
|
|
x2 = CLAMP (off_x + gimp_item_width (GIMP_ITEM (layer)), x, x + w);
|
|
|
|
y2 = CLAMP (off_y + gimp_item_height (GIMP_ITEM (layer)), y, y + h);
|
2000-12-28 02:15:37 +08:00
|
|
|
|
2001-11-28 11:08:03 +08:00
|
|
|
/* configure the pixel regions */
|
2004-07-14 00:36:29 +08:00
|
|
|
pixel_region_init (&src1PR, gimp_projection_get_tiles (proj),
|
2006-04-12 20:49:29 +08:00
|
|
|
x1, y1, (x2 - x1), (y2 - y1),
|
|
|
|
TRUE);
|
2001-11-28 11:08:03 +08:00
|
|
|
|
|
|
|
/* If we're showing the layer mask instead of the layer... */
|
2007-12-24 00:58:41 +08:00
|
|
|
if (mask && gimp_layer_mask_get_show (mask))
|
2006-04-12 20:49:29 +08:00
|
|
|
{
|
|
|
|
pixel_region_init (&src2PR,
|
2007-12-24 00:58:41 +08:00
|
|
|
gimp_drawable_get_tiles (GIMP_DRAWABLE (mask)),
|
2007-07-24 04:14:28 +08:00
|
|
|
x1 - off_x, y1 - off_y,
|
|
|
|
x2 - x1, y2 - y1,
|
|
|
|
FALSE);
|
2006-04-12 20:49:29 +08:00
|
|
|
|
|
|
|
copy_gray_to_region (&src2PR, &src1PR);
|
|
|
|
}
|
2001-11-28 11:08:03 +08:00
|
|
|
/* Otherwise, normal */
|
|
|
|
else
|
2006-04-12 20:49:29 +08:00
|
|
|
{
|
2007-12-24 00:58:41 +08:00
|
|
|
PixelRegion *mask_pr = NULL;
|
2005-05-31 22:49:01 +08:00
|
|
|
|
2006-04-12 20:49:29 +08:00
|
|
|
pixel_region_init (&src2PR,
|
|
|
|
gimp_drawable_get_tiles (GIMP_DRAWABLE (layer)),
|
2007-07-24 04:14:28 +08:00
|
|
|
x1 - off_x, y1 - off_y,
|
|
|
|
x2 - x1, y2 - y1,
|
|
|
|
FALSE);
|
2006-04-12 20:49:29 +08:00
|
|
|
|
2007-12-24 00:58:41 +08:00
|
|
|
if (mask && gimp_layer_mask_get_apply (mask))
|
2006-04-12 20:49:29 +08:00
|
|
|
{
|
|
|
|
pixel_region_init (&maskPR,
|
2007-12-24 00:58:41 +08:00
|
|
|
gimp_drawable_get_tiles (GIMP_DRAWABLE (mask)),
|
2007-07-24 04:14:28 +08:00
|
|
|
x1 - off_x, y1 - off_y,
|
|
|
|
x2 - x1, y2 - y1,
|
|
|
|
FALSE);
|
2007-12-24 00:58:41 +08:00
|
|
|
mask_pr = &maskPR;
|
2006-04-12 20:49:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* 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:
|
2005-05-31 22:49:01 +08:00
|
|
|
case GIMP_GRAY_IMAGE:
|
2007-12-24 00:58:41 +08:00
|
|
|
project_intensity (proj, layer, &src2PR, &src1PR, mask_pr);
|
2006-04-12 20:49:29 +08:00
|
|
|
break;
|
2000-12-28 02:15:37 +08:00
|
|
|
|
2006-04-12 20:49:29 +08:00
|
|
|
case GIMP_RGBA_IMAGE:
|
2005-05-31 22:49:01 +08:00
|
|
|
case GIMP_GRAYA_IMAGE:
|
2007-12-24 00:58:41 +08:00
|
|
|
project_intensity_alpha (proj, layer, &src2PR, &src1PR, mask_pr);
|
2006-04-12 20:49:29 +08:00
|
|
|
break;
|
1998-06-28 18:39:58 +08:00
|
|
|
|
2006-04-12 20:49:29 +08:00
|
|
|
case GIMP_INDEXED_IMAGE:
|
2007-12-24 00:58:41 +08:00
|
|
|
project_indexed (proj, layer, &src2PR, &src1PR, mask_pr);
|
2006-04-12 20:49:29 +08:00
|
|
|
break;
|
1998-06-28 18:39:58 +08:00
|
|
|
|
2006-04-12 20:49:29 +08:00
|
|
|
case GIMP_INDEXEDA_IMAGE:
|
2007-12-24 00:58:41 +08:00
|
|
|
project_indexed_alpha (proj, layer, &src2PR, &src1PR, mask_pr);
|
2006-04-12 20:49:29 +08:00
|
|
|
break;
|
1998-06-28 18:39:58 +08:00
|
|
|
|
2006-04-12 20:49:29 +08:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2001-05-07 01:56:10 +08:00
|
|
|
|
2004-07-14 00:36:29 +08:00
|
|
|
proj->construct_flag = TRUE; /* something was projected */
|
2001-11-28 11:08:03 +08:00
|
|
|
}
|
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
|
2004-07-14 00:36:29 +08:00
|
|
|
gimp_projection_construct_channels (GimpProjection *proj,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint w,
|
|
|
|
gint h)
|
1998-06-28 18:39:58 +08:00
|
|
|
{
|
2005-05-31 22:49:01 +08:00
|
|
|
GList *list;
|
|
|
|
GList *reverse_list = NULL;
|
2000-02-27 02:46:08 +08:00
|
|
|
|
2001-11-28 11:08:03 +08:00
|
|
|
/* reverse the channel list */
|
2006-03-29 01:08:36 +08:00
|
|
|
for (list = GIMP_LIST (proj->image->channels)->list;
|
2003-09-12 03:52:29 +08:00
|
|
|
list;
|
2001-02-19 21:06:09 +08:00
|
|
|
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
|
|
|
{
|
2005-05-31 22:49:01 +08:00
|
|
|
GimpChannel *channel = list->data;
|
2001-01-29 07:25:25 +08:00
|
|
|
|
2003-09-12 03:52:29 +08:00
|
|
|
if (gimp_item_get_visible (GIMP_ITEM (channel)))
|
2006-04-12 20:49:29 +08:00
|
|
|
{
|
2005-05-31 22:49:01 +08:00
|
|
|
PixelRegion src1PR;
|
|
|
|
PixelRegion src2PR;
|
|
|
|
|
2006-04-12 20:49:29 +08:00
|
|
|
/* configure the pixel regions */
|
|
|
|
pixel_region_init (&src1PR,
|
|
|
|
gimp_projection_get_tiles (proj),
|
|
|
|
x, y, w, h,
|
|
|
|
TRUE);
|
|
|
|
pixel_region_init (&src2PR,
|
|
|
|
gimp_drawable_get_tiles (GIMP_DRAWABLE (channel)),
|
|
|
|
x, y, w, h,
|
|
|
|
FALSE);
|
1998-06-28 18:39:58 +08:00
|
|
|
|
2006-04-12 20:49:29 +08:00
|
|
|
project_channel (proj, channel, &src1PR, &src2PR);
|
1999-01-18 04:41:38 +08:00
|
|
|
|
2006-04-12 20:49:29 +08:00
|
|
|
proj->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
|
|
|
}
|
|
|
|
|
2007-06-22 18:11:36 +08:00
|
|
|
/**
|
|
|
|
* gimp_projection_initialize:
|
|
|
|
* @proj: A #GimpProjection.
|
|
|
|
* @x:
|
|
|
|
* @y:
|
|
|
|
* @w:
|
|
|
|
* @h:
|
|
|
|
*
|
|
|
|
* This function determines whether a visible layer with combine mode Normal
|
|
|
|
* provides complete coverage over the specified area. If not, the projection
|
|
|
|
* is initialized to transparent black.
|
|
|
|
*/
|
2001-11-28 11:08:03 +08:00
|
|
|
static void
|
2004-07-14 00:36:29 +08:00
|
|
|
gimp_projection_initialize (GimpProjection *proj,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint w,
|
|
|
|
gint h)
|
2001-06-05 07:11:31 +08:00
|
|
|
{
|
|
|
|
|
2004-07-14 00:36:29 +08:00
|
|
|
GList *list;
|
|
|
|
gboolean coverage = FALSE;
|
2001-06-05 07:11:31 +08:00
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
for (list = GIMP_LIST (proj->image->layers)->list;
|
2003-09-12 03:52:29 +08:00
|
|
|
list;
|
2001-06-05 07:11:31 +08:00
|
|
|
list = g_list_next (list))
|
|
|
|
{
|
2004-07-14 00:36:29 +08:00
|
|
|
GimpItem *item = list->data;
|
2003-05-08 22:06:03 +08:00
|
|
|
gint off_x, off_y;
|
2001-06-05 07:11:31 +08:00
|
|
|
|
2003-05-08 22:06:03 +08:00
|
|
|
gimp_item_offsets (item, &off_x, &off_y);
|
|
|
|
|
2007-06-22 18:11:36 +08:00
|
|
|
if (gimp_item_get_visible (item) &&
|
|
|
|
! gimp_drawable_has_alpha (GIMP_DRAWABLE (item)) &&
|
|
|
|
gimp_layer_get_mode (GIMP_LAYER (item)) == GIMP_NORMAL_MODE &&
|
|
|
|
(off_x <= x) &&
|
|
|
|
(off_y <= y) &&
|
|
|
|
(off_x + gimp_item_width (item) >= x + w) &&
|
2006-04-12 20:49:29 +08:00
|
|
|
(off_y + gimp_item_height (item) >= y + h))
|
|
|
|
{
|
|
|
|
coverage = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
2001-06-05 07:11:31 +08:00
|
|
|
}
|
|
|
|
|
2007-07-24 04:14:28 +08:00
|
|
|
if (! coverage)
|
2001-08-11 22:39:19 +08:00
|
|
|
{
|
2004-07-14 00:36:29 +08:00
|
|
|
PixelRegion PR;
|
|
|
|
guchar clear[4] = { 0, 0, 0, 0 };
|
|
|
|
|
|
|
|
pixel_region_init (&PR, gimp_projection_get_tiles (proj),
|
2006-04-12 20:49:29 +08:00
|
|
|
x, y, w, h, TRUE);
|
2001-11-28 11:08:03 +08:00
|
|
|
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
|
2004-07-14 00:36:29 +08:00
|
|
|
project_intensity (GimpProjection *proj,
|
2006-04-12 20:49:29 +08:00
|
|
|
GimpLayer *layer,
|
|
|
|
PixelRegion *src,
|
|
|
|
PixelRegion *dest,
|
|
|
|
PixelRegion *mask)
|
2001-11-28 11:08:03 +08:00
|
|
|
{
|
2007-12-17 18:45:05 +08:00
|
|
|
if (proj->construct_flag)
|
|
|
|
{
|
|
|
|
combine_regions (dest, src, dest, mask, NULL,
|
2007-12-24 00:58:41 +08:00
|
|
|
gimp_layer_get_opacity (layer) * 255.999,
|
|
|
|
gimp_layer_get_mode (layer),
|
2007-12-17 18:45:05 +08:00
|
|
|
proj->image->visible,
|
|
|
|
COMBINE_INTEN_A_INTEN);
|
|
|
|
}
|
1998-06-28 18:39:58 +08:00
|
|
|
else
|
2007-12-17 18:45:05 +08:00
|
|
|
{
|
|
|
|
initial_region (src, dest, mask, NULL,
|
2007-12-24 00:58:41 +08:00
|
|
|
gimp_layer_get_opacity (layer) * 255.999,
|
|
|
|
gimp_layer_get_mode (layer),
|
2007-12-17 18:45:05 +08:00
|
|
|
proj->image->visible,
|
|
|
|
INITIAL_INTENSITY);
|
|
|
|
}
|
1998-06-28 18:39:58 +08:00
|
|
|
}
|
|
|
|
|
2001-11-28 11:08:03 +08:00
|
|
|
static void
|
2004-07-14 00:36:29 +08:00
|
|
|
project_intensity_alpha (GimpProjection *proj,
|
2006-04-12 20:49:29 +08:00
|
|
|
GimpLayer *layer,
|
|
|
|
PixelRegion *src,
|
|
|
|
PixelRegion *dest,
|
|
|
|
PixelRegion *mask)
|
2001-11-28 11:08:03 +08:00
|
|
|
{
|
2007-07-24 04:14:28 +08:00
|
|
|
if (proj->construct_flag)
|
|
|
|
{
|
|
|
|
combine_regions (dest, src, dest, mask, NULL,
|
2007-12-24 00:58:41 +08:00
|
|
|
gimp_layer_get_opacity (layer) * 255.999,
|
|
|
|
gimp_layer_get_mode (layer),
|
2007-07-24 04:14:28 +08:00
|
|
|
proj->image->visible,
|
|
|
|
COMBINE_INTEN_A_INTEN_A);
|
|
|
|
}
|
2001-11-28 11:08:03 +08:00
|
|
|
else
|
2007-07-24 04:14:28 +08:00
|
|
|
{
|
|
|
|
initial_region (src, dest, mask, NULL,
|
2007-12-24 00:58:41 +08:00
|
|
|
gimp_layer_get_opacity (layer) * 255.999,
|
|
|
|
gimp_layer_get_mode (layer),
|
2007-07-24 04:14:28 +08:00
|
|
|
proj->image->visible,
|
|
|
|
INITIAL_INTENSITY_ALPHA);
|
|
|
|
}
|
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
|
2004-07-14 00:36:29 +08:00
|
|
|
project_indexed (GimpProjection *proj,
|
2006-04-12 20:49:29 +08:00
|
|
|
GimpLayer *layer,
|
|
|
|
PixelRegion *src,
|
2006-05-24 03:18:00 +08:00
|
|
|
PixelRegion *dest,
|
|
|
|
PixelRegion *mask)
|
1998-06-28 18:39:58 +08:00
|
|
|
{
|
2007-12-26 00:21:40 +08:00
|
|
|
const guchar *colormap = gimp_image_get_colormap (proj->image);
|
|
|
|
|
|
|
|
g_return_if_fail (colormap != NULL);
|
2004-05-07 04:18:53 +08:00
|
|
|
|
2007-07-24 04:14:28 +08:00
|
|
|
if (proj->construct_flag)
|
|
|
|
{
|
2007-12-26 00:21:40 +08:00
|
|
|
combine_regions (dest, src, dest, mask, colormap,
|
2007-12-24 00:58:41 +08:00
|
|
|
gimp_layer_get_opacity (layer) * 255.999,
|
|
|
|
gimp_layer_get_mode (layer),
|
2007-07-24 04:14:28 +08:00
|
|
|
proj->image->visible,
|
|
|
|
COMBINE_INTEN_A_INDEXED);
|
|
|
|
}
|
2001-11-28 11:08:03 +08:00
|
|
|
else
|
2007-07-24 04:14:28 +08:00
|
|
|
{
|
2007-12-26 00:21:40 +08:00
|
|
|
initial_region (src, dest, mask, colormap,
|
2007-12-24 00:58:41 +08:00
|
|
|
gimp_layer_get_opacity (layer) * 255.999,
|
|
|
|
gimp_layer_get_mode (layer),
|
2007-07-24 04:14:28 +08:00
|
|
|
proj->image->visible,
|
|
|
|
INITIAL_INDEXED);
|
|
|
|
}
|
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
|
2004-07-14 00:36:29 +08:00
|
|
|
project_indexed_alpha (GimpProjection *proj,
|
2006-04-12 20:49:29 +08:00
|
|
|
GimpLayer *layer,
|
|
|
|
PixelRegion *src,
|
|
|
|
PixelRegion *dest,
|
|
|
|
PixelRegion *mask)
|
2001-11-28 11:08:03 +08:00
|
|
|
{
|
2007-12-26 00:21:40 +08:00
|
|
|
const guchar *colormap = gimp_image_get_colormap (proj->image);
|
|
|
|
|
|
|
|
g_return_if_fail (colormap != NULL);
|
2004-05-07 04:18:53 +08:00
|
|
|
|
2007-07-24 04:14:28 +08:00
|
|
|
if (proj->construct_flag)
|
|
|
|
{
|
2007-12-26 00:21:40 +08:00
|
|
|
combine_regions (dest, src, dest, mask, colormap,
|
2007-12-24 00:58:41 +08:00
|
|
|
gimp_layer_get_opacity (layer) * 255.999,
|
|
|
|
gimp_layer_get_mode (layer),
|
2007-07-24 04:14:28 +08:00
|
|
|
proj->image->visible,
|
|
|
|
COMBINE_INTEN_A_INDEXED_A);
|
|
|
|
}
|
2001-11-28 11:08:03 +08:00
|
|
|
else
|
2007-07-24 04:14:28 +08:00
|
|
|
{
|
2007-12-26 00:21:40 +08:00
|
|
|
initial_region (src, dest, mask, colormap,
|
2007-12-24 00:58:41 +08:00
|
|
|
gimp_layer_get_opacity (layer) * 255.999,
|
|
|
|
gimp_layer_get_mode (layer),
|
2007-07-24 04:14:28 +08:00
|
|
|
proj->image->visible,
|
|
|
|
INITIAL_INDEXED_ALPHA);
|
|
|
|
}
|
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
|
2004-07-14 00:36:29 +08:00
|
|
|
project_channel (GimpProjection *proj,
|
2006-04-12 20:49:29 +08:00
|
|
|
GimpChannel *channel,
|
|
|
|
PixelRegion *src,
|
|
|
|
PixelRegion *src2)
|
2001-11-28 11:08:03 +08:00
|
|
|
{
|
2007-07-24 04:14:28 +08:00
|
|
|
guchar col[3];
|
|
|
|
guchar opacity;
|
1998-06-28 18:39:58 +08:00
|
|
|
|
2001-11-28 11:08:03 +08:00
|
|
|
gimp_rgba_get_uchar (&channel->color,
|
2006-04-12 20:49:29 +08:00
|
|
|
&col[0], &col[1], &col[2], &opacity);
|
1998-06-28 18:39:58 +08:00
|
|
|
|
2007-07-24 04:14:28 +08:00
|
|
|
if (proj->construct_flag)
|
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,
|
2007-12-24 00:58:41 +08:00
|
|
|
(gimp_channel_get_show_masked (channel) ?
|
2007-07-24 04:14:28 +08:00
|
|
|
COMBINE_INTEN_A_CHANNEL_MASK :
|
|
|
|
COMBINE_INTEN_A_CHANNEL_SELECTION));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
initial_region (src2, src, NULL, col,
|
|
|
|
opacity,
|
|
|
|
GIMP_NORMAL_MODE,
|
|
|
|
NULL,
|
2007-12-24 00:58:41 +08:00
|
|
|
(gimp_channel_get_show_masked (channel) ?
|
2007-07-24 04:14:28 +08:00
|
|
|
INITIAL_CHANNEL_MASK :
|
|
|
|
INITIAL_CHANNEL_SELECTION));
|
1998-06-28 18:39:58 +08:00
|
|
|
}
|
|
|
|
}
|