? app/core/stLZLpd7 Index: app/core/gimp-edit.c =================================================================== RCS file: /cvs/gnome/gimp/app/core/gimp-edit.c,v retrieving revision 1.122 diff -u -p -r1.122 gimp-edit.c --- app/core/gimp-edit.c 12 Oct 2004 21:28:52 -0000 1.122 +++ app/core/gimp-edit.c 19 Oct 2004 15:30:45 -0000 @@ -130,10 +130,6 @@ gimp_edit_paste (GimpImage *gimage, if (! layer) return NULL; - /* Start a group undo */ - gimp_image_undo_group_start (gimage, GIMP_UNDO_GROUP_EDIT_PASTE, - _("Paste")); - if (drawable) { /* if pasting to a drawable */ @@ -198,6 +194,10 @@ gimp_edit_paste (GimpImage *gimage, GIMP_ITEM (layer)->offset_x = offset_x; GIMP_ITEM (layer)->offset_y = offset_y; + /* Start a group undo */ + gimp_image_undo_group_start (gimage, GIMP_UNDO_GROUP_EDIT_PASTE, + _("Paste")); + /* If there is a selection mask clear it-- * this might not always be desired, but in general, * it seems like the correct behavior. @@ -388,15 +388,13 @@ gimp_edit_fill_internal (GimpImage *g { TileManager *buf_tiles; PixelRegion bufPR; - gint x1, y1, x2, y2; + gint x, y, width, height; gint tiles_bytes; guchar col[MAX_CHANNELS]; TempBuf *pat_buf = NULL; gboolean new_buf; - gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2); - - if (x1 == x2 || y1 == y2) + if (! gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height)) return TRUE; /* nothing to do, but the fill succeded */ tiles_bytes = gimp_drawable_bytes (drawable); @@ -440,9 +438,9 @@ gimp_edit_fill_internal (GimpImage *g return TRUE; /* nothing to do, but the fill succeded */ } - buf_tiles = tile_manager_new (x2 - x1, y2 - y1, tiles_bytes); + buf_tiles = tile_manager_new (width, height, tiles_bytes); - pixel_region_init (&bufPR, buf_tiles, 0, 0, x2 - x1, y2 - y1, TRUE); + pixel_region_init (&bufPR, buf_tiles, 0, 0, width, height, TRUE); if (pat_buf) { @@ -459,17 +457,17 @@ gimp_edit_fill_internal (GimpImage *g color_region (&bufPR, col); } - pixel_region_init (&bufPR, buf_tiles, 0, 0, x2 - x1, y2 - y1, FALSE); + pixel_region_init (&bufPR, buf_tiles, 0, 0, width, height, FALSE); gimp_drawable_apply_region (drawable, &bufPR, TRUE, undo_desc, GIMP_OPACITY_OPAQUE, (fill_type == GIMP_TRANSPARENT_FILL) ? GIMP_ERASE_MODE : GIMP_NORMAL_MODE, - NULL, x1, y1); + NULL, x, y); tile_manager_unref (buf_tiles); - gimp_drawable_update (drawable, x1, y1, x2 - x1, y2 - y1); + gimp_drawable_update (drawable, x, y, width, height); return TRUE; } Index: app/core/gimpdrawable-blend.c =================================================================== RCS file: /cvs/gnome/gimp/app/core/gimpdrawable-blend.c,v retrieving revision 1.149 diff -u -p -r1.149 gimpdrawable-blend.c --- app/core/gimpdrawable-blend.c 11 Aug 2004 00:34:34 -0000 1.149 +++ app/core/gimpdrawable-blend.c 19 Oct 2004 15:30:46 -0000 @@ -191,7 +191,7 @@ gimp_drawable_blend (GimpDrawable TileManager *buf_tiles; PixelRegion bufPR; gint bytes; - gint x1, y1, x2, y2; + gint x, y, width, height; g_return_if_fail (GIMP_IS_DRAWABLE (drawable)); g_return_if_fail (GIMP_IS_CONTEXT (context)); @@ -201,9 +201,10 @@ gimp_drawable_blend (GimpDrawable g_return_if_fail (GIMP_IS_IMAGE (gimage)); - gimp_set_busy (gimage->gimp); + if (! gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height)) + return; - gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2); + gimp_set_busy (gimage->gimp); bytes = gimp_drawable_bytes (drawable); @@ -213,15 +214,15 @@ gimp_drawable_blend (GimpDrawable bytes += 1; } - buf_tiles = tile_manager_new ((x2 - x1), (y2 - y1), bytes); - pixel_region_init (&bufPR, buf_tiles, 0, 0, (x2 - x1), (y2 - y1), TRUE); + buf_tiles = tile_manager_new (width, height, bytes); + pixel_region_init (&bufPR, buf_tiles, 0, 0, width, height, TRUE); gradient_fill_region (gimage, drawable, context, - &bufPR, (x2 - x1), (y2 - y1), + &bufPR, width, height, blend_mode, gradient_type, offset, repeat, reverse, supersample, max_depth, threshold, dither, - (startx - x1), (starty - y1), - (endx - x1), (endy - y1), + (startx - x), (starty - y), + (endx - x), (endy - y), progress); if (distR.tiles) @@ -230,14 +231,14 @@ gimp_drawable_blend (GimpDrawable distR.tiles = NULL; } - pixel_region_init (&bufPR, buf_tiles, 0, 0, (x2 - x1), (y2 - y1), FALSE); + pixel_region_init (&bufPR, buf_tiles, 0, 0, width, height, FALSE); gimp_drawable_apply_region (drawable, &bufPR, TRUE, _("Blend"), opacity, paint_mode, - NULL, x1, y1); + NULL, x, y); /* update the image */ - gimp_drawable_update (drawable, x1, y1, x2 - x1, y2 - y1); + gimp_drawable_update (drawable, x, y, width, height); /* free the temporary buffer */ tile_manager_unref (buf_tiles); Index: app/core/gimpdrawable-bucket-fill.c =================================================================== RCS file: /cvs/gnome/gimp/app/core/gimpdrawable-bucket-fill.c,v retrieving revision 1.34 diff -u -p -r1.34 gimpdrawable-bucket-fill.c --- app/core/gimpdrawable-bucket-fill.c 12 May 2004 08:11:49 -0000 1.34 +++ app/core/gimpdrawable-bucket-fill.c 19 Oct 2004 15:30:46 -0000 @@ -138,6 +138,12 @@ gimp_drawable_bucket_fill_full (GimpDraw g_return_if_fail (GIMP_IS_IMAGE (gimage)); + bytes = gimp_drawable_bytes (drawable); + selection = gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2); + + if ((x1 == x2) || (y1 == y2)) + return; + if (fill_mode == GIMP_FG_BUCKET_FILL || fill_mode == GIMP_BG_BUCKET_FILL) { @@ -163,9 +169,6 @@ gimp_drawable_bucket_fill_full (GimpDraw } gimp_set_busy (gimage->gimp); - - bytes = gimp_drawable_bytes (drawable); - selection = gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2); /* Do a seed bucket fill...To do this, calculate a new * contiguous region. If there is a selection, calculate the Index: app/core/gimpdrawable-desaturate.c =================================================================== RCS file: /cvs/gnome/gimp/app/core/gimpdrawable-desaturate.c,v retrieving revision 1.26 diff -u -p -r1.26 gimpdrawable-desaturate.c --- app/core/gimpdrawable-desaturate.c 13 Apr 2003 18:45:38 -0000 1.26 +++ app/core/gimpdrawable-desaturate.c 19 Oct 2004 15:30:46 -0000 @@ -41,18 +41,20 @@ gimp_drawable_desaturate (GimpDrawable * gint lightness, min, max; gboolean has_alpha; gpointer pr; - gint x1, y1, x2, y2; + gint x, y, width, height; g_return_if_fail (GIMP_IS_DRAWABLE (drawable)); g_return_if_fail (gimp_drawable_is_rgb (drawable)); has_alpha = gimp_drawable_has_alpha (drawable); - gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2); + + if (gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height)) + return; pixel_region_init (&srcPR, gimp_drawable_data (drawable), - x1, y1, (x2 - x1), (y2 - y1), FALSE); + x, y, width, height, FALSE); pixel_region_init (&destPR, gimp_drawable_shadow (drawable), - x1, y1, (x2 - x1), (y2 - y1), TRUE); + x, y, width, height, TRUE); for (pr = pixel_regions_register (2, &srcPR, &destPR); pr != NULL; @@ -94,5 +96,5 @@ gimp_drawable_desaturate (GimpDrawable * gimp_drawable_merge_shadow (drawable, TRUE, _("Desaturate")); - gimp_drawable_update (drawable, x1, y1, (x2 - x1), (y2 - y1)); + gimp_drawable_update (drawable, x, y, width, height); } Index: app/core/gimpdrawable-equalize.c =================================================================== RCS file: /cvs/gnome/gimp/app/core/gimpdrawable-equalize.c,v retrieving revision 1.30 diff -u -p -r1.30 gimpdrawable-equalize.c --- app/core/gimpdrawable-equalize.c 4 Jul 2004 18:12:22 -0000 1.30 +++ app/core/gimpdrawable-equalize.c 19 Oct 2004 15:30:46 -0000 @@ -44,20 +44,19 @@ gimp_drawable_equalize (GimpDrawable *dr gboolean mask_only) { PixelRegion srcPR, destPR; - guchar *mask; gint bytes; - gint x1, y1, x2, y2; + gint x, y, width, height; GimpHistogram *hist; GimpLut *lut; GimpImage *gimage; g_return_if_fail (GIMP_IS_DRAWABLE (drawable)); - mask = NULL; - - bytes = gimp_drawable_bytes (drawable); - gimage = gimp_item_get_image (GIMP_ITEM (drawable)); + bytes = gimp_drawable_bytes (drawable); + + if (! gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height)) + return; hist = gimp_histogram_new (GIMP_BASE_CONFIG (gimage->gimp->config)); gimp_drawable_calculate_histogram (drawable, hist); @@ -66,14 +65,12 @@ gimp_drawable_equalize (GimpDrawable *dr lut = eq_histogram_lut_new (hist, bytes); /* Apply the histogram */ - gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2); - pixel_region_init (&srcPR, gimp_drawable_data (drawable), - x1, y1, (x2 - x1), (y2 - y1), FALSE); + x, y, width, height, FALSE); pixel_region_init (&destPR, gimp_drawable_shadow (drawable), - x1, y1, (x2 - x1), (y2 - y1), TRUE); + x, y, width, height, TRUE); - pixel_regions_process_parallel ((p_func) gimp_lut_process, lut, + pixel_regions_process_parallel ((p_func) gimp_lut_process, lut, 2, &srcPR, &destPR); gimp_lut_free (lut); @@ -81,5 +78,5 @@ gimp_drawable_equalize (GimpDrawable *dr gimp_drawable_merge_shadow (drawable, TRUE, _("Equalize")); - gimp_drawable_update (drawable, x1, y1, (x2 - x1), (y2 - y1)); + gimp_drawable_update (drawable, x, y, width, height); } Index: app/core/gimpdrawable-histogram.c =================================================================== RCS file: /cvs/gnome/gimp/app/core/gimpdrawable-histogram.c,v retrieving revision 1.6 diff -u -p -r1.6 gimpdrawable-histogram.c --- app/core/gimpdrawable-histogram.c 13 Jan 2004 11:51:39 -0000 1.6 +++ app/core/gimpdrawable-histogram.c 19 Oct 2004 15:30:46 -0000 @@ -38,13 +38,16 @@ gimp_drawable_calculate_histogram (GimpD PixelRegion region; PixelRegion mask; gint x1, y1, x2, y2; - gint off_x, off_y; gboolean have_mask; g_return_if_fail (GIMP_IS_DRAWABLE (drawable)); g_return_if_fail (histogram != NULL); have_mask = gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2); + + if ((x1 == x2) || (y1 == y2)) + return; + pixel_region_init (®ion, gimp_drawable_data (drawable), x1, y1, (x2 - x1), (y2 - y1), FALSE); @@ -52,6 +55,7 @@ gimp_drawable_calculate_histogram (GimpD { GimpChannel *sel_mask; GimpImage *gimage; + gint off_x, off_y; gimage = gimp_item_get_image (GIMP_ITEM (drawable)); sel_mask = gimp_image_get_mask (gimage); Index: app/core/gimpdrawable-invert.c =================================================================== RCS file: /cvs/gnome/gimp/app/core/gimpdrawable-invert.c,v retrieving revision 1.32 diff -u -p -r1.32 gimpdrawable-invert.c --- app/core/gimpdrawable-invert.c 25 Mar 2003 16:36:34 -0000 1.32 +++ app/core/gimpdrawable-invert.c 19 Oct 2004 15:30:46 -0000 @@ -37,25 +37,25 @@ void gimp_drawable_invert (GimpDrawable *drawable) { PixelRegion srcPR, destPR; - gint x1, y1, x2, y2; + gint x, y, width, height; GimpLut *lut; + if (! gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height)) + return; + lut = invert_lut_new (gimp_drawable_bytes (drawable)); - gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2); pixel_region_init (&srcPR, gimp_drawable_data (drawable), - x1, y1, (x2 - x1), (y2 - y1), FALSE); + x, y, width, height, FALSE); pixel_region_init (&destPR, gimp_drawable_shadow (drawable), - x1, y1, (x2 - x1), (y2 - y1), TRUE); + x, y, width, height, TRUE); - pixel_regions_process_parallel ((p_func)gimp_lut_process, lut, + pixel_regions_process_parallel ((p_func)gimp_lut_process, lut, 2, &srcPR, &destPR); gimp_lut_free (lut); gimp_drawable_merge_shadow (drawable, TRUE, _("Invert")); - gimp_drawable_update (drawable, - x1, y1, - (x2 - x1), (y2 - y1)); + gimp_drawable_update (drawable, x, y, width, height); } Index: app/core/gimpdrawable-stroke.c =================================================================== RCS file: /cvs/gnome/gimp/app/core/gimpdrawable-stroke.c,v retrieving revision 1.28 diff -u -p -r1.28 gimpdrawable-stroke.c --- app/core/gimpdrawable-stroke.c 31 Dec 2003 02:26:29 -0000 1.28 +++ app/core/gimpdrawable-stroke.c 19 Oct 2004 15:30:47 -0000 @@ -205,7 +205,8 @@ gimp_drawable_stroke_scan_convert (GimpD GimpStrokeOptions *options, GimpScanConvert *scan_convert) { - /* Stroke options */ + GimpContext *context = GIMP_CONTEXT (options); + GimpImage *gimage; gdouble width; TileManager *base; TileManager *mask; @@ -214,28 +215,11 @@ gimp_drawable_stroke_scan_convert (GimpD gint off_x, off_y; guchar bg[1] = { 0, }; PixelRegion maskPR, basePR; - GimpContext *context; - GimpImage *gimage; - - context = GIMP_CONTEXT (options); gimage = gimp_item_get_image (GIMP_ITEM (drawable)); - /* what area do we operate on? */ - if (! gimp_channel_is_empty (gimp_image_get_mask (gimage))) - { - gint x2, y2; - - gimp_drawable_mask_bounds (drawable, &x, &y, &x2, &y2); - w = x2 - x; - h = y2 - y; - } - else - { - x = y = 0; - w = gimp_item_width (GIMP_ITEM (drawable)); - h = gimp_item_height (GIMP_ITEM (drawable)); - } + if (! gimp_drawable_mask_intersect (drawable, &x, &y, &w, &h)) + return; gimp_item_offsets (GIMP_ITEM (drawable), &off_x, &off_y); Index: app/core/gimpdrawable.c =================================================================== RCS file: /cvs/gnome/gimp/app/core/gimpdrawable.c,v retrieving revision 1.170 diff -u -p -r1.170 gimpdrawable.c --- app/core/gimpdrawable.c 25 Sep 2004 13:16:13 -0000 1.170 +++ app/core/gimpdrawable.c 19 Oct 2004 15:30:47 -0000 @@ -1065,8 +1065,7 @@ gimp_drawable_merge_shadow (GimpDrawable const gchar *undo_desc) { GimpImage *gimage; - PixelRegion shadowPR; - gint x1, y1, x2, y2; + gint x, y, width, height; g_return_if_fail (GIMP_IS_DRAWABLE (drawable)); @@ -1079,13 +1078,17 @@ gimp_drawable_merge_shadow (GimpDrawable * extents of the selection mask, as it cannot extend beyond * them. */ - gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2); - pixel_region_init (&shadowPR, gimage->shadow, - x1, y1, (x2 - x1), (y2 - y1), FALSE); - gimp_drawable_apply_region (drawable, &shadowPR, - push_undo, undo_desc, - GIMP_OPACITY_OPAQUE, GIMP_REPLACE_MODE, - NULL, x1, y1); + if (gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height)) + { + PixelRegion shadowPR; + + pixel_region_init (&shadowPR, gimage->shadow, + x, y, width, height, FALSE); + gimp_drawable_apply_region (drawable, &shadowPR, + push_undo, undo_desc, + GIMP_OPACITY_OPAQUE, GIMP_REPLACE_MODE, + NULL, x, y); + } } void @@ -1214,10 +1217,10 @@ gimp_drawable_mask_bounds (GimpDrawable g_return_val_if_fail (y2 != NULL, FALSE); item = GIMP_ITEM (drawable); - gimage = gimp_item_get_image (item); - g_return_val_if_fail (gimage != NULL, FALSE); + g_return_val_if_fail (gimp_item_is_attached (item), FALSE); + gimage = gimp_item_get_image (item); selection = gimp_image_get_mask (gimage); if (GIMP_DRAWABLE (selection) != drawable && @@ -1241,6 +1244,54 @@ gimp_drawable_mask_bounds (GimpDrawable *y2 = gimp_item_height (item); return FALSE; +} + +gboolean +gimp_drawable_mask_intersect (GimpDrawable *drawable, + gint *x, + gint *y, + gint *width, + gint *height) +{ + GimpItem *item; + GimpImage *gimage; + GimpChannel *selection; + + g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), FALSE); + g_return_val_if_fail (x != NULL, FALSE); + g_return_val_if_fail (y != NULL, FALSE); + g_return_val_if_fail (width != NULL, FALSE); + g_return_val_if_fail (height != NULL, FALSE); + + item = GIMP_ITEM (drawable); + + g_return_val_if_fail (gimp_item_is_attached (item), FALSE); + + gimage = gimp_item_get_image (item); + selection = gimp_image_get_mask (gimage); + + if (GIMP_DRAWABLE (selection) != drawable && + gimp_channel_bounds (selection, x, y, width, height)) + { + gint off_x, off_y; + + gimp_item_offsets (item, &off_x, &off_y); + + return gimp_rectangle_intersect (*x - off_x, *y - off_y, + *width - *x, *height - *y, + 0, 0, + gimp_item_width (item), + gimp_item_height (item), + x, y, + width, height); + } + + *x = 0; + *y = 0; + *width = gimp_item_width (item); + *height = gimp_item_height (item); + + return TRUE; } gboolean Index: app/core/gimpdrawable.h =================================================================== RCS file: /cvs/gnome/gimp/app/core/gimpdrawable.h,v retrieving revision 1.69 diff -u -p -r1.69 gimpdrawable.h --- app/core/gimpdrawable.h 13 Jul 2004 23:04:05 -0000 1.69 +++ app/core/gimpdrawable.h 19 Oct 2004 15:30:48 -0000 @@ -189,10 +189,15 @@ void gimp_drawable_fill_by_ty GimpFillType fill_type); gboolean gimp_drawable_mask_bounds (GimpDrawable *drawable, - gint *x1, - gint *y1, - gint *x2, - gint *y2); + gint *x1, + gint *y1, + gint *x2, + gint *y2); +gboolean gimp_drawable_mask_intersect (GimpDrawable *drawable, + gint *x, + gint *y, + gint *width, + gint *height); gboolean gimp_drawable_has_alpha (const GimpDrawable *drawable); GimpImageType gimp_drawable_type (const GimpDrawable *drawable); Index: app/core/gimpimagemap.c =================================================================== RCS file: /cvs/gnome/gimp/app/core/gimpimagemap.c,v retrieving revision 1.60 diff -u -p -r1.60 gimpimagemap.c --- app/core/gimpimagemap.c 25 Sep 2004 13:16:13 -0000 1.60 +++ app/core/gimpimagemap.c 19 Oct 2004 15:30:48 -0000 @@ -275,10 +275,10 @@ gimp_image_map_apply (GimpImageMap GimpImageMapApplyFunc apply_func, gpointer apply_data) { - gint x1, y1; - gint x2, y2; - gint offset_x, offset_y; + gint x, y; gint width, height; + gint undo_offset_x, undo_offset_y; + gint undo_width, undo_height; g_return_if_fail (GIMP_IS_IMAGE_MAP (image_map)); g_return_if_fail (apply_func != NULL); @@ -301,33 +301,38 @@ gimp_image_map_apply (GimpImageMap return; /* The application should occur only within selection bounds */ - gimp_drawable_mask_bounds (image_map->drawable, &x1, &y1, &x2, &y2); - - if ((x2 - x1 < 1) || (y2 - y1 < 1)) + if (! gimp_drawable_mask_intersect (image_map->drawable, + &x, &y, &width, &height)) return; /* If undo tiles don't exist, or change size, (re)allocate */ if (image_map->undo_tiles) { - offset_x = image_map->undo_offset_x; - offset_y = image_map->undo_offset_y; - width = tile_manager_width (image_map->undo_tiles); - height = tile_manager_height (image_map->undo_tiles); + undo_offset_x = image_map->undo_offset_x; + undo_offset_y = image_map->undo_offset_y; + undo_width = tile_manager_width (image_map->undo_tiles); + undo_height = tile_manager_height (image_map->undo_tiles); } else { - offset_x = offset_y = width = height = 0; + undo_offset_x = 0; + undo_offset_y = 0; + undo_width = 0; + undo_height = 0; } if (! image_map->undo_tiles || - offset_x != x1 || offset_y != y1 || - width != (x2 - x1) || height != (y2 - y1)) + undo_offset_x != x || + undo_offset_y != y || + undo_width != width || + undo_height != height) { /* If either the extents changed or the tiles don't exist, * allocate new */ if (! image_map->undo_tiles || - width != (x2 - x1) || height != (y2 - y1)) + undo_width != width || + undo_height != height) { /* Destroy old tiles */ if (image_map->undo_tiles) @@ -335,44 +340,45 @@ gimp_image_map_apply (GimpImageMap /* Allocate new tiles */ image_map->undo_tiles = - tile_manager_new ((x2 - x1), (y2 - y1), + tile_manager_new (width, height, gimp_drawable_bytes (image_map->drawable)); } /* Copy from the image to the new tiles */ pixel_region_init (&image_map->srcPR, gimp_drawable_data (image_map->drawable), - x1, y1, (x2 - x1), (y2 - y1), FALSE); + x, y, width, height, FALSE); pixel_region_init (&image_map->destPR, image_map->undo_tiles, - 0, 0, (x2 - x1), (y2 - y1), TRUE); + 0, 0, width, height, TRUE); copy_region (&image_map->srcPR, &image_map->destPR); /* Set the offsets */ - image_map->undo_offset_x = x1; - image_map->undo_offset_y = y1; + image_map->undo_offset_x = x; + image_map->undo_offset_y = y; } else /* image_map->undo_tiles exist AND drawable dimensions have not changed... */ { /* Reset to initial drawable conditions. */ /* Copy from the backup undo tiles to the drawable */ pixel_region_init (&image_map->srcPR, image_map->undo_tiles, - 0, 0, width, height, FALSE); + 0, 0, undo_width, undo_height, FALSE); pixel_region_init (&image_map->destPR, gimp_drawable_data (image_map->drawable), - offset_x, offset_y, width, height, TRUE); + undo_offset_x, undo_offset_y, + undo_width, undo_height, TRUE); copy_region (&image_map->srcPR, &image_map->destPR); } /* Configure the src from the drawable data */ pixel_region_init (&image_map->srcPR, image_map->undo_tiles, - 0, 0, (x2 - x1), (y2 - y1), FALSE); + 0, 0, width, height, FALSE); /* Configure the dest as the shadow buffer */ pixel_region_init (&image_map->destPR, gimp_drawable_shadow (image_map->drawable), - x1, y1, (x2 - x1), (y2 - y1), TRUE); + x, y, width, height, TRUE); /* Apply the image transformation to the pixels */ image_map->PRI = pixel_regions_register (2, Index: app/core/gimpselection.c =================================================================== RCS file: /cvs/gnome/gimp/app/core/gimpselection.c,v retrieving revision 1.26 diff -u -p -r1.26 gimpselection.c --- app/core/gimpselection.c 22 Sep 2004 12:46:34 -0000 1.26 +++ app/core/gimpselection.c 19 Oct 2004 15:30:49 -0000 @@ -652,8 +652,8 @@ gimp_selection_extract (GimpChannel *se GimpImageBaseType base_type = GIMP_RGB; gint bytes = 0; gint x1, y1, x2, y2; - gint off_x, off_y; gboolean non_empty; + gint off_x, off_y; g_return_val_if_fail (GIMP_IS_SELECTION (selection), NULL); g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL); @@ -668,7 +668,7 @@ gimp_selection_extract (GimpChannel *se * actual selection mask */ non_empty = gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2); - if (non_empty && (!(x2 - x1) || !(y2 - y1))) + if (non_empty && ((x1 == x2) || (y1 == y2))) { g_message (_("Unable to cut or copy because the " "selected region is empty.")); @@ -803,9 +803,8 @@ gimp_selection_float (GimpChannel *sele GimpImage *gimage; GimpLayer *layer; TileManager *tiles; + gint x1, y1, x2, y2; gboolean non_empty; - gint x1, y1; - gint x2, y2; g_return_val_if_fail (GIMP_IS_SELECTION (selection), NULL); g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL); @@ -816,7 +815,7 @@ gimp_selection_float (GimpChannel *sele /* Make sure there is a region to float... */ non_empty = gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2); - if (! non_empty || (x2 - x1) == 0 || (y2 - y1) == 0) + if (! non_empty || (x1 == x2) || (y1 == y2)) { g_message (_("Cannot float selection because the " "selected region is empty.")); Index: app/pdb/color_cmds.c =================================================================== RCS file: /cvs/gnome/gimp/app/pdb/color_cmds.c,v retrieving revision 1.53 diff -u -p -r1.53 color_cmds.c --- app/pdb/color_cmds.c 6 Oct 2004 13:13:07 -0000 1.53 +++ app/pdb/color_cmds.c 19 Oct 2004 15:30:50 -0000 @@ -91,10 +91,6 @@ brightness_contrast_invoker (Gimp GimpDrawable *drawable; gint32 brightness; gint32 contrast; - GimpImage *gimage; - GimpLut *lut; - PixelRegion srcPR, destPR; - int x1, y1, x2, y2; drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int); if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable)))) @@ -115,27 +111,31 @@ brightness_contrast_invoker (Gimp if (success) { - gimage = gimp_item_get_image (GIMP_ITEM (drawable)); - - lut = brightness_contrast_lut_new (brightness / 255.0, - contrast / 127.0, - gimp_drawable_bytes (drawable)); + gint x, y, width, height; /* The application should occur only within selection bounds */ - gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2); + if (gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height)) + { + GimpLut *lut; + PixelRegion srcPR, destPR; + + lut = brightness_contrast_lut_new (brightness / 255.0, + contrast / 127.0, + gimp_drawable_bytes (drawable)); - pixel_region_init (&srcPR, gimp_drawable_data (drawable), - x1, y1, (x2 - x1), (y2 - y1), FALSE); - pixel_region_init (&destPR, gimp_drawable_shadow (drawable), - x1, y1, (x2 - x1), (y2 - y1), TRUE); + pixel_region_init (&srcPR, gimp_drawable_data (drawable), + x, y, width, height, FALSE); + pixel_region_init (&destPR, gimp_drawable_shadow (drawable), + x, y, width, height, TRUE); - pixel_regions_process_parallel ((p_func) gimp_lut_process, lut, 2, - &srcPR, &destPR); + pixel_regions_process_parallel ((p_func) gimp_lut_process, lut, 2, + &srcPR, &destPR); - gimp_lut_free (lut); + gimp_lut_free (lut); - gimp_drawable_merge_shadow (drawable, TRUE, _("Brightness-Contrast")); - gimp_drawable_update (drawable, x1, y1, (x2 - x1), (y2 - y1)); + gimp_drawable_merge_shadow (drawable, TRUE, _("Brightness-Contrast")); + gimp_drawable_update (drawable, x, y, width, height); + } } } @@ -192,10 +192,6 @@ levels_invoker (Gimp *gimp, gdouble gamma; gint32 low_output; gint32 high_output; - PixelRegion srcPR, destPR; - Levels l; - gint x1, y1, x2, y2; - GimpLut *lut; drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int); if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable)))) @@ -236,41 +232,49 @@ levels_invoker (Gimp *gimp, if (success) { - /* FIXME: hack */ - if (gimp_drawable_is_gray (drawable) && channel == GIMP_HISTOGRAM_ALPHA) - channel = 1; - - lut = gimp_lut_new (); - - levels_init (&l); - - l.low_input[channel] = low_input; - l.high_input[channel] = high_input; - l.gamma[channel] = gamma; - l.low_output[channel] = low_output; - l.high_output[channel] = high_output; - - /* setup the lut */ - gimp_lut_setup (lut, - (GimpLutFunc) levels_lut_func, - &l, - gimp_drawable_bytes (drawable)); + gint x, y, width, height; /* The application should occur only within selection bounds */ - gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2); - - pixel_region_init (&srcPR, gimp_drawable_data (drawable), - x1, y1, (x2 - x1), (y2 - y1), FALSE); - pixel_region_init (&destPR, gimp_drawable_shadow (drawable), - x1, y1, (x2 - x1), (y2 - y1), TRUE); + if (gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height)) + { + PixelRegion srcPR, destPR; + Levels l; + GimpLut *lut; + + /* FIXME: hack */ + if (gimp_drawable_is_gray (drawable) && + channel == GIMP_HISTOGRAM_ALPHA) + channel = 1; + + lut = gimp_lut_new (); + + levels_init (&l); + + l.low_input[channel] = low_input; + l.high_input[channel] = high_input; + l.gamma[channel] = gamma; + l.low_output[channel] = low_output; + l.high_output[channel] = high_output; + + /* setup the lut */ + gimp_lut_setup (lut, + (GimpLutFunc) levels_lut_func, + &l, + gimp_drawable_bytes (drawable)); + + pixel_region_init (&srcPR, gimp_drawable_data (drawable), + x, y, width, height, FALSE); + pixel_region_init (&destPR, gimp_drawable_shadow (drawable), + x, y, width, height, TRUE); - pixel_regions_process_parallel ((p_func) gimp_lut_process, lut, 2, - &srcPR, &destPR); + pixel_regions_process_parallel ((p_func) gimp_lut_process, lut, 2, + &srcPR, &destPR); - gimp_lut_free (lut); + gimp_lut_free (lut); - gimp_drawable_merge_shadow (drawable, TRUE, _("Levels")); - gimp_drawable_update (drawable, x1, y1, (x2 - x1), (y2 - y1)); + gimp_drawable_merge_shadow (drawable, TRUE, _("Levels")); + gimp_drawable_update (drawable, x, y, width, height); + } } } @@ -341,12 +345,6 @@ levels_auto_invoker (Gimp *gimp, { gboolean success = TRUE; GimpDrawable *drawable; - PixelRegion srcPR, destPR; - Levels levels; - gint x1, y1, x2, y2; - GimpLut *lut; - GimpImage *image; - GimpHistogram *hist; drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int); if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable)))) @@ -359,39 +357,46 @@ levels_auto_invoker (Gimp *gimp, if (success) { - /* Build the histogram */ - image = gimp_item_get_image (GIMP_ITEM (drawable)); - hist = gimp_histogram_new (GIMP_BASE_CONFIG (image->gimp->config)); - - gimp_drawable_calculate_histogram (drawable, hist); - - /* Calculate the levels */ - levels_init (&levels); - levels_auto (&levels, hist, ! gimp_drawable_is_gray (drawable)); - - /* Set up the lut */ - lut = gimp_lut_new (); - gimp_lut_setup (lut, - (GimpLutFunc) levels_lut_func, - &levels, - gimp_drawable_bytes (drawable)); + gint x, y, width, height; /* The application should occur only within selection bounds */ - gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2); - - pixel_region_init (&srcPR, gimp_drawable_data (drawable), - x1, y1, (x2 - x1), (y2 - y1), FALSE); - pixel_region_init (&destPR, gimp_drawable_shadow (drawable), - x1, y1, (x2 - x1), (y2 - y1), TRUE); + if (gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height)) + { + PixelRegion srcPR, destPR; + Levels levels; + GimpLut *lut; + GimpHistogram *hist; + + /* Build the histogram */ + hist = gimp_histogram_new (GIMP_BASE_CONFIG (gimp->config)); + + gimp_drawable_calculate_histogram (drawable, hist); + + /* Calculate the levels */ + levels_init (&levels); + levels_auto (&levels, hist, ! gimp_drawable_is_gray (drawable)); + + /* Set up the lut */ + lut = gimp_lut_new (); + gimp_lut_setup (lut, + (GimpLutFunc) levels_lut_func, + &levels, + gimp_drawable_bytes (drawable)); + + pixel_region_init (&srcPR, gimp_drawable_data (drawable), + x, y, width, height, FALSE); + pixel_region_init (&destPR, gimp_drawable_shadow (drawable), + x, y, width, height, TRUE); - pixel_regions_process_parallel ((p_func) gimp_lut_process, lut, 2, - &srcPR, &destPR); + pixel_regions_process_parallel ((p_func) gimp_lut_process, lut, 2, + &srcPR, &destPR); - gimp_lut_free (lut); - gimp_histogram_free (hist); + gimp_lut_free (lut); + gimp_histogram_free (hist); - gimp_drawable_merge_shadow (drawable, TRUE, _("Levels")); - gimp_drawable_update (drawable, x1, y1, (x2 - x1), (y2 - y1)); + gimp_drawable_merge_shadow (drawable, TRUE, _("Levels")); + gimp_drawable_update (drawable, x, y, width, height); + } } } @@ -433,10 +438,6 @@ posterize_invoker (Gimp *gimp, gboolean success = TRUE; GimpDrawable *drawable; gint32 levels; - GimpImage *gimage; - GimpLut *lut; - PixelRegion srcPR, destPR; - int x1, y1, x2, y2; drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int); if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable)))) @@ -453,25 +454,29 @@ posterize_invoker (Gimp *gimp, if (success) { - gimage = gimp_item_get_image (GIMP_ITEM (drawable)); - - lut = posterize_lut_new (levels, gimp_drawable_bytes (drawable)); + gint x, y, width, height; /* The application should occur only within selection bounds */ - gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2); + if (gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height)) + { + GimpLut *lut; + PixelRegion srcPR, destPR; + + lut = posterize_lut_new (levels, gimp_drawable_bytes (drawable)); - pixel_region_init (&srcPR, gimp_drawable_data (drawable), - x1, y1, (x2 - x1), (y2 - y1), FALSE); - pixel_region_init (&destPR, gimp_drawable_shadow (drawable), - x1, y1, (x2 - x1), (y2 - y1), TRUE); + pixel_region_init (&srcPR, gimp_drawable_data (drawable), + x, y, width, height, FALSE); + pixel_region_init (&destPR, gimp_drawable_shadow (drawable), + x, y, width, height, TRUE); - pixel_regions_process_parallel ((p_func) gimp_lut_process, lut, 2, - &srcPR, &destPR); + pixel_regions_process_parallel ((p_func) gimp_lut_process, lut, 2, + &srcPR, &destPR); - gimp_lut_free (lut); + gimp_lut_free (lut); - gimp_drawable_merge_shadow (drawable, TRUE, _("Posterize")); - gimp_drawable_update (drawable, x1, y1, (x2 - x1), (y2 - y1)); + gimp_drawable_merge_shadow (drawable, TRUE, _("Posterize")); + gimp_drawable_update (drawable, x, y, width, height); + } } } @@ -678,11 +683,6 @@ curves_spline_invoker (Gimp *gim gint32 channel; gint32 num_points; guint8 *control_pts; - Curves c; - gint x1, y1, x2, y2; - gint j; - PixelRegion srcPR, destPR; - GimpLut *lut; drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int); if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable)))) @@ -709,46 +709,55 @@ curves_spline_invoker (Gimp *gim if (success) { - /* FIXME: hack */ - if (gimp_drawable_is_gray (drawable) && channel == GIMP_HISTOGRAM_ALPHA) - channel = 1; + gint x, y, width, height; - lut = gimp_lut_new (); + /* The application should occur only within selection bounds */ + if (gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height)) + { + Curves c; + gint j; + PixelRegion srcPR, destPR; + GimpLut *lut; - curves_init (&c); + /* FIXME: hack */ + if (gimp_drawable_is_gray (drawable) && + channel == GIMP_HISTOGRAM_ALPHA) + channel = 1; - /* unset the last point */ - c.points[channel][CURVES_NUM_POINTS - 1][0] = -1; - c.points[channel][CURVES_NUM_POINTS - 1][1] = -1; + lut = gimp_lut_new (); - for (j = 0; j < num_points / 2; j++) - { - c.points[channel][j][0] = control_pts[j * 2]; - c.points[channel][j][1] = control_pts[j * 2 + 1]; - } + curves_init (&c); - curves_calculate_curve (&c, channel); + /* unset the last point */ + c.points[channel][CURVES_NUM_POINTS - 1][0] = -1; + c.points[channel][CURVES_NUM_POINTS - 1][1] = -1; - gimp_lut_setup (lut, - (GimpLutFunc) curves_lut_func, - &c, - gimp_drawable_bytes (drawable)); + for (j = 0; j < num_points / 2; j++) + { + c.points[channel][j][0] = control_pts[j * 2]; + c.points[channel][j][1] = control_pts[j * 2 + 1]; + } - /* The application should occur only within selection bounds */ - gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2); + curves_calculate_curve (&c, channel); + + gimp_lut_setup (lut, + (GimpLutFunc) curves_lut_func, + &c, + gimp_drawable_bytes (drawable)); - pixel_region_init (&srcPR, gimp_drawable_data (drawable), - x1, y1, (x2 - x1), (y2 - y1), FALSE); - pixel_region_init (&destPR, gimp_drawable_shadow (drawable), - x1, y1, (x2 - x1), (y2 - y1), TRUE); + pixel_region_init (&srcPR, gimp_drawable_data (drawable), + x, y, width, height, FALSE); + pixel_region_init (&destPR, gimp_drawable_shadow (drawable), + x, y, width, height, TRUE); - pixel_regions_process_parallel ((p_func) gimp_lut_process, lut, 2, - &srcPR, &destPR); + pixel_regions_process_parallel ((p_func) gimp_lut_process, lut, 2, + &srcPR, &destPR); - gimp_lut_free (lut); + gimp_lut_free (lut); - gimp_drawable_merge_shadow (drawable, TRUE, _("Curves")); - gimp_drawable_update (drawable, x1, y1, (x2 - x1), (y2 - y1)); + gimp_drawable_merge_shadow (drawable, TRUE, _("Curves")); + gimp_drawable_update (drawable, x, y, width, height); + } } } @@ -807,11 +816,6 @@ curves_explicit_invoker (Gimp *g gint32 channel; gint32 num_bytes; guint8 *curve; - Curves c; - gint x1, y1, x2, y2; - gint j; - PixelRegion srcPR, destPR; - GimpLut *lut; drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int); if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable)))) @@ -838,37 +842,46 @@ curves_explicit_invoker (Gimp *g if (success) { - /* FIXME: hack */ - if (gimp_drawable_is_gray (drawable) && channel == GIMP_HISTOGRAM_ALPHA) - channel = 1; + gint x, y, width, height; + + /* The application should occur only within selection bounds */ + if (gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height)) + { + Curves c; + gint j; + PixelRegion srcPR, destPR; + GimpLut *lut; - lut = gimp_lut_new (); + /* FIXME: hack */ + if (gimp_drawable_is_gray (drawable) && + channel == GIMP_HISTOGRAM_ALPHA) + channel = 1; - curves_init (&c); + lut = gimp_lut_new (); - for (j = 0; j < 256; j++) - c.curve[channel][j] = curve[j]; + curves_init (&c); - gimp_lut_setup (lut, - (GimpLutFunc) curves_lut_func, - &c, - gimp_drawable_bytes (drawable)); + for (j = 0; j < 256; j++) + c.curve[channel][j] = curve[j]; - /* The application should occur only within selection bounds */ - gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2); + gimp_lut_setup (lut, + (GimpLutFunc) curves_lut_func, + &c, + gimp_drawable_bytes (drawable)); - pixel_region_init (&srcPR, gimp_drawable_data (drawable), - x1, y1, (x2 - x1), (y2 - y1), FALSE); - pixel_region_init (&destPR, gimp_drawable_shadow (drawable), - x1, y1, (x2 - x1), (y2 - y1), TRUE); + pixel_region_init (&srcPR, gimp_drawable_data (drawable), + x, y, width, height, FALSE); + pixel_region_init (&destPR, gimp_drawable_shadow (drawable), + x, y, width, height, TRUE); - pixel_regions_process_parallel ((p_func) gimp_lut_process, lut, 2, - &srcPR, &destPR); + pixel_regions_process_parallel ((p_func) gimp_lut_process, lut, 2, + &srcPR, &destPR); - gimp_lut_free (lut); + gimp_lut_free (lut); - gimp_drawable_merge_shadow (drawable, TRUE, _("Curves")); - gimp_drawable_update (drawable, x1, y1, (x2 - x1), (y2 - y1)); + gimp_drawable_merge_shadow (drawable, TRUE, _("Curves")); + gimp_drawable_update (drawable, x, y, width, height); + } } } @@ -929,10 +942,6 @@ color_balance_invoker (Gimp *gim gdouble cyan_red; gdouble magenta_green; gdouble yellow_blue; - ColorBalance cb; - PixelRegionIterator *pr; - PixelRegion srcPR, destPR; - gint x1, y1, x2, y2; drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int); if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable)))) @@ -963,33 +972,40 @@ color_balance_invoker (Gimp *gim if (success) { - color_balance_init (&cb); - - cb.preserve_luminosity = preserve_lum; - - cb.cyan_red[transfer_mode] = cyan_red; - cb.magenta_green[transfer_mode] = magenta_green; - cb.yellow_blue[transfer_mode] = yellow_blue; - - color_balance_create_lookup_tables (&cb); + gint x, y, width, height; /* The application should occur only within selection bounds */ - gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2); - - pixel_region_init (&srcPR, gimp_drawable_data (drawable), - x1, y1, (x2 - x1), (y2 - y1), FALSE); - pixel_region_init (&destPR, gimp_drawable_shadow (drawable), - x1, y1, (x2 - x1), (y2 - y1), TRUE); - - for (pr = pixel_regions_register (2, &srcPR, &destPR); - pr; - pr = pixel_regions_process (pr)) + if (gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height)) { - color_balance (&srcPR, &destPR, &cb); - } + ColorBalance cb; + PixelRegionIterator *pr; + PixelRegion srcPR, destPR; + + color_balance_init (&cb); + + cb.preserve_luminosity = preserve_lum; + + cb.cyan_red[transfer_mode] = cyan_red; + cb.magenta_green[transfer_mode] = magenta_green; + cb.yellow_blue[transfer_mode] = yellow_blue; + + color_balance_create_lookup_tables (&cb); + + pixel_region_init (&srcPR, gimp_drawable_data (drawable), + x, y, width, height, FALSE); + pixel_region_init (&destPR, gimp_drawable_shadow (drawable), + x, y, width, height, TRUE); + + for (pr = pixel_regions_register (2, &srcPR, &destPR); + pr; + pr = pixel_regions_process (pr)) + { + color_balance (&srcPR, &destPR, &cb); + } - gimp_drawable_merge_shadow (drawable, TRUE, _("Color Balance")); - gimp_drawable_update (drawable, x1, y1, (x2 - x1), (y2 - y1)); + gimp_drawable_merge_shadow (drawable, TRUE, _("Color Balance")); + gimp_drawable_update (drawable, x, y, width, height); + } } } @@ -1058,10 +1074,6 @@ colorize_invoker (Gimp *gimp, gdouble hue; gdouble saturation; gdouble lightness; - Colorize colors; - PixelRegionIterator *pr; - PixelRegion srcPR, destPR; - gint x1, y1, x2, y2; drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int); if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable)))) @@ -1086,31 +1098,38 @@ colorize_invoker (Gimp *gimp, if (success) { - colorize_init (&colors); - - colors.hue = hue; - colors.saturation = saturation; - colors.lightness = lightness; - - colorize_calculate (&colors); + gint x, y, width, height; /* The application should occur only within selection bounds */ - gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2); - - pixel_region_init (&srcPR, gimp_drawable_data (drawable), - x1, y1, (x2 - x1), (y2 - y1), FALSE); - pixel_region_init (&destPR, gimp_drawable_shadow (drawable), - x1, y1, (x2 - x1), (y2 - y1), TRUE); - - for (pr = pixel_regions_register (2, &srcPR, &destPR); - pr; - pr = pixel_regions_process (pr)) + if (gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height)) { - colorize (&srcPR, &destPR, &colors); - } + Colorize colors; + PixelRegionIterator *pr; + PixelRegion srcPR, destPR; + + colorize_init (&colors); + + colors.hue = hue; + colors.saturation = saturation; + colors.lightness = lightness; + + colorize_calculate (&colors); + + pixel_region_init (&srcPR, gimp_drawable_data (drawable), + x, y, width, height, FALSE); + pixel_region_init (&destPR, gimp_drawable_shadow (drawable), + x, y, width, height, TRUE); + + for (pr = pixel_regions_register (2, &srcPR, &destPR); + pr; + pr = pixel_regions_process (pr)) + { + colorize (&srcPR, &destPR, &colors); + } - gimp_drawable_merge_shadow (drawable, TRUE, _("Colorize")); - gimp_drawable_update (drawable, x1, y1, (x2 - x1), (y2 - y1)); + gimp_drawable_merge_shadow (drawable, TRUE, _("Colorize")); + gimp_drawable_update (drawable, x, y, width, height); + } } } @@ -1327,10 +1346,6 @@ hue_saturation_invoker (Gimp *gi gdouble hue_offset; gdouble lightness; gdouble saturation; - HueSaturation hs; - PixelRegionIterator *pr; - PixelRegion srcPR, destPR; - gint x1, y1, x2, y2; drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int); if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable)))) @@ -1359,32 +1374,39 @@ hue_saturation_invoker (Gimp *gi if (success) { - hue_saturation_init (&hs); - - hs.hue[hue_range] = hue_offset; - hs.lightness[hue_range] = lightness; - hs.saturation[hue_range] = saturation; - - /* Calculate the transfer arrays */ - hue_saturation_calculate_transfers (&hs); + gint x, y, width, height; /* The application should occur only within selection bounds */ - gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2); - - pixel_region_init (&srcPR, gimp_drawable_data (drawable), - x1, y1, (x2 - x1), (y2 - y1), FALSE); - pixel_region_init (&destPR, gimp_drawable_shadow (drawable), - x1, y1, (x2 - x1), (y2 - y1), TRUE); - - for (pr = pixel_regions_register (2, &srcPR, &destPR); - pr; - pr = pixel_regions_process (pr)) + if (gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height)) { - hue_saturation (&srcPR, &destPR, &hs); - } + HueSaturation hs; + PixelRegionIterator *pr; + PixelRegion srcPR, destPR; + + hue_saturation_init (&hs); + + hs.hue[hue_range] = hue_offset; + hs.lightness[hue_range] = lightness; + hs.saturation[hue_range] = saturation; + + /* Calculate the transfer arrays */ + hue_saturation_calculate_transfers (&hs); + + pixel_region_init (&srcPR, gimp_drawable_data (drawable), + x, y, width, height, FALSE); + pixel_region_init (&destPR, gimp_drawable_shadow (drawable), + x, y, width, height, TRUE); + + for (pr = pixel_regions_register (2, &srcPR, &destPR); + pr; + pr = pixel_regions_process (pr)) + { + hue_saturation (&srcPR, &destPR, &hs); + } - gimp_drawable_merge_shadow (drawable, TRUE, _("Hue-Saturation")); - gimp_drawable_update (drawable, x1, y1, (x2 - x1), (y2 - y1)); + gimp_drawable_merge_shadow (drawable, TRUE, _("Hue-Saturation")); + gimp_drawable_update (drawable, x, y, width, height); + } } } @@ -1447,9 +1469,6 @@ threshold_invoker (Gimp *gimp, GimpDrawable *drawable; gint32 low_threshold; gint32 high_threshold; - Threshold tr; - gint x1, y1, x2, y2; - PixelRegion srcPR, destPR; drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int); if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable)))) @@ -1470,23 +1489,29 @@ threshold_invoker (Gimp *gimp, if (success) { - tr.color = gimp_drawable_is_rgb (drawable); - tr.low_threshold = low_threshold; - tr.high_threshold = high_threshold; + gint x, y, width, height; /* The application should occur only within selection bounds */ - gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2); + if (gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height)) + { + Threshold tr; + PixelRegion srcPR, destPR; - pixel_region_init (&srcPR, gimp_drawable_data (drawable), - x1, y1, (x2 - x1), (y2 - y1), FALSE); - pixel_region_init (&destPR, gimp_drawable_shadow (drawable), - x1, y1, (x2 - x1), (y2 - y1), TRUE); + tr.color = gimp_drawable_is_rgb (drawable); + tr.low_threshold = low_threshold; + tr.high_threshold = high_threshold; + + pixel_region_init (&srcPR, gimp_drawable_data (drawable), + x, y, width, height, FALSE); + pixel_region_init (&destPR, gimp_drawable_shadow (drawable), + x, y, width, height, TRUE); - pixel_regions_process_parallel ((p_func) threshold_2, &tr, 2, - &srcPR, &destPR); + pixel_regions_process_parallel ((p_func) threshold_2, &tr, 2, + &srcPR, &destPR); - gimp_drawable_merge_shadow (drawable, TRUE, _("Threshold")); - gimp_drawable_update (drawable, x1, y1, (x2 - x1), (y2 - y1)); + gimp_drawable_merge_shadow (drawable, TRUE, _("Threshold")); + gimp_drawable_update (drawable, x, y, width, height); + } } } Index: app/pdb/transform_tools_cmds.c =================================================================== RCS file: /cvs/gnome/gimp/app/pdb/transform_tools_cmds.c,v retrieving revision 1.27 diff -u -p -r1.27 transform_tools_cmds.c --- app/pdb/transform_tools_cmds.c 6 Oct 2004 13:13:07 -0000 1.27 +++ app/pdb/transform_tools_cmds.c 19 Oct 2004 15:30:51 -0000 @@ -170,36 +170,39 @@ perspective_invoker (Gimp *gimp, if (success) { - gint x1, y1, x2, y2; - GimpMatrix3 matrix; - GimpInterpolationType interpolation_type; - - gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2); - - /* Assemble the transformation matrix */ - gimp_transform_matrix_perspective (x1, y1, x2, y2, - trans_info[X0], trans_info[Y0], - trans_info[X1], trans_info[Y1], - trans_info[X2], trans_info[Y2], - trans_info[X3], trans_info[Y3], - &matrix); - - if (interpolation) - interpolation_type = gimp->config->interpolation_type; - else - interpolation_type = GIMP_INTERPOLATION_NONE; - - if (progress) - gimp_progress_start (progress, _("Perspective..."), FALSE); - - /* Perspective the selection */ - success = gimp_drawable_transform_affine (drawable, context, - &matrix, GIMP_TRANSFORM_FORWARD, - interpolation_type, TRUE, 3, - FALSE, progress); + gint x, y, width, height; - if (progress) - gimp_progress_end (progress); + if (gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height)) + { + GimpMatrix3 matrix; + GimpInterpolationType interpolation_type; + + /* Assemble the transformation matrix */ + gimp_transform_matrix_perspective (x, y, x + width, y + height, + trans_info[X0], trans_info[Y0], + trans_info[X1], trans_info[Y1], + trans_info[X2], trans_info[Y2], + trans_info[X3], trans_info[Y3], + &matrix); + + if (interpolation) + interpolation_type = gimp->config->interpolation_type; + else + interpolation_type = GIMP_INTERPOLATION_NONE; + + if (progress) + gimp_progress_start (progress, _("Perspective..."), FALSE); + + /* Perspective the selection */ + success = gimp_drawable_transform_affine (drawable, context, + &matrix, + GIMP_TRANSFORM_FORWARD, + interpolation_type, TRUE, 3, + FALSE, progress); + + if (progress) + gimp_progress_end (progress); + } } } @@ -318,31 +321,35 @@ rotate_invoker (Gimp *gimp, if (success) { - gint x1, y1, x2, y2; - GimpMatrix3 matrix; - GimpInterpolationType interpolation_type; - - gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2); - - /* Assemble the transformation matrix */ - gimp_transform_matrix_rotate (x1, y1, x2, y2, angle, &matrix); - - if (interpolation) - interpolation_type = gimp->config->interpolation_type; - else - interpolation_type = GIMP_INTERPOLATION_NONE; - - if (progress) - gimp_progress_start (progress, _("Rotating..."), FALSE); - - /* Rotate the selection */ - success = gimp_drawable_transform_affine (drawable, context, - &matrix, GIMP_TRANSFORM_FORWARD, - interpolation_type, FALSE, 3, - FALSE, progress); + gint x, y, width, height; - if (progress) - gimp_progress_end (progress); + if (gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height)) + { + GimpMatrix3 matrix; + GimpInterpolationType interpolation_type; + + /* Assemble the transformation matrix */ + gimp_transform_matrix_rotate (x, y, x + width, y + height, + angle, &matrix); + + if (interpolation) + interpolation_type = gimp->config->interpolation_type; + else + interpolation_type = GIMP_INTERPOLATION_NONE; + + if (progress) + gimp_progress_start (progress, _("Rotating..."), FALSE); + + /* Rotate the selection */ + success = gimp_drawable_transform_affine (drawable, context, + &matrix, + GIMP_TRANSFORM_FORWARD, + interpolation_type, FALSE, 3, + FALSE, progress); + + if (progress) + gimp_progress_end (progress); + } } } @@ -433,34 +440,37 @@ scale_invoker (Gimp *gimp, if (success) { - gint x1, y1, x2, y2; - GimpMatrix3 matrix; - GimpInterpolationType interpolation_type; - - gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2); - - /* Assemble the transformation matrix */ - gimp_transform_matrix_scale (x1, y1, x2, y2, - trans_info[X0], trans_info[Y0], - trans_info[X1], trans_info[Y1], - &matrix); - - if (interpolation) - interpolation_type = gimp->config->interpolation_type; - else - interpolation_type = GIMP_INTERPOLATION_NONE; - - if (progress) - gimp_progress_start (progress, _("Scaling..."), FALSE); - - /* Scale the selection */ - success = gimp_drawable_transform_affine (drawable, context, - &matrix, GIMP_TRANSFORM_FORWARD, - interpolation_type, TRUE, 3, - FALSE, progress); + gint x, y, width, height; - if (progress) - gimp_progress_end (progress); + if (gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height)) + { + GimpMatrix3 matrix; + GimpInterpolationType interpolation_type; + + /* Assemble the transformation matrix */ + gimp_transform_matrix_scale (x, y, x + width, y + height, + trans_info[X0], trans_info[Y0], + trans_info[X1], trans_info[Y1], + &matrix); + + if (interpolation) + interpolation_type = gimp->config->interpolation_type; + else + interpolation_type = GIMP_INTERPOLATION_NONE; + + if (progress) + gimp_progress_start (progress, _("Scaling..."), FALSE); + + /* Scale the selection */ + success = gimp_drawable_transform_affine (drawable, context, + &matrix, + GIMP_TRANSFORM_FORWARD, + interpolation_type, TRUE, 3, + FALSE, progress); + + if (progress) + gimp_progress_end (progress); + } } } @@ -563,33 +573,36 @@ shear_invoker (Gimp *gimp, if (success) { - gint x1, y1, x2, y2; - GimpMatrix3 matrix; - GimpInterpolationType interpolation_type; - - gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2); - - /* Assemble the transformation matrix */ - gimp_transform_matrix_shear (x1, y1, x2, y2, - shear_type, magnitude, - &matrix); - - if (interpolation) - interpolation_type = gimp->config->interpolation_type; - else - interpolation_type = GIMP_INTERPOLATION_NONE; - - if (progress) - gimp_progress_start (progress, _("Shearing..."), FALSE); - - /* Shear the selection */ - success = gimp_drawable_transform_affine (drawable, context, - &matrix, GIMP_TRANSFORM_FORWARD, - interpolation_type, FALSE, 3, - FALSE, progress); + gint x, y, width, height; - if (progress) - gimp_progress_end (progress); + if (gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height)) + { + GimpMatrix3 matrix; + GimpInterpolationType interpolation_type; + + /* Assemble the transformation matrix */ + gimp_transform_matrix_shear (x, y, x + width, y + height, + shear_type, magnitude, + &matrix); + + if (interpolation) + interpolation_type = gimp->config->interpolation_type; + else + interpolation_type = GIMP_INTERPOLATION_NONE; + + if (progress) + gimp_progress_start (progress, _("Shearing..."), FALSE); + + /* Shear the selection */ + success = gimp_drawable_transform_affine (drawable, context, + &matrix, + GIMP_TRANSFORM_FORWARD, + interpolation_type, FALSE, 3, + FALSE, progress); + + if (progress) + gimp_progress_end (progress); + } } } Index: tools/pdbgen/pdb/color.pdb =================================================================== RCS file: /cvs/gnome/gimp/tools/pdbgen/pdb/color.pdb,v retrieving revision 1.49 diff -u -p -r1.49 color.pdb --- tools/pdbgen/pdb/color.pdb 3 Oct 2004 12:57:06 -0000 1.49 +++ tools/pdbgen/pdb/color.pdb 19 Oct 2004 15:30:52 -0000 @@ -48,8 +48,6 @@ HELP } %invoke = ( - vars => [ 'GimpImage *gimage', 'GimpLut *lut', - 'PixelRegion srcPR, destPR', 'int x1, y1, x2, y2' ], code => <<'CODE' { if (gimp_drawable_is_indexed (drawable)) @@ -57,27 +55,31 @@ HELP if (success) { - gimage = gimp_item_get_image (GIMP_ITEM (drawable)); - - lut = brightness_contrast_lut_new (brightness / 255.0, - contrast / 127.0, - gimp_drawable_bytes (drawable)); + gint x, y, width, height; /* The application should occur only within selection bounds */ - gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2); + if (gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height)) + { + GimpLut *lut; + PixelRegion srcPR, destPR; - pixel_region_init (&srcPR, gimp_drawable_data (drawable), - x1, y1, (x2 - x1), (y2 - y1), FALSE); - pixel_region_init (&destPR, gimp_drawable_shadow (drawable), - x1, y1, (x2 - x1), (y2 - y1), TRUE); + lut = brightness_contrast_lut_new (brightness / 255.0, + contrast / 127.0, + gimp_drawable_bytes (drawable)); - pixel_regions_process_parallel ((p_func) gimp_lut_process, lut, 2, - &srcPR, &destPR); + pixel_region_init (&srcPR, gimp_drawable_data (drawable), + x, y, width, height, FALSE); + pixel_region_init (&destPR, gimp_drawable_shadow (drawable), + x, y, width, height, TRUE); - gimp_lut_free (lut); + pixel_regions_process_parallel ((p_func) gimp_lut_process, lut, 2, + &srcPR, &destPR); - gimp_drawable_merge_shadow (drawable, TRUE, _("Brightness-Contrast")); - gimp_drawable_update (drawable, x1, y1, (x2 - x1), (y2 - y1)); + gimp_lut_free (lut); + + gimp_drawable_merge_shadow (drawable, TRUE, _("Brightness-Contrast")); + gimp_drawable_update (drawable, x, y, width, height); + } } } CODE @@ -120,8 +122,6 @@ HELP %invoke = ( headers => [ qw("base/levels.h") ], - vars => [ 'PixelRegion srcPR, destPR', 'Levels l', 'gint x1, y1, x2, y2', - 'GimpLut *lut' ], code => <<'CODE' { if (gimp_drawable_is_indexed (drawable) || @@ -133,41 +133,49 @@ HELP if (success) { - /* FIXME: hack */ - if (gimp_drawable_is_gray (drawable) && channel == GIMP_HISTOGRAM_ALPHA) - channel = 1; - - lut = gimp_lut_new (); - - levels_init (&l); - - l.low_input[channel] = low_input; - l.high_input[channel] = high_input; - l.gamma[channel] = gamma; - l.low_output[channel] = low_output; - l.high_output[channel] = high_output; - - /* setup the lut */ - gimp_lut_setup (lut, - (GimpLutFunc) levels_lut_func, - &l, - gimp_drawable_bytes (drawable)); + gint x, y, width, height; /* The application should occur only within selection bounds */ - gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2); - - pixel_region_init (&srcPR, gimp_drawable_data (drawable), - x1, y1, (x2 - x1), (y2 - y1), FALSE); - pixel_region_init (&destPR, gimp_drawable_shadow (drawable), - x1, y1, (x2 - x1), (y2 - y1), TRUE); + if (gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height)) + { + PixelRegion srcPR, destPR; + Levels l; + GimpLut *lut; + + /* FIXME: hack */ + if (gimp_drawable_is_gray (drawable) && + channel == GIMP_HISTOGRAM_ALPHA) + channel = 1; + + lut = gimp_lut_new (); + + levels_init (&l); + + l.low_input[channel] = low_input; + l.high_input[channel] = high_input; + l.gamma[channel] = gamma; + l.low_output[channel] = low_output; + l.high_output[channel] = high_output; + + /* setup the lut */ + gimp_lut_setup (lut, + (GimpLutFunc) levels_lut_func, + &l, + gimp_drawable_bytes (drawable)); + + pixel_region_init (&srcPR, gimp_drawable_data (drawable), + x, y, width, height, FALSE); + pixel_region_init (&destPR, gimp_drawable_shadow (drawable), + x, y, width, height, TRUE); - pixel_regions_process_parallel ((p_func) gimp_lut_process, lut, 2, - &srcPR, &destPR); + pixel_regions_process_parallel ((p_func) gimp_lut_process, lut, 2, + &srcPR, &destPR); - gimp_lut_free (lut); + gimp_lut_free (lut); - gimp_drawable_merge_shadow (drawable, TRUE, _("Levels")); - gimp_drawable_update (drawable, x1, y1, (x2 - x1), (y2 - y1)); + gimp_drawable_merge_shadow (drawable, TRUE, _("Levels")); + gimp_drawable_update (drawable, x, y, width, height); + } } } CODE @@ -195,12 +203,6 @@ HELP %invoke = ( headers => [ qw("base/levels.h" "base/gimphistogram.h" "core/gimpdrawable-histogram.h") ], - vars => [ 'PixelRegion srcPR, destPR', - 'Levels levels', - 'gint x1, y1, x2, y2', - 'GimpLut *lut', - 'GimpImage *image', - 'GimpHistogram *hist' ], code => <<'CODE' { if (gimp_drawable_is_indexed (drawable)) @@ -208,39 +210,46 @@ HELP if (success) { - /* Build the histogram */ - image = gimp_item_get_image (GIMP_ITEM (drawable)); - hist = gimp_histogram_new (GIMP_BASE_CONFIG (image->gimp->config)); - - gimp_drawable_calculate_histogram (drawable, hist); - - /* Calculate the levels */ - levels_init (&levels); - levels_auto (&levels, hist, ! gimp_drawable_is_gray (drawable)); - - /* Set up the lut */ - lut = gimp_lut_new (); - gimp_lut_setup (lut, - (GimpLutFunc) levels_lut_func, - &levels, - gimp_drawable_bytes (drawable)); + gint x, y, width, height; /* The application should occur only within selection bounds */ - gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2); - - pixel_region_init (&srcPR, gimp_drawable_data (drawable), - x1, y1, (x2 - x1), (y2 - y1), FALSE); - pixel_region_init (&destPR, gimp_drawable_shadow (drawable), - x1, y1, (x2 - x1), (y2 - y1), TRUE); + if (gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height)) + { + PixelRegion srcPR, destPR; + Levels levels; + GimpLut *lut; + GimpHistogram *hist; + + /* Build the histogram */ + hist = gimp_histogram_new (GIMP_BASE_CONFIG (gimp->config)); + + gimp_drawable_calculate_histogram (drawable, hist); + + /* Calculate the levels */ + levels_init (&levels); + levels_auto (&levels, hist, ! gimp_drawable_is_gray (drawable)); + + /* Set up the lut */ + lut = gimp_lut_new (); + gimp_lut_setup (lut, + (GimpLutFunc) levels_lut_func, + &levels, + gimp_drawable_bytes (drawable)); + + pixel_region_init (&srcPR, gimp_drawable_data (drawable), + x, y, width, height, FALSE); + pixel_region_init (&destPR, gimp_drawable_shadow (drawable), + x, y, width, height, TRUE); - pixel_regions_process_parallel ((p_func) gimp_lut_process, lut, 2, - &srcPR, &destPR); + pixel_regions_process_parallel ((p_func) gimp_lut_process, lut, 2, + &srcPR, &destPR); - gimp_lut_free (lut); - gimp_histogram_free (hist); + gimp_lut_free (lut); + gimp_histogram_free (hist); - gimp_drawable_merge_shadow (drawable, TRUE, _("Levels")); - gimp_drawable_update (drawable, x1, y1, (x2 - x1), (y2 - y1)); + gimp_drawable_merge_shadow (drawable, TRUE, _("Levels")); + gimp_drawable_update (drawable, x, y, width, height); + } } } CODE @@ -265,8 +274,6 @@ HELP ); %invoke = ( - vars => [ 'GimpImage *gimage', 'GimpLut *lut', - 'PixelRegion srcPR, destPR', 'int x1, y1, x2, y2' ], code => <<'CODE' { if (gimp_drawable_is_indexed (drawable)) @@ -274,25 +281,29 @@ HELP if (success) { - gimage = gimp_item_get_image (GIMP_ITEM (drawable)); - - lut = posterize_lut_new (levels, gimp_drawable_bytes (drawable)); + gint x, y, width, height; /* The application should occur only within selection bounds */ - gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2); + if (gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height)) + { + GimpLut *lut; + PixelRegion srcPR, destPR; + + lut = posterize_lut_new (levels, gimp_drawable_bytes (drawable)); - pixel_region_init (&srcPR, gimp_drawable_data (drawable), - x1, y1, (x2 - x1), (y2 - y1), FALSE); - pixel_region_init (&destPR, gimp_drawable_shadow (drawable), - x1, y1, (x2 - x1), (y2 - y1), TRUE); + pixel_region_init (&srcPR, gimp_drawable_data (drawable), + x, y, width, height, FALSE); + pixel_region_init (&destPR, gimp_drawable_shadow (drawable), + x, y, width, height, TRUE); - pixel_regions_process_parallel ((p_func) gimp_lut_process, lut, 2, - &srcPR, &destPR); + pixel_regions_process_parallel ((p_func) gimp_lut_process, lut, 2, + &srcPR, &destPR); - gimp_lut_free (lut); + gimp_lut_free (lut); - gimp_drawable_merge_shadow (drawable, TRUE, _("Posterize")); - gimp_drawable_update (drawable, x1, y1, (x2 - x1), (y2 - y1)); + gimp_drawable_merge_shadow (drawable, TRUE, _("Posterize")); + gimp_drawable_update (drawable, x, y, width, height); + } } } CODE @@ -411,8 +422,6 @@ HELP %invoke = ( headers => [ qw("base/curves.h") ], - vars => [ 'Curves c', 'gint x1, y1, x2, y2', 'gint j', - 'PixelRegion srcPR, destPR', 'GimpLut *lut' ], code => <<'CODE' { if (gimp_drawable_is_indexed (drawable) || (num_points & 1) || @@ -424,46 +433,55 @@ HELP if (success) { - /* FIXME: hack */ - if (gimp_drawable_is_gray (drawable) && channel == GIMP_HISTOGRAM_ALPHA) - channel = 1; - - lut = gimp_lut_new (); - - curves_init (&c); - - /* unset the last point */ - c.points[channel][CURVES_NUM_POINTS - 1][0] = -1; - c.points[channel][CURVES_NUM_POINTS - 1][1] = -1; - - for (j = 0; j < num_points / 2; j++) - { - c.points[channel][j][0] = control_pts[j * 2]; - c.points[channel][j][1] = control_pts[j * 2 + 1]; - } + gint x, y, width, height; + + /* The application should occur only within selection bounds */ + if (gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height)) + { + Curves c; + gint j; + PixelRegion srcPR, destPR; + GimpLut *lut; - curves_calculate_curve (&c, channel); + /* FIXME: hack */ + if (gimp_drawable_is_gray (drawable) && + channel == GIMP_HISTOGRAM_ALPHA) + channel = 1; - gimp_lut_setup (lut, - (GimpLutFunc) curves_lut_func, - &c, - gimp_drawable_bytes (drawable)); + lut = gimp_lut_new (); - /* The application should occur only within selection bounds */ - gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2); + curves_init (&c); - pixel_region_init (&srcPR, gimp_drawable_data (drawable), - x1, y1, (x2 - x1), (y2 - y1), FALSE); - pixel_region_init (&destPR, gimp_drawable_shadow (drawable), - x1, y1, (x2 - x1), (y2 - y1), TRUE); + /* unset the last point */ + c.points[channel][CURVES_NUM_POINTS - 1][0] = -1; + c.points[channel][CURVES_NUM_POINTS - 1][1] = -1; - pixel_regions_process_parallel ((p_func) gimp_lut_process, lut, 2, - &srcPR, &destPR); + for (j = 0; j < num_points / 2; j++) + { + c.points[channel][j][0] = control_pts[j * 2]; + c.points[channel][j][1] = control_pts[j * 2 + 1]; + } - gimp_lut_free (lut); + curves_calculate_curve (&c, channel); - gimp_drawable_merge_shadow (drawable, TRUE, _("Curves")); - gimp_drawable_update (drawable, x1, y1, (x2 - x1), (y2 - y1)); + gimp_lut_setup (lut, + (GimpLutFunc) curves_lut_func, + &c, + gimp_drawable_bytes (drawable)); + + pixel_region_init (&srcPR, gimp_drawable_data (drawable), + x, y, width, height, FALSE); + pixel_region_init (&destPR, gimp_drawable_shadow (drawable), + x, y, width, height, TRUE); + + pixel_regions_process_parallel ((p_func) gimp_lut_process, lut, 2, + &srcPR, &destPR); + + gimp_lut_free (lut); + + gimp_drawable_merge_shadow (drawable, TRUE, _("Curves")); + gimp_drawable_update (drawable, x, y, width, height); + } } } CODE @@ -496,8 +514,6 @@ HELP %invoke = ( headers => [ qw("base/curves.h") ], - vars => [ 'Curves c', 'gint x1, y1, x2, y2', 'gint j', - 'PixelRegion srcPR, destPR', 'GimpLut *lut' ], code => <<'CODE' { if (gimp_drawable_is_indexed (drawable) || (num_bytes != 256) || @@ -509,37 +525,46 @@ HELP if (success) { - /* FIXME: hack */ - if (gimp_drawable_is_gray (drawable) && channel == GIMP_HISTOGRAM_ALPHA) - channel = 1; - - lut = gimp_lut_new (); + gint x, y, width, height; - curves_init (&c); - - for (j = 0; j < 256; j++) - c.curve[channel][j] = curve[j]; - - gimp_lut_setup (lut, - (GimpLutFunc) curves_lut_func, - &c, - gimp_drawable_bytes (drawable)); - /* The application should occur only within selection bounds */ - gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2); - - pixel_region_init (&srcPR, gimp_drawable_data (drawable), - x1, y1, (x2 - x1), (y2 - y1), FALSE); - pixel_region_init (&destPR, gimp_drawable_shadow (drawable), - x1, y1, (x2 - x1), (y2 - y1), TRUE); + if (gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height)) + { + Curves c; + gint j; + PixelRegion srcPR, destPR; + GimpLut *lut; + + /* FIXME: hack */ + if (gimp_drawable_is_gray (drawable) && + channel == GIMP_HISTOGRAM_ALPHA) + channel = 1; + + lut = gimp_lut_new (); + + curves_init (&c); + + for (j = 0; j < 256; j++) + c.curve[channel][j] = curve[j]; + + gimp_lut_setup (lut, + (GimpLutFunc) curves_lut_func, + &c, + gimp_drawable_bytes (drawable)); + + pixel_region_init (&srcPR, gimp_drawable_data (drawable), + x, y, width, height, FALSE); + pixel_region_init (&destPR, gimp_drawable_shadow (drawable), + x, y, width, height, TRUE); - pixel_regions_process_parallel ((p_func) gimp_lut_process, lut, 2, - &srcPR, &destPR); + pixel_regions_process_parallel ((p_func) gimp_lut_process, lut, 2, + &srcPR, &destPR); - gimp_lut_free (lut); + gimp_lut_free (lut); - gimp_drawable_merge_shadow (drawable, TRUE, _("Curves")); - gimp_drawable_update (drawable, x1, y1, (x2 - x1), (y2 - y1)); + gimp_drawable_merge_shadow (drawable, TRUE, _("Curves")); + gimp_drawable_update (drawable, x, y, width, height); + } } } CODE @@ -579,8 +604,6 @@ HELP %invoke = ( headers => [ qw("base/color-balance.h") ], - vars => [ 'ColorBalance cb', 'PixelRegionIterator *pr', - 'PixelRegion srcPR, destPR', 'gint x1, y1, x2, y2' ], code => <<'CODE' { if (gimp_drawable_is_indexed (drawable)) @@ -588,33 +611,40 @@ HELP if (success) { - color_balance_init (&cb); - - cb.preserve_luminosity = preserve_lum; - - cb.cyan_red[transfer_mode] = cyan_red; - cb.magenta_green[transfer_mode] = magenta_green; - cb.yellow_blue[transfer_mode] = yellow_blue; - - color_balance_create_lookup_tables (&cb); + gint x, y, width, height; /* The application should occur only within selection bounds */ - gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2); - - pixel_region_init (&srcPR, gimp_drawable_data (drawable), - x1, y1, (x2 - x1), (y2 - y1), FALSE); - pixel_region_init (&destPR, gimp_drawable_shadow (drawable), - x1, y1, (x2 - x1), (y2 - y1), TRUE); - - for (pr = pixel_regions_register (2, &srcPR, &destPR); - pr; - pr = pixel_regions_process (pr)) + if (gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height)) { - color_balance (&srcPR, &destPR, &cb); - } + ColorBalance cb; + PixelRegionIterator *pr; + PixelRegion srcPR, destPR; + + color_balance_init (&cb); + + cb.preserve_luminosity = preserve_lum; + + cb.cyan_red[transfer_mode] = cyan_red; + cb.magenta_green[transfer_mode] = magenta_green; + cb.yellow_blue[transfer_mode] = yellow_blue; + + color_balance_create_lookup_tables (&cb); + + pixel_region_init (&srcPR, gimp_drawable_data (drawable), + x, y, width, height, FALSE); + pixel_region_init (&destPR, gimp_drawable_shadow (drawable), + x, y, width, height, TRUE); + + for (pr = pixel_regions_register (2, &srcPR, &destPR); + pr; + pr = pixel_regions_process (pr)) + { + color_balance (&srcPR, &destPR, &cb); + } - gimp_drawable_merge_shadow (drawable, TRUE, _("Color Balance")); - gimp_drawable_update (drawable, x1, y1, (x2 - x1), (y2 - y1)); + gimp_drawable_merge_shadow (drawable, TRUE, _("Color Balance")); + gimp_drawable_update (drawable, x, y, width, height); + } } } CODE @@ -646,8 +676,6 @@ HELP %invoke = ( headers => [ qw("base/colorize.h") ], - vars => [ 'Colorize colors', 'PixelRegionIterator *pr', - 'PixelRegion srcPR, destPR', 'gint x1, y1, x2, y2' ], code => <<'CODE' { if (! gimp_drawable_is_rgb (drawable)) @@ -655,31 +683,38 @@ HELP if (success) { - colorize_init (&colors); - - colors.hue = hue; - colors.saturation = saturation; - colors.lightness = lightness; - - colorize_calculate (&colors); + gint x, y, width, height; /* The application should occur only within selection bounds */ - gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2); - - pixel_region_init (&srcPR, gimp_drawable_data (drawable), - x1, y1, (x2 - x1), (y2 - y1), FALSE); - pixel_region_init (&destPR, gimp_drawable_shadow (drawable), - x1, y1, (x2 - x1), (y2 - y1), TRUE); - - for (pr = pixel_regions_register (2, &srcPR, &destPR); - pr; - pr = pixel_regions_process (pr)) + if (gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height)) { - colorize (&srcPR, &destPR, &colors); - } + Colorize colors; + PixelRegionIterator *pr; + PixelRegion srcPR, destPR; + + colorize_init (&colors); + + colors.hue = hue; + colors.saturation = saturation; + colors.lightness = lightness; + + colorize_calculate (&colors); + + pixel_region_init (&srcPR, gimp_drawable_data (drawable), + x, y, width, height, FALSE); + pixel_region_init (&destPR, gimp_drawable_shadow (drawable), + x, y, width, height, TRUE); + + for (pr = pixel_regions_register (2, &srcPR, &destPR); + pr; + pr = pixel_regions_process (pr)) + { + colorize (&srcPR, &destPR, &colors); + } - gimp_drawable_merge_shadow (drawable, TRUE, _("Colorize")); - gimp_drawable_update (drawable, x1, y1, (x2 - x1), (y2 - y1)); + gimp_drawable_merge_shadow (drawable, TRUE, _("Colorize")); + gimp_drawable_update (drawable, x, y, width, height); + } } } CODE @@ -803,8 +838,6 @@ HELP %invoke = ( headers => [ qw("base/hue-saturation.h") ], - vars => [ 'HueSaturation hs', 'PixelRegionIterator *pr', - 'PixelRegion srcPR, destPR', 'gint x1, y1, x2, y2' ], code => <<'CODE' { if (gimp_drawable_is_indexed (drawable)) @@ -812,32 +845,39 @@ HELP if (success) { - hue_saturation_init (&hs); - - hs.hue[hue_range] = hue_offset; - hs.lightness[hue_range] = lightness; - hs.saturation[hue_range] = saturation; - - /* Calculate the transfer arrays */ - hue_saturation_calculate_transfers (&hs); + gint x, y, width, height; /* The application should occur only within selection bounds */ - gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2); - - pixel_region_init (&srcPR, gimp_drawable_data (drawable), - x1, y1, (x2 - x1), (y2 - y1), FALSE); - pixel_region_init (&destPR, gimp_drawable_shadow (drawable), - x1, y1, (x2 - x1), (y2 - y1), TRUE); - - for (pr = pixel_regions_register (2, &srcPR, &destPR); - pr; - pr = pixel_regions_process (pr)) + if (gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height)) { - hue_saturation (&srcPR, &destPR, &hs); - } + HueSaturation hs; + PixelRegionIterator *pr; + PixelRegion srcPR, destPR; + + hue_saturation_init (&hs); + + hs.hue[hue_range] = hue_offset; + hs.lightness[hue_range] = lightness; + hs.saturation[hue_range] = saturation; + + /* Calculate the transfer arrays */ + hue_saturation_calculate_transfers (&hs); + + pixel_region_init (&srcPR, gimp_drawable_data (drawable), + x, y, width, height, FALSE); + pixel_region_init (&destPR, gimp_drawable_shadow (drawable), + x, y, width, height, TRUE); + + for (pr = pixel_regions_register (2, &srcPR, &destPR); + pr; + pr = pixel_regions_process (pr)) + { + hue_saturation (&srcPR, &destPR, &hs); + } - gimp_drawable_merge_shadow (drawable, TRUE, _("Hue-Saturation")); - gimp_drawable_update (drawable, x1, y1, (x2 - x1), (y2 - y1)); + gimp_drawable_merge_shadow (drawable, TRUE, _("Hue-Saturation")); + gimp_drawable_update (drawable, x, y, width, height); + } } } CODE @@ -864,8 +904,6 @@ HELP %invoke = ( headers => [ qw("base/threshold.h") ], - vars => [ 'Threshold tr', 'gint x1, y1, x2, y2', - 'PixelRegion srcPR, destPR' ], code => <<'CODE' { if (gimp_drawable_is_indexed (drawable) || (low_threshold >= high_threshold)) @@ -873,23 +911,29 @@ HELP if (success) { - tr.color = gimp_drawable_is_rgb (drawable); - tr.low_threshold = low_threshold; - tr.high_threshold = high_threshold; + gint x, y, width, height; /* The application should occur only within selection bounds */ - gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2); + if (gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height)) + { + Threshold tr; + PixelRegion srcPR, destPR; - pixel_region_init (&srcPR, gimp_drawable_data (drawable), - x1, y1, (x2 - x1), (y2 - y1), FALSE); - pixel_region_init (&destPR, gimp_drawable_shadow (drawable), - x1, y1, (x2 - x1), (y2 - y1), TRUE); + tr.color = gimp_drawable_is_rgb (drawable); + tr.low_threshold = low_threshold; + tr.high_threshold = high_threshold; + + pixel_region_init (&srcPR, gimp_drawable_data (drawable), + x, y, width, height, FALSE); + pixel_region_init (&destPR, gimp_drawable_shadow (drawable), + x, y, width, height, TRUE); - pixel_regions_process_parallel ((p_func) threshold_2, &tr, 2, - &srcPR, &destPR); + pixel_regions_process_parallel ((p_func) threshold_2, &tr, 2, + &srcPR, &destPR); - gimp_drawable_merge_shadow (drawable, TRUE, _("Threshold")); - gimp_drawable_update (drawable, x1, y1, (x2 - x1), (y2 - y1)); + gimp_drawable_merge_shadow (drawable, TRUE, _("Threshold")); + gimp_drawable_update (drawable, x, y, width, height); + } } } CODE Index: tools/pdbgen/pdb/transform_tools.pdb =================================================================== RCS file: /cvs/gnome/gimp/tools/pdbgen/pdb/transform_tools.pdb,v retrieving revision 1.68 diff -u -p -r1.68 transform_tools.pdb --- tools/pdbgen/pdb/transform_tools.pdb 31 Aug 2004 14:17:33 -0000 1.68 +++ tools/pdbgen/pdb/transform_tools.pdb 19 Oct 2004 15:30:52 -0000 @@ -130,36 +130,39 @@ HELP if (success) { - gint x1, y1, x2, y2; - GimpMatrix3 matrix; - GimpInterpolationType interpolation_type; - - gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2); - - /* Assemble the transformation matrix */ - gimp_transform_matrix_perspective (x1, y1, x2, y2, - trans_info[X0], trans_info[Y0], - trans_info[X1], trans_info[Y1], - trans_info[X2], trans_info[Y2], - trans_info[X3], trans_info[Y3], - &matrix); - - if (interpolation) - interpolation_type = gimp->config->interpolation_type; - else - interpolation_type = GIMP_INTERPOLATION_NONE; - - if (progress) - gimp_progress_start (progress, _("Perspective..."), FALSE); - - /* Perspective the selection */ - success = gimp_drawable_transform_affine (drawable, context, - &matrix, GIMP_TRANSFORM_FORWARD, - interpolation_type, TRUE, 3, - FALSE, progress); + gint x, y, width, height; - if (progress) - gimp_progress_end (progress); + if (gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height)) + { + GimpMatrix3 matrix; + GimpInterpolationType interpolation_type; + + /* Assemble the transformation matrix */ + gimp_transform_matrix_perspective (x, y, x + width, y + height, + trans_info[X0], trans_info[Y0], + trans_info[X1], trans_info[Y1], + trans_info[X2], trans_info[Y2], + trans_info[X3], trans_info[Y3], + &matrix); + + if (interpolation) + interpolation_type = gimp->config->interpolation_type; + else + interpolation_type = GIMP_INTERPOLATION_NONE; + + if (progress) + gimp_progress_start (progress, _("Perspective..."), FALSE); + + /* Perspective the selection */ + success = gimp_drawable_transform_affine (drawable, context, + &matrix, + GIMP_TRANSFORM_FORWARD, + interpolation_type, TRUE, 3, + FALSE, progress); + + if (progress) + gimp_progress_end (progress); + } } } CODE @@ -201,31 +204,35 @@ HELP if (success) { - gint x1, y1, x2, y2; - GimpMatrix3 matrix; - GimpInterpolationType interpolation_type; - - gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2); - - /* Assemble the transformation matrix */ - gimp_transform_matrix_rotate (x1, y1, x2, y2, angle, &matrix); - - if (interpolation) - interpolation_type = gimp->config->interpolation_type; - else - interpolation_type = GIMP_INTERPOLATION_NONE; - - if (progress) - gimp_progress_start (progress, _("Rotating..."), FALSE); - - /* Rotate the selection */ - success = gimp_drawable_transform_affine (drawable, context, - &matrix, GIMP_TRANSFORM_FORWARD, - interpolation_type, FALSE, 3, - FALSE, progress); + gint x, y, width, height; - if (progress) - gimp_progress_end (progress); + if (gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height)) + { + GimpMatrix3 matrix; + GimpInterpolationType interpolation_type; + + /* Assemble the transformation matrix */ + gimp_transform_matrix_rotate (x, y, x + width, y + height, + angle, &matrix); + + if (interpolation) + interpolation_type = gimp->config->interpolation_type; + else + interpolation_type = GIMP_INTERPOLATION_NONE; + + if (progress) + gimp_progress_start (progress, _("Rotating..."), FALSE); + + /* Rotate the selection */ + success = gimp_drawable_transform_affine (drawable, context, + &matrix, + GIMP_TRANSFORM_FORWARD, + interpolation_type, FALSE, 3, + FALSE, progress); + + if (progress) + gimp_progress_end (progress); + } } } CODE @@ -278,34 +285,37 @@ HELP if (success) { - gint x1, y1, x2, y2; - GimpMatrix3 matrix; - GimpInterpolationType interpolation_type; - - gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2); - - /* Assemble the transformation matrix */ - gimp_transform_matrix_scale (x1, y1, x2, y2, - trans_info[X0], trans_info[Y0], - trans_info[X1], trans_info[Y1], - &matrix); - - if (interpolation) - interpolation_type = gimp->config->interpolation_type; - else - interpolation_type = GIMP_INTERPOLATION_NONE; - - if (progress) - gimp_progress_start (progress, _("Scaling..."), FALSE); - - /* Scale the selection */ - success = gimp_drawable_transform_affine (drawable, context, - &matrix, GIMP_TRANSFORM_FORWARD, - interpolation_type, TRUE, 3, - FALSE, progress); + gint x, y, width, height; - if (progress) - gimp_progress_end (progress); + if (gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height)) + { + GimpMatrix3 matrix; + GimpInterpolationType interpolation_type; + + /* Assemble the transformation matrix */ + gimp_transform_matrix_scale (x, y, x + width, y + height, + trans_info[X0], trans_info[Y0], + trans_info[X1], trans_info[Y1], + &matrix); + + if (interpolation) + interpolation_type = gimp->config->interpolation_type; + else + interpolation_type = GIMP_INTERPOLATION_NONE; + + if (progress) + gimp_progress_start (progress, _("Scaling..."), FALSE); + + /* Scale the selection */ + success = gimp_drawable_transform_affine (drawable, context, + &matrix, + GIMP_TRANSFORM_FORWARD, + interpolation_type, TRUE, 3, + FALSE, progress); + + if (progress) + gimp_progress_end (progress); + } } } CODE @@ -352,33 +362,36 @@ HELP if (success) { - gint x1, y1, x2, y2; - GimpMatrix3 matrix; - GimpInterpolationType interpolation_type; - - gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2); - - /* Assemble the transformation matrix */ - gimp_transform_matrix_shear (x1, y1, x2, y2, - shear_type, magnitude, - &matrix); - - if (interpolation) - interpolation_type = gimp->config->interpolation_type; - else - interpolation_type = GIMP_INTERPOLATION_NONE; - - if (progress) - gimp_progress_start (progress, _("Shearing..."), FALSE); - - /* Shear the selection */ - success = gimp_drawable_transform_affine (drawable, context, - &matrix, GIMP_TRANSFORM_FORWARD, - interpolation_type, FALSE, 3, - FALSE, progress); + gint x, y, width, height; - if (progress) - gimp_progress_end (progress); + if (gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height)) + { + GimpMatrix3 matrix; + GimpInterpolationType interpolation_type; + + /* Assemble the transformation matrix */ + gimp_transform_matrix_shear (x, y, x + width, y + height, + shear_type, magnitude, + &matrix); + + if (interpolation) + interpolation_type = gimp->config->interpolation_type; + else + interpolation_type = GIMP_INTERPOLATION_NONE; + + if (progress) + gimp_progress_start (progress, _("Shearing..."), FALSE); + + /* Shear the selection */ + success = gimp_drawable_transform_affine (drawable, context, + &matrix, + GIMP_TRANSFORM_FORWARD, + interpolation_type, FALSE, 3, + FALSE, progress); + + if (progress) + gimp_progress_end (progress); + } } } CODE