app: implement gimp_channel_translate() with GEGL
This commit is contained in:
@ -513,8 +513,10 @@ gimp_channel_translate (GimpItem *item,
|
|||||||
{
|
{
|
||||||
GimpChannel *channel = GIMP_CHANNEL (item);
|
GimpChannel *channel = GIMP_CHANNEL (item);
|
||||||
GimpChannel *tmp_mask = NULL;
|
GimpChannel *tmp_mask = NULL;
|
||||||
|
GeglBuffer *tmp_buffer = NULL;
|
||||||
gint width, height;
|
gint width, height;
|
||||||
PixelRegion srcPR, destPR;
|
GeglRectangle src_rect;
|
||||||
|
GeglRectangle dest_rect;
|
||||||
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);
|
||||||
@ -543,34 +545,36 @@ gimp_channel_translate (GimpItem *item,
|
|||||||
*/
|
*/
|
||||||
tmp_mask = gimp_channel_new_mask (gimp_item_get_image (item),
|
tmp_mask = gimp_channel_new_mask (gimp_item_get_image (item),
|
||||||
width, height);
|
width, height);
|
||||||
|
tmp_buffer = gimp_drawable_get_write_buffer (GIMP_DRAWABLE (tmp_mask));
|
||||||
|
|
||||||
pixel_region_init (&srcPR,
|
src_rect.x = x1 - off_x;
|
||||||
gimp_drawable_get_tiles (GIMP_DRAWABLE (channel)),
|
src_rect.y = y1 - off_y;
|
||||||
x1 - off_x, y1 - off_y, width, height, FALSE);
|
src_rect.width = width;
|
||||||
pixel_region_init (&destPR,
|
src_rect.height = height;
|
||||||
gimp_drawable_get_tiles (GIMP_DRAWABLE (tmp_mask)),
|
|
||||||
0, 0, width, height, TRUE);
|
dest_rect.x = 0;
|
||||||
copy_region (&srcPR, &destPR);
|
dest_rect.y = 0;
|
||||||
|
|
||||||
|
gegl_buffer_copy (gimp_drawable_get_read_buffer (GIMP_DRAWABLE (channel)),
|
||||||
|
&src_rect,
|
||||||
|
tmp_buffer,
|
||||||
|
&dest_rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* clear the mask */
|
/* clear the mask */
|
||||||
pixel_region_init (&srcPR,
|
gegl_buffer_clear (gimp_drawable_get_write_buffer (GIMP_DRAWABLE (channel)),
|
||||||
gimp_drawable_get_tiles (GIMP_DRAWABLE (channel)),
|
NULL);
|
||||||
0, 0,
|
|
||||||
gimp_item_get_width (GIMP_ITEM (channel)),
|
|
||||||
gimp_item_get_height (GIMP_ITEM (channel)), TRUE);
|
|
||||||
clear_region (&srcPR);
|
|
||||||
|
|
||||||
if (width != 0 && height != 0)
|
if (width != 0 && height != 0)
|
||||||
{
|
{
|
||||||
/* copy the temp mask back to the mask */
|
/* copy the temp mask back to the mask */
|
||||||
pixel_region_init (&srcPR,
|
dest_rect.x = x1;
|
||||||
gimp_drawable_get_tiles (GIMP_DRAWABLE (tmp_mask)),
|
dest_rect.y = y1;
|
||||||
0, 0, width, height, FALSE);
|
|
||||||
pixel_region_init (&destPR,
|
gegl_buffer_copy (tmp_buffer,
|
||||||
gimp_drawable_get_tiles (GIMP_DRAWABLE (channel)),
|
NULL,
|
||||||
x1, y1, width, height, TRUE);
|
gimp_drawable_get_write_buffer (GIMP_DRAWABLE (channel)),
|
||||||
copy_region (&srcPR, &destPR);
|
&dest_rect);
|
||||||
|
|
||||||
/* free the temporary mask */
|
/* free the temporary mask */
|
||||||
g_object_unref (tmp_mask);
|
g_object_unref (tmp_mask);
|
||||||
|
Reference in New Issue
Block a user