added clear_region().
2008-09-01 Sven Neumann <sven@gimp.org> * app/paint-funcs/paint-funcs.[ch]: added clear_region(). * app/base/tile-manager-crop.c * app/core/gimpchannel.c * app/core/gimpimage-merge.c * app/core/gimpmaskundo.c * app/core/gimpprojection-construct.c: use it instead of calling color_region() with a zero color. svn path=/trunk/; revision=26826
This commit is contained in:

committed by
Sven Neumann

parent
88955a3118
commit
a5f8345609
11
ChangeLog
11
ChangeLog
@ -1,3 +1,14 @@
|
|||||||
|
2008-09-01 Sven Neumann <sven@gimp.org>
|
||||||
|
|
||||||
|
* app/paint-funcs/paint-funcs.[ch]: added clear_region().
|
||||||
|
|
||||||
|
* app/base/tile-manager-crop.c
|
||||||
|
* app/core/gimpchannel.c
|
||||||
|
* app/core/gimpimage-merge.c
|
||||||
|
* app/core/gimpmaskundo.c
|
||||||
|
* app/core/gimpprojection-construct.c: use it instead of calling
|
||||||
|
color_region() with a zero color.
|
||||||
|
|
||||||
2008-09-01 Sven Neumann <sven@gimp.org>
|
2008-09-01 Sven Neumann <sven@gimp.org>
|
||||||
|
|
||||||
* app/core/gimpprojection-construct.c (gimp_projection_initialize):
|
* app/core/gimpprojection-construct.c (gimp_projection_initialize):
|
||||||
|
@ -35,14 +35,13 @@ TileManager *
|
|||||||
tile_manager_crop (TileManager *tiles,
|
tile_manager_crop (TileManager *tiles,
|
||||||
gint border)
|
gint border)
|
||||||
{
|
{
|
||||||
PixelRegion PR;
|
PixelRegion region;
|
||||||
TileManager *new_tiles;
|
TileManager *new_tiles;
|
||||||
gint bytes, alpha;
|
gint bytes, alpha;
|
||||||
gint x1, y1, x2, y2;
|
gint x1, y1, x2, y2;
|
||||||
gboolean found;
|
gboolean found;
|
||||||
gboolean empty;
|
gboolean empty;
|
||||||
gpointer pr;
|
gpointer pr;
|
||||||
const guchar black[MAX_CHANNELS] = { 0, 0, 0, 0 };
|
|
||||||
|
|
||||||
g_return_val_if_fail (tiles != NULL, NULL);
|
g_return_val_if_fail (tiles != NULL, NULL);
|
||||||
|
|
||||||
@ -55,22 +54,22 @@ tile_manager_crop (TileManager *tiles,
|
|||||||
x2 = 0;
|
x2 = 0;
|
||||||
y2 = 0;
|
y2 = 0;
|
||||||
|
|
||||||
pixel_region_init (&PR, tiles, 0, 0, x1, y1, FALSE);
|
pixel_region_init (®ion, tiles, 0, 0, x1, y1, FALSE);
|
||||||
|
|
||||||
for (pr = pixel_regions_register (1, &PR);
|
for (pr = pixel_regions_register (1, ®ion);
|
||||||
pr != NULL;
|
pr != NULL;
|
||||||
pr = pixel_regions_process (pr))
|
pr = pixel_regions_process (pr))
|
||||||
{
|
{
|
||||||
const guchar *data = PR.data + alpha;
|
const guchar *data = region.data + alpha;
|
||||||
gint ex = PR.x + PR.w;
|
gint ex = region.x + region.w;
|
||||||
gint ey = PR.y + PR.h;
|
gint ey = region.y + region.h;
|
||||||
gint x, y;
|
gint x, y;
|
||||||
|
|
||||||
for (y = PR.y; y < ey; y++)
|
for (y = region.y; y < ey; y++)
|
||||||
{
|
{
|
||||||
found = FALSE;
|
found = FALSE;
|
||||||
|
|
||||||
for (x = PR.x; x < ex; x++, data += bytes)
|
for (x = region.x; x < ex; x++, data += bytes)
|
||||||
if (*data)
|
if (*data)
|
||||||
{
|
{
|
||||||
if (x < x1)
|
if (x < x1)
|
||||||
@ -129,22 +128,22 @@ tile_manager_crop (TileManager *tiles,
|
|||||||
pixel_region_init (&destPR, new_tiles,
|
pixel_region_init (&destPR, new_tiles,
|
||||||
0, 0, new_width, border,
|
0, 0, new_width, border,
|
||||||
TRUE);
|
TRUE);
|
||||||
color_region (&destPR, black);
|
clear_region (&destPR);
|
||||||
|
|
||||||
pixel_region_init (&destPR, new_tiles,
|
pixel_region_init (&destPR, new_tiles,
|
||||||
0, border, border, (y2 - y1),
|
0, border, border, (y2 - y1),
|
||||||
TRUE);
|
TRUE);
|
||||||
color_region (&destPR, black);
|
clear_region (&destPR);
|
||||||
|
|
||||||
pixel_region_init (&destPR, new_tiles,
|
pixel_region_init (&destPR, new_tiles,
|
||||||
new_width - border, border, border, (y2 - y1),
|
new_width - border, border, border, (y2 - y1),
|
||||||
TRUE);
|
TRUE);
|
||||||
color_region (&destPR, black);
|
clear_region (&destPR);
|
||||||
|
|
||||||
pixel_region_init (&destPR, new_tiles,
|
pixel_region_init (&destPR, new_tiles,
|
||||||
0, new_height - border, new_width, border,
|
0, new_height - border, new_width, border,
|
||||||
TRUE);
|
TRUE);
|
||||||
color_region (&destPR, black);
|
clear_region (&destPR);
|
||||||
}
|
}
|
||||||
|
|
||||||
pixel_region_init (&srcPR, tiles,
|
pixel_region_init (&srcPR, tiles,
|
||||||
|
@ -494,7 +494,6 @@ gimp_channel_translate (GimpItem *item,
|
|||||||
GimpChannel *tmp_mask = NULL;
|
GimpChannel *tmp_mask = NULL;
|
||||||
gint width, height;
|
gint width, height;
|
||||||
PixelRegion srcPR, destPR;
|
PixelRegion srcPR, destPR;
|
||||||
guchar empty = TRANSPARENT_OPACITY;
|
|
||||||
gint x1, y1, x2, y2;
|
gint x1, y1, x2, y2;
|
||||||
|
|
||||||
gimp_channel_bounds (channel, &x1, &y1, &x2, &y2);
|
gimp_channel_bounds (channel, &x1, &y1, &x2, &y2);
|
||||||
@ -539,7 +538,7 @@ gimp_channel_translate (GimpItem *item,
|
|||||||
0, 0,
|
0, 0,
|
||||||
gimp_item_width (GIMP_ITEM (channel)),
|
gimp_item_width (GIMP_ITEM (channel)),
|
||||||
gimp_item_height (GIMP_ITEM (channel)), TRUE);
|
gimp_item_height (GIMP_ITEM (channel)), TRUE);
|
||||||
color_region (&srcPR, &empty);
|
clear_region (&srcPR);
|
||||||
|
|
||||||
if (width != 0 && height != 0)
|
if (width != 0 && height != 0)
|
||||||
{
|
{
|
||||||
@ -1195,7 +1194,6 @@ gimp_channel_real_clear (GimpChannel *channel,
|
|||||||
gboolean push_undo)
|
gboolean push_undo)
|
||||||
{
|
{
|
||||||
PixelRegion maskPR;
|
PixelRegion maskPR;
|
||||||
guchar bg = TRANSPARENT_OPACITY;
|
|
||||||
|
|
||||||
if (push_undo)
|
if (push_undo)
|
||||||
{
|
{
|
||||||
@ -1216,7 +1214,7 @@ gimp_channel_real_clear (GimpChannel *channel,
|
|||||||
channel->x1, channel->y1,
|
channel->x1, channel->y1,
|
||||||
channel->x2 - channel->x1,
|
channel->x2 - channel->x1,
|
||||||
channel->y2 - channel->y1, TRUE);
|
channel->y2 - channel->y1, TRUE);
|
||||||
color_region (&maskPR, &bg);
|
clear_region (&maskPR);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1226,7 +1224,7 @@ gimp_channel_real_clear (GimpChannel *channel,
|
|||||||
0, 0,
|
0, 0,
|
||||||
gimp_item_width (GIMP_ITEM (channel)),
|
gimp_item_width (GIMP_ITEM (channel)),
|
||||||
gimp_item_height (GIMP_ITEM (channel)), TRUE);
|
gimp_item_height (GIMP_ITEM (channel)), TRUE);
|
||||||
color_region (&maskPR, &bg);
|
clear_region (&maskPR);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* we know the bounds */
|
/* we know the bounds */
|
||||||
@ -1247,7 +1245,6 @@ gimp_channel_real_all (GimpChannel *channel,
|
|||||||
gboolean push_undo)
|
gboolean push_undo)
|
||||||
{
|
{
|
||||||
PixelRegion maskPR;
|
PixelRegion maskPR;
|
||||||
guchar bg = OPAQUE_OPACITY;
|
|
||||||
|
|
||||||
if (push_undo)
|
if (push_undo)
|
||||||
gimp_channel_push_undo (channel,
|
gimp_channel_push_undo (channel,
|
||||||
@ -1261,7 +1258,7 @@ gimp_channel_real_all (GimpChannel *channel,
|
|||||||
0, 0,
|
0, 0,
|
||||||
gimp_item_width (GIMP_ITEM (channel)),
|
gimp_item_width (GIMP_ITEM (channel)),
|
||||||
gimp_item_height (GIMP_ITEM (channel)), TRUE);
|
gimp_item_height (GIMP_ITEM (channel)), TRUE);
|
||||||
color_region (&maskPR, &bg);
|
clear_region (&maskPR);
|
||||||
|
|
||||||
/* we know the bounds */
|
/* we know the bounds */
|
||||||
channel->bounds_known = TRUE;
|
channel->bounds_known = TRUE;
|
||||||
|
@ -319,7 +319,6 @@ gimp_image_merge_layers (GimpImage *image,
|
|||||||
GimpLayer *merge_layer;
|
GimpLayer *merge_layer;
|
||||||
GimpLayer *layer;
|
GimpLayer *layer;
|
||||||
GimpLayer *bottom_layer;
|
GimpLayer *bottom_layer;
|
||||||
guchar bg[4] = {0, 0, 0, 0};
|
|
||||||
GimpImageType type;
|
GimpImageType type;
|
||||||
gint count;
|
gint count;
|
||||||
gint x1, y1, x2, y2;
|
gint x1, y1, x2, y2;
|
||||||
@ -418,6 +417,8 @@ gimp_image_merge_layers (GimpImage *image,
|
|||||||
if (merge_type == GIMP_FLATTEN_IMAGE ||
|
if (merge_type == GIMP_FLATTEN_IMAGE ||
|
||||||
gimp_drawable_type (GIMP_DRAWABLE (layer)) == GIMP_INDEXED_IMAGE)
|
gimp_drawable_type (GIMP_DRAWABLE (layer)) == GIMP_INDEXED_IMAGE)
|
||||||
{
|
{
|
||||||
|
guchar bg[4] = { 0, 0, 0, 0 };
|
||||||
|
|
||||||
type = GIMP_IMAGE_TYPE_FROM_BASE_TYPE (gimp_image_base_type (image));
|
type = GIMP_IMAGE_TYPE_FROM_BASE_TYPE (gimp_image_base_type (image));
|
||||||
|
|
||||||
merge_layer = gimp_layer_new (image, (x2 - x1), (y2 - y1),
|
merge_layer = gimp_layer_new (image, (x2 - x1), (y2 - y1),
|
||||||
@ -471,15 +472,13 @@ gimp_image_merge_layers (GimpImage *image,
|
|||||||
GIMP_ITEM (merge_layer)->offset_x = x1;
|
GIMP_ITEM (merge_layer)->offset_x = x1;
|
||||||
GIMP_ITEM (merge_layer)->offset_y = y1;
|
GIMP_ITEM (merge_layer)->offset_y = y1;
|
||||||
|
|
||||||
/* Set the layer to transparent */
|
/* clear the layer */
|
||||||
pixel_region_init (&src1PR,
|
pixel_region_init (&src1PR,
|
||||||
gimp_drawable_get_tiles (GIMP_DRAWABLE (merge_layer)),
|
gimp_drawable_get_tiles (GIMP_DRAWABLE (merge_layer)),
|
||||||
0, 0,
|
0, 0,
|
||||||
(x2 - x1), (y2 - y1),
|
(x2 - x1), (y2 - y1),
|
||||||
TRUE);
|
TRUE);
|
||||||
|
clear_region (&src1PR);
|
||||||
/* set the region to 0's */
|
|
||||||
color_region (&src1PR, bg);
|
|
||||||
|
|
||||||
/* Find the index in the layer list of the bottom layer--we need this
|
/* Find the index in the layer list of the bottom layer--we need this
|
||||||
* in order to add the final, merged layer to the layer list correctly
|
* in order to add the final, merged layer to the layer list correctly
|
||||||
|
@ -139,8 +139,6 @@ gimp_mask_undo_pop (GimpUndo *undo,
|
|||||||
|
|
||||||
if (gimp_channel_bounds (channel, &x1, &y1, &x2, &y2))
|
if (gimp_channel_bounds (channel, &x1, &y1, &x2, &y2))
|
||||||
{
|
{
|
||||||
guchar empty = 0;
|
|
||||||
|
|
||||||
new_tiles = tile_manager_new (x2 - x1, y2 - y1, 1);
|
new_tiles = tile_manager_new (x2 - x1, y2 - y1, 1);
|
||||||
|
|
||||||
pixel_region_init (&srcPR,
|
pixel_region_init (&srcPR,
|
||||||
@ -155,7 +153,7 @@ gimp_mask_undo_pop (GimpUndo *undo,
|
|||||||
gimp_drawable_get_tiles (GIMP_DRAWABLE (channel)),
|
gimp_drawable_get_tiles (GIMP_DRAWABLE (channel)),
|
||||||
x1, y1, x2 - x1, y2 - y1, TRUE);
|
x1, y1, x2 - x1, y2 - y1, TRUE);
|
||||||
|
|
||||||
color_region (&srcPR, &empty);
|
clear_region (&srcPR);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -377,12 +377,11 @@ gimp_projection_initialize (GimpProjection *proj,
|
|||||||
|
|
||||||
if (! coverage)
|
if (! coverage)
|
||||||
{
|
{
|
||||||
PixelRegion PR;
|
PixelRegion region;
|
||||||
guchar clear[4] = { 0, 0, 0, 0 };
|
|
||||||
|
|
||||||
pixel_region_init (&PR, gimp_projection_get_tiles (proj),
|
pixel_region_init (®ion,
|
||||||
x, y, w, h, TRUE);
|
gimp_projection_get_tiles (proj), x, y, w, h, TRUE);
|
||||||
color_region (&PR, clear);
|
clear_region (®ion);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1885,6 +1885,35 @@ extract_from_indexed_pixels (guchar *src,
|
|||||||
/* REGION FUNCTIONS */
|
/* REGION FUNCTIONS */
|
||||||
/**************************************************/
|
/**************************************************/
|
||||||
|
|
||||||
|
void
|
||||||
|
clear_region (PixelRegion *dest)
|
||||||
|
{
|
||||||
|
gpointer pr;
|
||||||
|
|
||||||
|
for (pr = pixel_regions_register (1, dest);
|
||||||
|
pr != NULL;
|
||||||
|
pr = pixel_regions_process (pr))
|
||||||
|
{
|
||||||
|
if (dest->w * dest->bytes == dest->rowstride)
|
||||||
|
{
|
||||||
|
memset (dest->data, 0, dest->w * dest->h * dest->bytes);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
guchar *d = dest->data;
|
||||||
|
gint h = dest->h;
|
||||||
|
|
||||||
|
while (h--)
|
||||||
|
{
|
||||||
|
memset (d, 0, dest->w * dest->bytes);
|
||||||
|
|
||||||
|
d += dest->rowstride;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
color_region (PixelRegion *dest,
|
color_region (PixelRegion *dest,
|
||||||
const guchar *col)
|
const guchar *col)
|
||||||
|
@ -339,6 +339,9 @@ void extract_from_indexed_pixels (guchar *src,
|
|||||||
|
|
||||||
|
|
||||||
/* Region functions */
|
/* Region functions */
|
||||||
|
|
||||||
|
void clear_region (PixelRegion *dest);
|
||||||
|
|
||||||
void color_region (PixelRegion *dest,
|
void color_region (PixelRegion *dest,
|
||||||
const guchar *color);
|
const guchar *color);
|
||||||
void color_region_mask (PixelRegion *dest,
|
void color_region_mask (PixelRegion *dest,
|
||||||
|
Reference in New Issue
Block a user