Index: app/paint/gimpclone.c =================================================================== RCS file: /cvs/gnome/gimp/app/paint/gimpclone.c,v retrieving revision 1.137 diff -u -p -r1.137 gimpclone.c --- app/paint/gimpclone.c 8 Sep 2006 15:15:57 -0000 1.137 +++ app/paint/gimpclone.c 9 Sep 2006 17:39:15 -0000 @@ -68,7 +68,7 @@ static void gimp_clone_motion (G static void gimp_clone_line_image (GimpImage *dest, GimpImage *src, GimpDrawable *d_drawable, - GimpPickable *s_pickable, + GimpImageType src_type, guchar *s, guchar *d, gint src_bytes, @@ -164,6 +164,7 @@ gimp_clone_motion (GimpSourceCore *sou GimpContext *context = GIMP_CONTEXT (paint_options); GimpImage *src_image; GimpImage *image; + GimpImageType src_type; gpointer pr = NULL; gint y; PixelRegion destPR; @@ -172,6 +173,11 @@ gimp_clone_motion (GimpSourceCore *sou src_image = gimp_pickable_get_image (src_pickable); image = gimp_item_get_image (GIMP_ITEM (drawable)); + src_type = gimp_pickable_get_image_type (src_pickable); + + if (gimp_pickable_get_bytes (src_pickable) < srcPR->bytes) + src_type = GIMP_IMAGE_TYPE_WITH_ALPHA (src_type); + /* configure the destination */ switch (options->clone_type) { @@ -207,7 +213,7 @@ gimp_clone_motion (GimpSourceCore *sou { case GIMP_IMAGE_CLONE: gimp_clone_line_image (image, src_image, - drawable, src_pickable, + drawable, src_type, s, d, srcPR->bytes, destPR.bytes, destPR.w); s += srcPR->rowstride; @@ -247,15 +253,15 @@ gimp_clone_motion (GimpSourceCore *sou } static void -gimp_clone_line_image (GimpImage *dest, - GimpImage *src, - GimpDrawable *d_drawable, - GimpPickable *s_pickable, - guchar *s, - guchar *d, - gint src_bytes, - gint dest_bytes, - gint width) +gimp_clone_line_image (GimpImage *dest, + GimpImage *src, + GimpDrawable *d_drawable, + GimpImageType src_type, + guchar *s, + guchar *d, + gint src_bytes, + gint dest_bytes, + gint width) { guchar rgba[MAX_CHANNELS]; gint alpha; @@ -264,8 +270,7 @@ gimp_clone_line_image (GimpImage *des while (width--) { - gimp_image_get_color (src, gimp_pickable_get_image_type (s_pickable), - s, rgba); + gimp_image_get_color (src, src_type, s, rgba); gimp_image_transform_color (dest, d_drawable, d, GIMP_RGB, rgba); d[alpha] = rgba[ALPHA_PIX]; Index: app/paint/gimpperspectiveclone.c =================================================================== RCS file: /cvs/gnome/gimp/app/paint/gimpperspectiveclone.c,v retrieving revision 1.4 diff -u -p -r1.4 gimpperspectiveclone.c --- app/paint/gimpperspectiveclone.c 8 Sep 2006 15:15:58 -0000 1.4 +++ app/paint/gimpperspectiveclone.c 9 Sep 2006 17:39:15 -0000 @@ -53,57 +53,32 @@ #define MAX4(a,b,c,d) MAX(MAX(a,b),MAX(c,d)) -enum -{ - PROP_0, - PROP_SRC_DRAWABLE, - PROP_SRC_X, - PROP_SRC_Y -}; - - -static void gimp_perspective_clone_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec); -static void gimp_perspective_clone_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec); - -static void gimp_perspective_clone_paint (GimpPaintCore *paint_core, - GimpDrawable *drawable, - GimpPaintOptions *paint_options, - GimpPaintState paint_state, - guint32 time); -static void gimp_perspective_clone_motion (GimpPaintCore *paint_core, - GimpDrawable *drawable, - GimpPaintOptions *paint_options); - -static void gimp_perspective_clone_line_image (GimpImage *dest, - GimpImage *src, - GimpDrawable *d_drawable, - GimpPickable *s_pickable, - guchar *s, - guchar *d, - gint src_bytes, - gint dest_bytes, - gint width); -static void gimp_perspective_clone_line_pattern (GimpImage *dest, - GimpDrawable *drawable, - GimpPattern *pattern, - guchar *d, - gint x, - gint y, - gint bytes, - gint width); +static void gimp_perspective_clone_finalize (GObject *object); -static void gimp_perspective_clone_set_src_drawable (GimpPerspectiveClone *clone, - GimpDrawable *drawable); +static void gimp_perspective_clone_paint (GimpPaintCore *paint_core, + GimpDrawable *drawable, + GimpPaintOptions *paint_options, + GimpPaintState paint_state, + guint32 time); + +static gboolean gimp_perspective_clone_get_source (GimpSourceCore *source_core, + GimpDrawable *drawable, + GimpPaintOptions *paint_options, + GimpPickable *src_pickable, + gint src_offset_x, + gint src_offset_y, + TempBuf *paint_area, + gint *paint_area_offset_x, + gint *paint_area_offset_y, + gint *paint_area_width, + gint *paint_area_height, + PixelRegion *srcPR); G_DEFINE_TYPE (GimpPerspectiveClone, gimp_perspective_clone, - GIMP_TYPE_BRUSH_CORE) + GIMP_TYPE_CLONE) + +#define parent_class gimp_perspective_clone_parent_class void @@ -121,113 +96,45 @@ gimp_perspective_clone_register (Gimp static void gimp_perspective_clone_class_init (GimpPerspectiveCloneClass *klass) { - GObjectClass *object_class = G_OBJECT_CLASS (klass); - GimpPaintCoreClass *paint_core_class = GIMP_PAINT_CORE_CLASS (klass); - GimpBrushCoreClass *brush_core_class = GIMP_BRUSH_CORE_CLASS (klass); - - object_class->set_property = gimp_perspective_clone_set_property; - object_class->get_property = gimp_perspective_clone_get_property; - - paint_core_class->paint = gimp_perspective_clone_paint; - - brush_core_class->handles_changing_brush = TRUE; - - g_object_class_install_property (object_class, PROP_SRC_DRAWABLE, - g_param_spec_object ("src-drawable", - NULL, NULL, - GIMP_TYPE_DRAWABLE, - GIMP_PARAM_READWRITE)); - - g_object_class_install_property (object_class, PROP_SRC_X, - g_param_spec_double ("src-x", NULL, NULL, - 0, GIMP_MAX_IMAGE_SIZE, - 0.0, - GIMP_PARAM_READWRITE)); - - g_object_class_install_property (object_class, PROP_SRC_Y, - g_param_spec_double ("src-y", NULL, NULL, - 0, GIMP_MAX_IMAGE_SIZE, - 0.0, - GIMP_PARAM_READWRITE)); + GObjectClass *object_class = G_OBJECT_CLASS (klass); + GimpPaintCoreClass *paint_core_class = GIMP_PAINT_CORE_CLASS (klass); + GimpSourceCoreClass *source_core_class = GIMP_SOURCE_CORE_CLASS (klass); + + object_class->finalize = gimp_perspective_clone_finalize; + + paint_core_class->paint = gimp_perspective_clone_paint; + + source_core_class->get_source = gimp_perspective_clone_get_source; } static void gimp_perspective_clone_init (GimpPerspectiveClone *clone) { - clone->set_source = FALSE; - - clone->src_drawable = NULL; - clone->src_x = 0.0; - clone->src_y = 0.0; - - clone->orig_src_x = 0.0; - clone->orig_src_y = 0.0; + clone->dest_x = 0.0; /* coords where the stroke starts */ + clone->dest_y = 0.0; - clone->dest_x = 0.0; /* coords where the stroke starts */ - clone->dest_y = 0.0; + clone->src_x_fv = 0.0; /* source coords in front_view perspective */ + clone->src_y_fv = 0.0; - clone->src_x_fv = 0.0; /* source coords in front_view perspective */ - clone->src_y_fv = 0.0; - - clone->dest_x_fv = 0.0; /* destination coords in front_view perspective */ - clone->dest_y_fv = 0.0; - - clone->offset_x = 0.0; /* offset from the source to the stroke that's being painted */ - clone->offset_y = 0.0; - clone->first_stroke = TRUE; + clone->dest_x_fv = 0.0; /* destination coords in front_view perspective */ + clone->dest_y_fv = 0.0; gimp_matrix3_identity (&clone->transform); gimp_matrix3_identity (&clone->transform_inv); } static void -gimp_perspective_clone_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec) +gimp_perspective_clone_finalize (GObject *object) { GimpPerspectiveClone *clone = GIMP_PERSPECTIVE_CLONE (object); - switch (property_id) + if (clone->src_area) { - case PROP_SRC_DRAWABLE: - gimp_perspective_clone_set_src_drawable (clone, g_value_get_object (value)); - break; - case PROP_SRC_X: - clone->src_x = g_value_get_double (value); - break; - case PROP_SRC_Y: - clone->src_y = g_value_get_double (value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - break; + temp_buf_free (clone->src_area); + clone->src_area = NULL; } -} -static void -gimp_perspective_clone_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) -{ - GimpPerspectiveClone *clone = GIMP_PERSPECTIVE_CLONE (object); - - switch (property_id) - { - case PROP_SRC_DRAWABLE: - g_value_set_object (value, clone->src_drawable); - break; - case PROP_SRC_X: - g_value_set_int (value, clone->src_x); - break; - case PROP_SRC_Y: - g_value_set_int (value, clone->src_y); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - break; - } + G_OBJECT_CLASS (parent_class)->finalize (object); } static void @@ -237,54 +144,60 @@ gimp_perspective_clone_paint (GimpPaintC GimpPaintState paint_state, guint32 time) { - GimpPerspectiveClone *clone = GIMP_PERSPECTIVE_CLONE (paint_core); - GimpPerspectiveCloneOptions *options = GIMP_PERSPECTIVE_CLONE_OPTIONS (paint_options); - GimpContext *context = GIMP_CONTEXT (paint_options); + GimpSourceCore *source_core = GIMP_SOURCE_CORE (paint_core); + GimpPerspectiveClone *clone = GIMP_PERSPECTIVE_CLONE (paint_core); + GimpSourceOptions *options = GIMP_SOURCE_OPTIONS (paint_options); + GimpCloneOptions *clone_options = GIMP_CLONE_OPTIONS (paint_options); + GimpContext *context = GIMP_CONTEXT (paint_options); switch (paint_state) { case GIMP_PAINT_STATE_INIT: - if (clone->set_source) + if (source_core->set_source) { - gimp_perspective_clone_set_src_drawable (clone, drawable); + g_object_set (source_core, "src-drawable", drawable, NULL); - clone->src_x = paint_core->cur_coords.x; - clone->src_y = paint_core->cur_coords.y; + source_core->src_x = paint_core->cur_coords.x; + source_core->src_y = paint_core->cur_coords.y; /* get source coordinates in front view perspective */ gimp_matrix3_transform_point (&clone->transform_inv, - clone->src_x, clone->src_y, - &clone->src_x_fv, &clone->src_y_fv); + source_core->src_x, + source_core->src_y, + &clone->src_x_fv, + &clone->src_y_fv); - clone->first_stroke = TRUE; + source_core->first_stroke = TRUE; } else if (options->align_mode == GIMP_SOURCE_ALIGN_NO) { - clone->orig_src_x = clone->src_x; - clone->orig_src_y = clone->src_y; + source_core->orig_src_x = source_core->src_x; + source_core->orig_src_y = source_core->src_y; - clone->first_stroke = TRUE; + source_core->first_stroke = TRUE; } - if (options->clone_type == GIMP_PATTERN_CLONE) + if (clone_options->clone_type == GIMP_PATTERN_CLONE) if (! gimp_context_get_pattern (context)) g_message (_("No patterns available for this operation.")); break; case GIMP_PAINT_STATE_MOTION: - if (clone->set_source) + if (source_core->set_source) { /* If the control key is down, move the src target and return */ - clone->src_x = paint_core->cur_coords.x; /* coords where the stroke starts */ - clone->src_y = paint_core->cur_coords.y; + source_core->src_x = paint_core->cur_coords.x; + source_core->src_y = paint_core->cur_coords.y; /* get source coordinates in front view perspective */ gimp_matrix3_transform_point (&clone->transform_inv, - clone->src_x, clone->src_y, - &clone->src_x_fv, &clone->src_y_fv); + source_core->src_x, + source_core->src_y, + &clone->src_x_fv, + &clone->src_y_fv); - clone->first_stroke = TRUE; + source_core->first_stroke = TRUE; } else { @@ -298,31 +211,33 @@ gimp_perspective_clone_paint (GimpPaintC if (options->align_mode == GIMP_SOURCE_ALIGN_REGISTERED) { - clone->offset_x = 0; - clone->offset_y = 0; + source_core->offset_x = 0; + source_core->offset_y = 0; } else if (options->align_mode == GIMP_SOURCE_ALIGN_FIXED) { - clone->offset_x = clone->src_x - dest_x; - clone->offset_y = clone->src_y - dest_y; + source_core->offset_x = source_core->src_x - dest_x; + source_core->offset_y = source_core->src_y - dest_y; } - else if (clone->first_stroke) + else if (source_core->first_stroke) { - clone->offset_x = clone->src_x - dest_x; - clone->offset_y = clone->src_y - dest_y; + source_core->offset_x = source_core->src_x - dest_x; + source_core->offset_y = source_core->src_y - dest_y; clone->dest_x = dest_x; /* cooords where start the destination stroke */ clone->dest_y = dest_y; /* get destination coordinates in front view perspective */ gimp_matrix3_transform_point (&clone->transform_inv, - clone->dest_x, clone->dest_y, - &clone->dest_x_fv, &clone->dest_y_fv); + clone->dest_x, + clone->dest_y, + &clone->dest_x_fv, + &clone->dest_y_fv); - clone->first_stroke = FALSE; + source_core->first_stroke = FALSE; } - gimp_perspective_clone_motion (paint_core, drawable, paint_options); + gimp_source_core_motion (source_core, drawable, paint_options); } break; @@ -337,405 +252,184 @@ gimp_perspective_clone_paint (GimpPaintC g_object_notify (G_OBJECT (clone), "src-y"); } -static void -gimp_perspective_clone_motion (GimpPaintCore *paint_core, - GimpDrawable *drawable, - GimpPaintOptions *paint_options) -{ - GimpPerspectiveClone *clone = GIMP_PERSPECTIVE_CLONE (paint_core); - GimpPerspectiveCloneOptions *options = GIMP_PERSPECTIVE_CLONE_OPTIONS (paint_options); - GimpContext *context = GIMP_CONTEXT (paint_options); - GimpImage *image; - GimpImage *src_image = NULL; - GimpPickable *src_pickable = NULL; - guchar *s; - guchar *d; - TempBuf *area; - gpointer pr = NULL; - gint y; - gint x1d, y1d, x2d, y2d; /* Coordinates of the destination area to paint */ - gdouble x1s, y1s, x2s, y2s, x3s, y3s, x4s, y4s; /* Coordinates of the boundary box to copy pixels to the tempbuf and after apply perspective transform */ - gint itemp_x, itemp_y; - gint xmin, ymin, xmax, ymax; - TileManager *src_tiles; - PixelRegion srcPR, destPR, auxPR, auxPR2; - GimpPattern *pattern = NULL; - gdouble opacity; - gint offset_x; - gint offset_y; - - guchar *src_data; - guchar *dest_data; - gint i, j; - gdouble temp_x, temp_y; - - - image = gimp_item_get_image (GIMP_ITEM (drawable)); - - opacity = gimp_paint_options_get_fade (paint_options, image, - paint_core->pixel_dist); - if (opacity == 0.0) - return; - - /* make local copies because we change them */ - offset_x = clone->offset_x; - offset_y = clone->offset_y; - - /* Make sure we still have a source if we are doing image cloning */ - if (options->clone_type == GIMP_IMAGE_CLONE) - { - if (! clone->src_drawable) - return; - - src_pickable = GIMP_PICKABLE (clone->src_drawable); - src_image = gimp_pickable_get_image (src_pickable); - - if (options->sample_merged) - { - gint off_x, off_y; - - src_pickable = GIMP_PICKABLE (src_image->projection); - - /* To the offset of the layer add the offset of the layer respect the entire image*/ - gimp_item_offsets (GIMP_ITEM (clone->src_drawable), &off_x, &off_y); - - // May I delete this offset, which is it function??? - offset_x += off_x; - offset_y += off_y; - } - - gimp_pickable_flush (src_pickable); - } +static gboolean +gimp_perspective_clone_get_source (GimpSourceCore *source_core, + GimpDrawable *drawable, + GimpPaintOptions *paint_options, + GimpPickable *src_pickable, + gint src_offset_x, + gint src_offset_y, + TempBuf *paint_area, + gint *paint_area_offset_x, + gint *paint_area_offset_y, + gint *paint_area_width, + gint *paint_area_height, + PixelRegion *srcPR) +{ + GimpPerspectiveClone *clone = GIMP_PERSPECTIVE_CLONE (source_core); + GimpPaintCore *paint_core = GIMP_PAINT_CORE (source_core); + GimpSourceOptions *options = GIMP_SOURCE_OPTIONS (paint_options); + GimpImage *src_image; + GimpImage *image; + gint x1d, y1d, x2d, y2d; /* Coordinates of the destination area to paint */ + gdouble x1s, y1s, x2s, y2s, x3s, y3s, x4s, y4s; /* Coordinates of the boundary box to copy pixels to the tempbuf and after apply perspective transform */ + gint xmin, ymin, xmax, ymax; + TileManager *src_tiles; + guchar *src_data; + guchar *dest_data; + gint i, j; + TempBuf *orig; + + src_image = gimp_pickable_get_image (src_pickable); + image = gimp_item_get_image (GIMP_ITEM (drawable)); + + src_tiles = gimp_pickable_get_tiles (src_pickable); + + /* Destination coordinates that will be painted */ + x1d = paint_area->x; + y1d = paint_area->y; + x2d = paint_area->x + paint_area->width; + y2d = paint_area->y + paint_area->height; + + /* Boundary box for source pixels to copy: Convert all the vertex of + * the box to paint in destination area to its correspondent in + * source area bearing in mind perspective + */ + gimp_perspective_clone_get_source_point (clone, x1d, y1d, &x1s, &y1s); + gimp_perspective_clone_get_source_point (clone, x1d, y2d, &x2s, &y2s); + gimp_perspective_clone_get_source_point (clone, x2d, y1d, &x3s, &y3s); + gimp_perspective_clone_get_source_point (clone, x2d, y2d, &x4s, &y4s); + + xmin = floor (MIN4 (x1s, x2s, x3s, x4s)); + ymin = floor (MIN4 (y1s, y2s, y3s, y4s)); + xmax = ceil (MAX4 (x1s, x2s, x3s, x4s)); + ymax = ceil (MAX4 (y1s, y2s, y3s, y4s)); + + xmin = CLAMP (xmin - 1, 0, tile_manager_width (src_tiles)); + ymin = CLAMP (ymin - 1, 0, tile_manager_height (src_tiles)); + xmax = CLAMP (xmax + 1, 0, tile_manager_width (src_tiles)); + ymax = CLAMP (ymax + 1, 0, tile_manager_height (src_tiles)); + + /* if the source area is completely out of the image */ + if (!(xmax - xmin) || !(ymax - ymin)) + return FALSE; + + /* get the original image */ + if (options->sample_merged) + orig = gimp_paint_core_get_orig_proj (paint_core, + src_pickable, + xmin, ymin, xmax, ymax); + else + orig = gimp_paint_core_get_orig_image (paint_core, + GIMP_DRAWABLE (src_pickable), + xmin, ymin, xmax, ymax); + + /* note: orig is a TempBuf where are all the pixels that I need to copy */ + /* copy from orig to temp_buf, this buffer has the size of the destination area */ + + /* Also allocate memory for alpha channel */ + clone->src_area = temp_buf_resize (clone->src_area, + orig->bytes + 1, /* FIXME */ + 0, 0, + x2d - x1d, y2d - y1d); - area = gimp_paint_core_get_paint_area (paint_core, drawable, paint_options); - if (! area) - return; + src_data = temp_buf_data (orig); + dest_data = temp_buf_data (clone->src_area); - switch (options->clone_type) + for (i = x1d; i < x2d; i++) { - TempBuf *orig, *temp_buf; - - case GIMP_IMAGE_CLONE: - /* Set the paint area to transparent */ - temp_buf_data_clear (area); - - src_tiles = gimp_pickable_get_tiles (src_pickable); - - /* Destination coordinates that will be painted */ - x1d = area->x; - y1d = area->y; - x2d = area->x + area->width; - y2d = area->y + area->height; - - /* Boundary box for source pixels to copy: Convert all the - * vertex of the box to paint in destination area to its - * correspondent in source area bearing in mind perspective - */ - gimp_perspective_clone_get_source_point (clone, x1d, y1d, &x1s, &y1s); - gimp_perspective_clone_get_source_point (clone, x1d, y2d, &x2s, &y2s); - gimp_perspective_clone_get_source_point (clone, x2d, y1d, &x3s, &y3s); - gimp_perspective_clone_get_source_point (clone, x2d, y2d, &x4s, &y4s); - - xmin = floor (MIN4 (x1s, x2s, x3s, x4s)); - ymin = floor (MIN4 (y1s, y2s, y3s, y4s)); - xmax = ceil (MAX4 (x1s, x2s, x3s, x4s)); - ymax = ceil (MAX4 (y1s, y2s, y3s, y4s)); - - xmin = CLAMP (xmin - 1, 0, tile_manager_width (src_tiles)); - ymin = CLAMP (ymin - 1, 0, tile_manager_height (src_tiles)); - xmax = CLAMP (xmax + 1, 0, tile_manager_width (src_tiles)); - ymax = CLAMP (ymax + 1, 0, tile_manager_height (src_tiles)); - - /* if the source area is completely out of the image */ - if (!(xmax - xmin) || !(ymax - ymin)) - return; - - /* If the source image is different from the destination, - * then we should copy straight from the destination image - * to the canvas. - * Otherwise, we need a call to get_orig_image to make sure - * we get a copy of the unblemished (offset) image - */ - if (( options->sample_merged && (src_image != image)) || - (! options->sample_merged && (clone->src_drawable != drawable))) - { - /* get the original image */ - pixel_region_init (&auxPR, src_tiles, - xmin, ymin, xmax - xmin, ymax - ymin, - FALSE); - orig = temp_buf_new (xmax - xmin, ymax - ymin, auxPR.bytes, - 0, 0, NULL); - - pixel_region_init_temp_buf (&auxPR2, orig, - 0, 0, xmax - xmin, ymax - ymin); - copy_region (&auxPR, &auxPR2); - } - else + for (j = y1d; j < y2d; j++) { - /* get the original image */ - if (options->sample_merged) - orig = gimp_paint_core_get_orig_proj (paint_core, - src_pickable, - xmin, ymin, xmax, ymax); - else - orig = gimp_paint_core_get_orig_image (paint_core, - GIMP_DRAWABLE (src_pickable), - xmin, ymin, xmax, ymax); - } - - /* note: orig is a TempBuf where are all the pixels that I need to copy */ - /* copy from orig to temp_buf, this buffer has the size of the destination area */ - /* Also allocate memory for alpha channel */ - temp_buf = temp_buf_new (x2d-x1d, y2d-y1d, orig->bytes+1, 0, 0, NULL); - - src_data = temp_buf_data (orig); - dest_data = temp_buf_data (temp_buf); - - for (i = x1d; i < x2d; i++) - { - for (j = y1d; j < y2d; j++) + guchar *dest_pixel; + gdouble temp_x, temp_y; + gint itemp_x, itemp_y; + + gimp_perspective_clone_get_source_point (clone, + i, j, + &temp_x, &temp_y); + + itemp_x = (gint) temp_x; + itemp_y = (gint) temp_y; + + /* Points to the dest pixel in clone->src_area */ + dest_pixel = (dest_data + + clone->src_area->bytes * + ((j - y1d) * clone->src_area->width + + (i - x1d))); + + /* Check if the source pixel is inside the image */ + if (itemp_x > 0 && itemp_x < tile_manager_width (src_tiles) - 1 && + itemp_y > 0 && itemp_y < tile_manager_height (src_tiles) - 1) { - guchar *dest_pixel; - - gimp_perspective_clone_get_source_point (clone, - i, j, - &temp_x, &temp_y); - - itemp_x = (gint) temp_x; - itemp_y = (gint) temp_y; - - /* Points to the dest pixel in temp_buf*/ - dest_pixel = dest_data + (gint)((j-y1d) * temp_buf->width + (i-x1d)) * temp_buf->bytes; - - /* Check if the source pixel is inside the image*/ - if (itemp_x > 0 && - itemp_x < (tile_manager_width (src_tiles)-1) && - itemp_y > 0 && - itemp_y < (tile_manager_height (src_tiles)-1)) - { - guchar *src_pixel; - guchar *color1 = g_alloca (temp_buf->bytes - 1); - guchar *color2 = g_alloca (temp_buf->bytes - 1); - guchar *color3 = g_alloca (temp_buf->bytes - 1); - guchar *color4 = g_alloca (temp_buf->bytes - 1); - gdouble dx, dy; - gint k; - - dx = temp_x - itemp_x; - dy = temp_y - itemp_y; - - /* linear interpolation */ - /* (i,j)*((1-dx)*(1-dy) + (i+1,j)*(dx*(1-dy)) + (i,j+1)*((1-dx)*dy) + (i+1,j+1)*(dx*dy) */ - src_pixel = src_data + (gint)((itemp_y-ymin) * orig->width + (itemp_x-xmin)) * orig->bytes; - for (k = 0 ; k < temp_buf->bytes-1; k++) color1[k] = *src_pixel++; - - src_pixel = src_data + (gint)((itemp_y-ymin) * orig->width + (itemp_x+1-xmin)) * orig->bytes; - for (k = 0 ; k < temp_buf->bytes-1; k++) color2[k] = *src_pixel++; - - src_pixel = src_data + (gint)((itemp_y+1-ymin) * orig->width + (itemp_x-xmin)) * orig->bytes; - for (k = 0 ; k < temp_buf->bytes-1; k++) color3[k] = *src_pixel++; - - src_pixel = src_data + (gint)((itemp_y+1-ymin) * orig->width + (itemp_x+1-xmin)) * orig->bytes; - for (k = 0 ; k < temp_buf->bytes-1; k++) color4[k] = *src_pixel++; - - /* copy the pixel interpolated to temp_buf */ - for (k = 0 ; k < temp_buf->bytes-1; k++) - *dest_pixel++ = color1[k]*((1-dx)*(1-dy)) + color2[k]*(dx*(1-dy)) + color3[k]*((1-dx)*dy) + color4[k]*(dx*dy); - - /* If the pixel is inside the image set the alpha channel visible */ - *dest_pixel = 255; - } - else - { - dest_pixel[temp_buf->bytes-1] = 0; /* Pixels with source out-of-image are transparent */ - } + guchar *src_pixel; + guchar *color1 = g_alloca (clone->src_area->bytes - 1); + guchar *color2 = g_alloca (clone->src_area->bytes - 1); + guchar *color3 = g_alloca (clone->src_area->bytes - 1); + guchar *color4 = g_alloca (clone->src_area->bytes - 1); + gdouble dx, dy; + gint k; + + dx = temp_x - itemp_x; + dy = temp_y - itemp_y; + + /* linear interpolation + * (i,j) * (1-dx)*(1-dy) + + * (i+1,j) * (dx*(1-dy)) + + * (i,j+1) * ((1-dx)*dy) + + * (i+1,j+1) * (dx*dy) + */ + src_pixel = (src_data + + orig->bytes * + ((itemp_y - ymin) * orig->width + + (itemp_x - xmin))); + for (k = 0 ; k < clone->src_area->bytes - 1; k++) + color1[k] = *src_pixel++; + + src_pixel = (src_data + + orig->bytes * + ((itemp_y - ymin) * orig->width + + (itemp_x + 1 - xmin))); + for (k = 0 ; k < clone->src_area->bytes - 1; k++) + color2[k] = *src_pixel++; + + src_pixel = (src_data + + orig->bytes * + ((itemp_y + 1 - ymin) * orig->width + + (itemp_x - xmin))); + for (k = 0 ; k < clone->src_area->bytes - 1; k++) + color3[k] = *src_pixel++; + + src_pixel = (src_data + + orig->bytes * + ((itemp_y + 1 - ymin) * orig->width + + (itemp_x + 1 - xmin))); + for (k = 0 ; k < clone->src_area->bytes - 1; k++) + color4[k] = *src_pixel++; + + /* copy the pixel interpolated to clone->src_area */ + for (k = 0 ; k < clone->src_area->bytes - 1; k++) + *dest_pixel++ = (color1[k] * ((1-dx) * (1-dy)) + + color2[k] * (dx * (1-dy)) + + color3[k] * ((1-dx) * dy) + + color4[k] * (dx * dy)); + + /* FIXME: If the pixel is inside the image set the alpha + * channel visible + */ + *dest_pixel = 255; } - } - - pixel_region_init_temp_buf (&srcPR, temp_buf, - 0, 0, x2d - x1d, y2d - y1d); - - /* configure the destination */ - pixel_region_init_temp_buf (&destPR, area, 0, 0, srcPR.w, srcPR.h); - - pr = pixel_regions_register (2, &srcPR, &destPR); - break; - - case GIMP_PATTERN_CLONE: - pattern = gimp_context_get_pattern (context); - - if (!pattern) - return; - - /* configure the destination */ - pixel_region_init_temp_buf (&destPR, area, - 0, 0, area->width, area->height); - - pr = pixel_regions_register (1, &destPR); - break; - } - - for (; pr != NULL; pr = pixel_regions_process (pr)) - { - s = srcPR.data; - d = destPR.data; - - for (y = 0; y < destPR.h; y++) - { - switch (options->clone_type) + else { - case GIMP_IMAGE_CLONE: - gimp_perspective_clone_line_image (image, src_image, - drawable, src_pickable, - s, d, - srcPR.bytes, destPR.bytes, destPR.w); - s += srcPR.rowstride; - break; - - case GIMP_PATTERN_CLONE: - gimp_perspective_clone_line_pattern (image, drawable, - pattern, d, - area->x + offset_x, - area->y + y + offset_y, - destPR.bytes, destPR.w); - break; + /* Pixels with source out-of-image are transparent */ + dest_pixel[clone->src_area->bytes - 1] = 0; } - - d += destPR.rowstride; } } - if (paint_options->pressure_options->opacity) - opacity *= PRESSURE_SCALE * paint_core->cur_coords.pressure; - - gimp_brush_core_paste_canvas (GIMP_BRUSH_CORE (paint_core), drawable, - MIN (opacity, GIMP_OPACITY_OPAQUE), - gimp_context_get_opacity (context), - gimp_context_get_paint_mode (context), - gimp_paint_options_get_brush_mode (paint_options), - - /* In fixed mode, paint incremental so the - * individual brushes are properly applied - * on top of each other. - * Otherwise the stuff we paint is seamless - * and we don't need intermediate masking. - */ - options->align_mode == GIMP_SOURCE_ALIGN_FIXED ? - GIMP_PAINT_INCREMENTAL : GIMP_PAINT_CONSTANT); -} - -static void -gimp_perspective_clone_line_image (GimpImage *dest, - GimpImage *src, - GimpDrawable *d_drawable, - GimpPickable *s_pickable, - guchar *s, - guchar *d, - gint src_bytes, - gint dest_bytes, - gint width) -{ - guchar rgba[MAX_CHANNELS]; - gint alpha; - - alpha = dest_bytes - 1; - - while (width--) - { - gimp_image_get_color (src, gimp_pickable_get_image_type (s_pickable), - s, rgba); - - gimp_image_transform_color (dest, d_drawable, d, GIMP_RGB, rgba); - - d[alpha] = s[src_bytes-1]; /* This line is diferent that in gimpclone !! */ - - s += src_bytes; - d += dest_bytes; - } -} - -static void -gimp_perspective_clone_line_pattern (GimpImage *dest, - GimpDrawable *drawable, - GimpPattern *pattern, - guchar *d, - gint x, - gint y, - gint bytes, - gint width) -{ - guchar *pat, *p; - GimpImageBaseType color_type; - gint alpha; - gint pat_bytes; - gint i; - - pat_bytes = pattern->mask->bytes; - - /* Make sure x, y are positive */ - while (x < 0) - x += pattern->mask->width; - while (y < 0) - y += pattern->mask->height; - - /* Get a pointer to the appropriate scanline of the pattern buffer */ - pat = temp_buf_data (pattern->mask) + - (y % pattern->mask->height) * pattern->mask->width * pat_bytes; - - color_type = (pat_bytes == 3 || - pat_bytes == 4) ? GIMP_RGB : GIMP_GRAY; - - alpha = bytes - 1; - - for (i = 0; i < width; i++) - { - p = pat + ((i + x) % pattern->mask->width) * pat_bytes; - - gimp_image_transform_color (dest, drawable, d, color_type, p); - - if (pat_bytes == 2 || pat_bytes == 4) - d[alpha] = p[pat_bytes - 1]; - else - d[alpha] = OPAQUE_OPACITY; - - d += bytes; - } -} - -static void -gimp_perspective_clone_src_drawable_removed (GimpDrawable *drawable, - GimpPerspectiveClone *clone) -{ - if (drawable == clone->src_drawable) - { - clone->src_drawable = NULL; - } - - g_signal_handlers_disconnect_by_func (drawable, - gimp_perspective_clone_src_drawable_removed, - clone); -} - -static void -gimp_perspective_clone_set_src_drawable (GimpPerspectiveClone *clone, - GimpDrawable *drawable) -{ - if (clone->src_drawable == drawable) - return; - - if (clone->src_drawable) - g_signal_handlers_disconnect_by_func (clone->src_drawable, - gimp_perspective_clone_src_drawable_removed, - clone); - - clone->src_drawable = drawable; - - if (clone->src_drawable) - g_signal_connect (clone->src_drawable, "removed", - G_CALLBACK (gimp_perspective_clone_src_drawable_removed), - clone); + pixel_region_init_temp_buf (srcPR, clone->src_area, + 0, 0, x2d - x1d, y2d - y1d); - g_object_notify (G_OBJECT (clone), "src-drawable"); + return TRUE; } void Index: app/paint/gimpperspectiveclone.h =================================================================== RCS file: /cvs/gnome/gimp/app/paint/gimpperspectiveclone.h,v retrieving revision 1.2 diff -u -p -r1.2 gimpperspectiveclone.h --- app/paint/gimpperspectiveclone.h 7 Sep 2006 17:10:08 -0000 1.2 +++ app/paint/gimpperspectiveclone.h 9 Sep 2006 17:39:15 -0000 @@ -36,37 +36,26 @@ typedef struct _GimpPerspectiveCloneClas struct _GimpPerspectiveClone { - GimpClone parent_instance; + GimpClone parent_instance; - gboolean set_source; + gdouble dest_x; /* coords where the stroke starts */ + gdouble dest_y; - GimpDrawable *src_drawable; - gdouble src_x; /* coordinates where the cross that indicate where is copying each moment is painted */ - gdouble src_y; + gdouble src_x_fv; /* source coords in front_view perspective */ + gdouble src_y_fv; - gdouble orig_src_x; - gdouble orig_src_y; + gdouble dest_x_fv; /* destination coords in front_view perspective */ + gdouble dest_y_fv; - gdouble dest_x; /* coords where the stroke starts */ - gdouble dest_y; + GimpMatrix3 transform; + GimpMatrix3 transform_inv; - gdouble src_x_fv; /* source coords in front_view perspective */ - gdouble src_y_fv; - - gdouble dest_x_fv; /* destination coords in front_view perspective */ - gdouble dest_y_fv; - - gdouble offset_x; - gdouble offset_y; - gboolean first_stroke; - - GimpMatrix3 transform; - GimpMatrix3 transform_inv; + TempBuf *src_area; }; struct _GimpPerspectiveCloneClass { - GimpCloneClass parent_class; + GimpCloneClass parent_class; }; @@ -76,9 +65,10 @@ void gimp_perspective_clone_register GType gimp_perspective_clone_get_type (void) G_GNUC_CONST; void gimp_perspective_clone_get_source_point (GimpPerspectiveClone *clone, - gdouble x, - gdouble y, - gdouble *newx, - gdouble *newy); + gdouble x, + gdouble y, + gdouble *newx, + gdouble *newy); + -#endif /* __GIMP_CLONE_VANISHIGN_H__ */ +#endif /* __GIMP_PERSPECTIVE_CLONE_H__ */ Index: app/paint/gimpperspectivecloneoptions.c =================================================================== RCS file: /cvs/gnome/gimp/app/paint/gimpperspectivecloneoptions.c,v retrieving revision 1.2 diff -u -p -r1.2 gimpperspectivecloneoptions.c --- app/paint/gimpperspectivecloneoptions.c 7 Sep 2006 17:10:08 -0000 1.2 +++ app/paint/gimpperspectivecloneoptions.c 9 Sep 2006 17:39:15 -0000 @@ -27,18 +27,10 @@ #include "gimpperspectivecloneoptions.h" -#define PERSPECTIVE_CLONE_DEFAULT_MODE GIMP_PERSPECTIVE_CLONE_MODE_ADJUST -#define PERSPECTIVE_CLONE_DEFAULT_TYPE GIMP_IMAGE_CLONE -#define PERSPECTIVE_CLONE_DEFAULT_ALIGN_MODE GIMP_SOURCE_ALIGN_NO - - enum { PROP_0, - PROP_CLONE_MODE, - PROP_CLONE_TYPE, - PROP_ALIGN_MODE, - PROP_SAMPLE_MERGED + PROP_CLONE_MODE }; @@ -53,7 +45,7 @@ static void gimp_perspective_clone_opt G_DEFINE_TYPE (GimpPerspectiveCloneOptions, gimp_perspective_clone_options, - GIMP_TYPE_PAINT_OPTIONS) + GIMP_TYPE_CLONE_OPTIONS) static void @@ -67,22 +59,8 @@ gimp_perspective_clone_options_class_ini GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_CLONE_MODE, "clone-mode", NULL, GIMP_TYPE_PERSPECTIVE_CLONE_MODE, - PERSPECTIVE_CLONE_DEFAULT_MODE, - GIMP_PARAM_STATIC_STRINGS); - GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_CLONE_TYPE, - "clone-type", NULL, - GIMP_TYPE_CLONE_TYPE, - PERSPECTIVE_CLONE_DEFAULT_TYPE, + GIMP_PERSPECTIVE_CLONE_MODE_ADJUST, GIMP_PARAM_STATIC_STRINGS); - GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_ALIGN_MODE, - "align-mode", NULL, - GIMP_TYPE_SOURCE_ALIGN_MODE, - PERSPECTIVE_CLONE_DEFAULT_ALIGN_MODE, - GIMP_PARAM_STATIC_STRINGS); - GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_SAMPLE_MERGED, - "sample-merged", NULL, - FALSE, - GIMP_PARAM_STATIC_STRINGS); } static void @@ -103,15 +81,7 @@ gimp_perspective_clone_options_set_prope case PROP_CLONE_MODE: options->clone_mode = g_value_get_enum (value); break; - case PROP_CLONE_TYPE: - options->clone_type = g_value_get_enum (value); - break; - case PROP_ALIGN_MODE: - options->align_mode = g_value_get_enum (value); - break; - case PROP_SAMPLE_MERGED: - options->sample_merged = g_value_get_boolean (value); - break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; @@ -131,15 +101,7 @@ gimp_perspective_clone_options_get_prope case PROP_CLONE_MODE: g_value_set_enum (value, options->clone_mode); break; - case PROP_CLONE_TYPE: - g_value_set_enum (value, options->clone_type); - break; - case PROP_ALIGN_MODE: - g_value_set_enum (value, options->align_mode); - break; - case PROP_SAMPLE_MERGED: - g_value_set_boolean (value, options->sample_merged); - break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; Index: app/paint/gimpperspectivecloneoptions.h =================================================================== RCS file: /cvs/gnome/gimp/app/paint/gimpperspectivecloneoptions.h,v retrieving revision 1.2 diff -u -p -r1.2 gimpperspectivecloneoptions.h --- app/paint/gimpperspectivecloneoptions.h 7 Sep 2006 17:10:08 -0000 1.2 +++ app/paint/gimpperspectivecloneoptions.h 9 Sep 2006 17:39:16 -0000 @@ -20,7 +20,7 @@ #define __GIMP_PERSPECTIVE_CLONE_OPTIONS_H__ -#include "gimppaintoptions.h" +#include "gimpcloneoptions.h" #define GIMP_TYPE_PERSPECTIVE_CLONE_OPTIONS (gimp_perspective_clone_options_get_type ()) @@ -36,17 +36,14 @@ typedef struct _GimpPerspectiveCloneOpti struct _GimpPerspectiveCloneOptions { - GimpPaintOptions paint_instance; + GimpCloneOptions paint_instance; - GimpPerspectiveCloneMode clone_mode; - GimpCloneType clone_type; - GimpSourceAlignMode align_mode; - gboolean sample_merged; + GimpPerspectiveCloneMode clone_mode; }; struct _GimpPerspectiveCloneOptionsClass { - GimpPaintOptionsClass parent_class; + GimpCloneOptionsClass parent_class; }; Index: app/paint/gimpsourcecore.c =================================================================== RCS file: /cvs/gnome/gimp/app/paint/gimpsourcecore.c,v retrieving revision 1.137 diff -u -p -r1.137 gimpsourcecore.c --- app/paint/gimpsourcecore.c 8 Sep 2006 15:15:58 -0000 1.137 +++ app/paint/gimpsourcecore.c 9 Sep 2006 17:39:16 -0000 @@ -63,9 +63,11 @@ static void gimp_source_core_paint GimpPaintState paint_state, guint32 time); +#if 0 static void gimp_source_core_motion (GimpSourceCore *source_core, GimpDrawable *drawable, GimpPaintOptions *paint_options); +#endif static gboolean gimp_source_core_real_get_source (GimpSourceCore *source_core, GimpDrawable *drawable, @@ -284,7 +286,7 @@ gimp_source_core_paint (GimpPaintCore g_object_notify (G_OBJECT (source_core), "src-y"); } -static void +void gimp_source_core_motion (GimpSourceCore *source_core, GimpDrawable *drawable, GimpPaintOptions *paint_options) Index: app/paint/gimpsourcecore.h =================================================================== RCS file: /cvs/gnome/gimp/app/paint/gimpsourcecore.h,v retrieving revision 1.34 diff -u -p -r1.34 gimpsourcecore.h --- app/paint/gimpsourcecore.h 8 Sep 2006 15:15:59 -0000 1.34 +++ app/paint/gimpsourcecore.h 9 Sep 2006 17:39:16 -0000 @@ -87,5 +87,10 @@ struct _GimpSourceCoreClass GType gimp_source_core_get_type (void) G_GNUC_CONST; +/* TEMP HACK */ +void gimp_source_core_motion (GimpSourceCore *source_core, + GimpDrawable *drawable, + GimpPaintOptions *paint_options); + #endif /* __GIMP_SOURCE_CORE_H__ */ Index: app/tools/gimpperspectiveclonetool.c =================================================================== RCS file: /cvs/gnome/gimp/app/tools/gimpperspectiveclonetool.c,v retrieving revision 1.3 diff -u -p -r1.3 gimpperspectiveclonetool.c --- app/tools/gimpperspectiveclonetool.c 8 Sep 2006 08:39:55 -0000 1.3 +++ app/tools/gimpperspectiveclonetool.c 9 Sep 2006 17:39:17 -0000 @@ -316,9 +316,10 @@ gimp_perspective_clone_tool_button_press GdkModifierType state, GimpDisplay *display) { - GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (tool); - GimpPerspectiveCloneTool *clone_tool = GIMP_PERSPECTIVE_CLONE_TOOL (tool); - GimpPerspectiveClone *clone = GIMP_PERSPECTIVE_CLONE (paint_tool->core); + GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (tool); + GimpPerspectiveCloneTool *clone_tool = GIMP_PERSPECTIVE_CLONE_TOOL (tool); + GimpPerspectiveClone *clone = GIMP_PERSPECTIVE_CLONE (paint_tool->core); + GimpSourceCore *source_core = GIMP_SOURCE_CORE (clone); GimpPerspectiveCloneOptions *options; options = GIMP_PERSPECTIVE_CLONE_OPTIONS (tool->tool_info->tool_options); @@ -343,16 +344,16 @@ gimp_perspective_clone_tool_button_press if ((state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK)) == GDK_CONTROL_MASK) { - clone->set_source = TRUE; + source_core->set_source = TRUE; clone_tool->src_display = display; } else { - clone->set_source = FALSE; + source_core->set_source = FALSE; - if (options->clone_type == GIMP_IMAGE_CLONE && - options->sample_merged && + if (GIMP_CLONE_OPTIONS (options)->clone_type == GIMP_IMAGE_CLONE && + GIMP_SOURCE_OPTIONS (options)->sample_merged && display == clone_tool->src_display) { paint_tool->core->use_saved_proj = TRUE; @@ -375,8 +376,8 @@ gimp_perspective_clone_tool_button_press } static void -gimp_perspective_clone_tool_prepare (GimpPerspectiveCloneTool *perspective_clone_tool, - GimpDisplay *display) +gimp_perspective_clone_tool_prepare (GimpPerspectiveCloneTool *perspective_clone_tool, + GimpDisplay *display) { perspective_clone_tool->trans_info[X0] = (gdouble) perspective_clone_tool->x1; perspective_clone_tool->trans_info[Y0] = (gdouble) perspective_clone_tool->y1; @@ -419,9 +420,10 @@ gimp_perspective_clone_tool_motion (Gimp GdkModifierType state, GimpDisplay *display) { - GimpPerspectiveCloneTool *clone_tool = GIMP_PERSPECTIVE_CLONE_TOOL (tool); - GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (tool); - GimpPerspectiveClone *clone = GIMP_PERSPECTIVE_CLONE (paint_tool->core); + GimpPerspectiveCloneTool *clone_tool = GIMP_PERSPECTIVE_CLONE_TOOL (tool); + GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (tool); + GimpPerspectiveClone *clone = GIMP_PERSPECTIVE_CLONE (paint_tool->core); + GimpSourceCore *source_core = GIMP_SOURCE_CORE (clone); GimpPerspectiveCloneOptions *options; options = GIMP_PERSPECTIVE_CLONE_OPTIONS (tool->tool_info->tool_options); @@ -481,9 +483,9 @@ gimp_perspective_clone_tool_motion (Gimp gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool)); if ((state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK)) == GDK_CONTROL_MASK) - clone->set_source = TRUE; + source_core->set_source = TRUE; else - clone->set_source = FALSE; + source_core->set_source = FALSE; GIMP_TOOL_CLASS (parent_class)->motion (tool, coords, time, state, display); @@ -553,13 +555,13 @@ gimp_perspective_clone_tool_cursor_updat } else { - if (options->clone_type == GIMP_IMAGE_CLONE) + if (GIMP_CLONE_OPTIONS (options)->clone_type == GIMP_IMAGE_CLONE) { if ((state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK)) == GDK_CONTROL_MASK) { cursor = GIMP_CURSOR_CROSSHAIR_SMALL; } - else if (! GIMP_PERSPECTIVE_CLONE (GIMP_PAINT_TOOL (tool)->core)->src_drawable) + else if (! GIMP_SOURCE_CORE (GIMP_PAINT_TOOL (tool)->core)->src_drawable) { modifier = GIMP_CURSOR_MODIFIER_BAD; } @@ -640,11 +642,13 @@ gimp_perspective_clone_tool_oper_update GIMP_TOOL_CLASS (parent_class)->oper_update (tool, coords, state, proximity, display); - if (options->clone_type == GIMP_IMAGE_CLONE && proximity) + if (GIMP_CLONE_OPTIONS (options)->clone_type == GIMP_IMAGE_CLONE && + proximity) { - GimpPerspectiveClone *clone = GIMP_PERSPECTIVE_CLONE (GIMP_PAINT_TOOL (tool)->core); + GimpPerspectiveClone *clone = GIMP_PERSPECTIVE_CLONE (GIMP_PAINT_TOOL (tool)->core); + GimpSourceCore *source_core = GIMP_SOURCE_CORE (clone); - if (clone->src_drawable == NULL) + if (source_core->src_drawable == NULL) { gimp_tool_replace_status (tool, display, _("Ctrl-Click to set a clone source.")); @@ -653,12 +657,13 @@ gimp_perspective_clone_tool_oper_update { gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool)); - clone_tool->src_x = clone->src_x; - clone_tool->src_y = clone->src_y; + clone_tool->src_x = source_core->src_x; + clone_tool->src_y = source_core->src_y; - if (! clone->first_stroke) + if (! source_core->first_stroke) { - if (options->align_mode == GIMP_SOURCE_ALIGN_YES) + if (GIMP_SOURCE_OPTIONS (options)->align_mode == + GIMP_SOURCE_ALIGN_YES) { gdouble nnx, nny; @@ -682,9 +687,10 @@ gimp_perspective_clone_tool_oper_update static void gimp_perspective_clone_tool_draw (GimpDrawTool *draw_tool) { - GimpTool *tool = GIMP_TOOL (draw_tool); - GimpPerspectiveCloneTool *clone_tool = GIMP_PERSPECTIVE_CLONE_TOOL (draw_tool); - GimpPerspectiveClone *clone = GIMP_PERSPECTIVE_CLONE (GIMP_PAINT_TOOL (tool)->core); + GimpTool *tool = GIMP_TOOL (draw_tool); + GimpPerspectiveCloneTool *clone_tool = GIMP_PERSPECTIVE_CLONE_TOOL (draw_tool); + GimpPerspectiveClone *clone = GIMP_PERSPECTIVE_CLONE (GIMP_PAINT_TOOL (tool)->core); + GimpSourceCore *source_core = GIMP_SOURCE_CORE (clone); GimpPerspectiveCloneOptions *options; options = GIMP_PERSPECTIVE_CLONE_OPTIONS (tool->tool_info->tool_options); @@ -736,14 +742,15 @@ gimp_perspective_clone_tool_draw (GimpDr FALSE); } - if (options->clone_type == GIMP_IMAGE_CLONE && - clone->src_drawable && clone_tool->src_display) + if (GIMP_CLONE_OPTIONS (options)->clone_type == GIMP_IMAGE_CLONE && + source_core->src_drawable && clone_tool->src_display) { GimpDisplay *tmp_display; gint off_x; gint off_y; - gimp_item_offsets (GIMP_ITEM (clone->src_drawable), &off_x, &off_y); + gimp_item_offsets (GIMP_ITEM (source_core->src_drawable), + &off_x, &off_y); tmp_display = draw_tool->display; draw_tool->display = clone_tool->src_display; @@ -903,16 +910,10 @@ gimp_perspective_clone_options_gui (Gimp gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0); gtk_widget_show (table); - /*combo = gimp_prop_enum_combo_box_new (config, "align-mode", 0, 0); + combo = gimp_prop_enum_combo_box_new (config, "align-mode", 0, 0); gimp_table_attach_aligned (GTK_TABLE (table), 0, 0, _("Alignment:"), 0.0, 0.5, combo, 1, FALSE); - */ - frame = gimp_prop_enum_radio_frame_new (config, "align-mode", - _("Alignment"), - 0, 0); - gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); - gtk_widget_show (frame); return vbox; }