1997-11-25 06:05:25 +08:00
/* The GIMP -- an image manipulation program
* Copyright ( C ) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation ; either version 2 of the License , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with this program ; if not , write to the Free Software
1998-04-13 13:44:11 +08:00
* Foundation , Inc . , 59 Temple Place - Suite 330 , Boston , MA 02111 - 1307 , USA .
1997-11-25 06:05:25 +08:00
*/
# include <stdlib.h>
# include <string.h>
# include "appenv.h"
1998-07-09 13:31:06 +08:00
# include "gimpbrushlist.h"
1997-11-25 06:05:25 +08:00
# include "drawable.h"
# include "errors.h"
# include "gdisplay.h"
# include "gimage_mask.h"
# include "interface.h"
# include "paint_funcs.h"
# include "paint_core.h"
# include "patterns.h"
# include "clone.h"
# include "selection.h"
# include "tools.h"
Lots of ii8n stuff here and some additions to the de.po. Applied
Wed Oct 14 17:46:15 EDT 1998 Adrian Likins <adrian@gimp.org>
* app/*, po/de.po, de/POTFILES.in, libgimp/gimpintl.h:
Lots of ii8n stuff here and some additions to the de.po.
Applied gimp-egger-981005-1 ,gimp-egger-981006-1,
gimp-egger-981007-1, gimp-egger-981008-1,
gimp-egger-981009-1.patch, gimp-egger-981010-1.patch
* plug-in/guillotine/guillotine.c: added the coordinates
of the split images from the original image to the title.
ie foo.jpg (0,0) for the image in the topleft.
* plug-in/script-fu/scripts/neon-logo.scm,
perspective-shadow.scm, predator.scm,rendermap.scm,
ripply-anim.scm, select_to_image.scm,swirltile.scm,
xach-effect.scm: updated scripts to use new script-fu stuff
wooo boy! a big un!
in testing this, it looks like some of the po files are busted.
but the code stuff seems okay.
-adrian
1998-10-15 07:23:52 +08:00
# include "libgimp/gimpintl.h"
1997-11-25 06:05:25 +08:00
# define TARGET_HEIGHT 15
# define TARGET_WIDTH 15
typedef enum
{
ImageClone ,
PatternClone
} CloneType ;
/* forward function declarations */
static void clone_draw ( Tool * ) ;
1998-01-22 15:02:57 +08:00
static void clone_motion ( PaintCore * , GimpDrawable * , GimpDrawable * , CloneType , int , int ) ;
static void clone_line_image ( GImage * , GImage * , GimpDrawable * , GimpDrawable * , unsigned char * ,
1997-11-25 06:05:25 +08:00
unsigned char * , int , int , int , int ) ;
1998-01-22 15:02:57 +08:00
static void clone_line_pattern ( GImage * , GimpDrawable * , GPatternP , unsigned char * ,
1997-11-25 06:05:25 +08:00
int , int , int , int ) ;
static Argument * clone_invoker ( Argument * ) ;
1998-01-22 15:02:57 +08:00
static GimpDrawable * non_gui_src_drawable ;
1997-11-25 06:05:25 +08:00
static int non_gui_offset_x ;
static int non_gui_offset_y ;
static CloneType non_gui_type ;
typedef struct _CloneOptions CloneOptions ;
struct _CloneOptions
{
CloneType type ;
int aligned ;
} ;
/* local variables */
static int src_x = 0 ; /* */
static int src_y = 0 ; /* position of clone src */
static int dest_x = 0 ; /* */
static int dest_y = 0 ; /* position of clone src */
static int offset_x = 0 ; /* */
static int offset_y = 0 ; /* offset for cloning */
static int first = TRUE ;
static int trans_tx , trans_ty ; /* transformed target */
1998-06-30 23:31:32 +08:00
static GDisplay * the_src_gdisp = NULL ; /* ID of source gdisplay */
1998-01-22 15:02:57 +08:00
static GimpDrawable * src_drawable_ = NULL ; /* source drawable */
1997-11-25 06:05:25 +08:00
static CloneOptions * clone_options = NULL ;
static void
clone_toggle_update ( GtkWidget * widget ,
gpointer data )
{
int * toggle_val ;
toggle_val = ( int * ) data ;
if ( GTK_TOGGLE_BUTTON ( widget ) - > active )
* toggle_val = TRUE ;
else
* toggle_val = FALSE ;
}
static void
clone_type_callback ( GtkWidget * w ,
gpointer client_data )
{
clone_options - > type = ( CloneType ) client_data ;
}
static CloneOptions *
create_clone_options ( void )
{
CloneOptions * options ;
GtkWidget * vbox ;
GtkWidget * label ;
GtkWidget * aligned_toggle ;
GtkWidget * radio_frame ;
GtkWidget * radio_box ;
GtkWidget * radio_button ;
GSList * group = NULL ;
int i ;
char * button_names [ 2 ] =
{
Lots of ii8n stuff here and some additions to the de.po. Applied
Wed Oct 14 17:46:15 EDT 1998 Adrian Likins <adrian@gimp.org>
* app/*, po/de.po, de/POTFILES.in, libgimp/gimpintl.h:
Lots of ii8n stuff here and some additions to the de.po.
Applied gimp-egger-981005-1 ,gimp-egger-981006-1,
gimp-egger-981007-1, gimp-egger-981008-1,
gimp-egger-981009-1.patch, gimp-egger-981010-1.patch
* plug-in/guillotine/guillotine.c: added the coordinates
of the split images from the original image to the title.
ie foo.jpg (0,0) for the image in the topleft.
* plug-in/script-fu/scripts/neon-logo.scm,
perspective-shadow.scm, predator.scm,rendermap.scm,
ripply-anim.scm, select_to_image.scm,swirltile.scm,
xach-effect.scm: updated scripts to use new script-fu stuff
wooo boy! a big un!
in testing this, it looks like some of the po files are busted.
but the code stuff seems okay.
-adrian
1998-10-15 07:23:52 +08:00
N_ ( " Image Source " ) ,
N_ ( " Pattern Source " )
1997-11-25 06:05:25 +08:00
} ;
/* the new options structure */
options = ( CloneOptions * ) g_malloc ( sizeof ( CloneOptions ) ) ;
options - > type = ImageClone ;
options - > aligned = TRUE ;
/* the main vbox */
vbox = gtk_vbox_new ( FALSE , 1 ) ;
/* the main label */
Lots of ii8n stuff here and some additions to the de.po. Applied
Wed Oct 14 17:46:15 EDT 1998 Adrian Likins <adrian@gimp.org>
* app/*, po/de.po, de/POTFILES.in, libgimp/gimpintl.h:
Lots of ii8n stuff here and some additions to the de.po.
Applied gimp-egger-981005-1 ,gimp-egger-981006-1,
gimp-egger-981007-1, gimp-egger-981008-1,
gimp-egger-981009-1.patch, gimp-egger-981010-1.patch
* plug-in/guillotine/guillotine.c: added the coordinates
of the split images from the original image to the title.
ie foo.jpg (0,0) for the image in the topleft.
* plug-in/script-fu/scripts/neon-logo.scm,
perspective-shadow.scm, predator.scm,rendermap.scm,
ripply-anim.scm, select_to_image.scm,swirltile.scm,
xach-effect.scm: updated scripts to use new script-fu stuff
wooo boy! a big un!
in testing this, it looks like some of the po files are busted.
but the code stuff seems okay.
-adrian
1998-10-15 07:23:52 +08:00
label = gtk_label_new ( _ ( " Clone Tool Options " ) ) ;
1997-11-25 06:05:25 +08:00
gtk_box_pack_start ( GTK_BOX ( vbox ) , label , FALSE , FALSE , 0 ) ;
gtk_widget_show ( label ) ;
/* the radio frame and box */
Lots of ii8n stuff here and some additions to the de.po. Applied
Wed Oct 14 17:46:15 EDT 1998 Adrian Likins <adrian@gimp.org>
* app/*, po/de.po, de/POTFILES.in, libgimp/gimpintl.h:
Lots of ii8n stuff here and some additions to the de.po.
Applied gimp-egger-981005-1 ,gimp-egger-981006-1,
gimp-egger-981007-1, gimp-egger-981008-1,
gimp-egger-981009-1.patch, gimp-egger-981010-1.patch
* plug-in/guillotine/guillotine.c: added the coordinates
of the split images from the original image to the title.
ie foo.jpg (0,0) for the image in the topleft.
* plug-in/script-fu/scripts/neon-logo.scm,
perspective-shadow.scm, predator.scm,rendermap.scm,
ripply-anim.scm, select_to_image.scm,swirltile.scm,
xach-effect.scm: updated scripts to use new script-fu stuff
wooo boy! a big un!
in testing this, it looks like some of the po files are busted.
but the code stuff seems okay.
-adrian
1998-10-15 07:23:52 +08:00
radio_frame = gtk_frame_new ( _ ( " Source " ) ) ;
1997-11-25 06:05:25 +08:00
gtk_box_pack_start ( GTK_BOX ( vbox ) , radio_frame , FALSE , FALSE , 0 ) ;
radio_box = gtk_vbox_new ( FALSE , 1 ) ;
gtk_container_add ( GTK_CONTAINER ( radio_frame ) , radio_box ) ;
/* the radio buttons */
for ( i = 0 ; i < 2 ; i + + )
{
1998-11-23 22:47:09 +08:00
radio_button = gtk_radio_button_new_with_label ( group , gettext ( button_names [ i ] ) ) ;
1997-11-25 06:05:25 +08:00
group = gtk_radio_button_group ( GTK_RADIO_BUTTON ( radio_button ) ) ;
gtk_signal_connect ( GTK_OBJECT ( radio_button ) , " toggled " ,
( GtkSignalFunc ) clone_type_callback ,
( void * ) ( ( long ) i ) ) ;
gtk_box_pack_start ( GTK_BOX ( radio_box ) , radio_button , FALSE , FALSE , 0 ) ;
gtk_widget_show ( radio_button ) ;
}
gtk_widget_show ( radio_box ) ;
gtk_widget_show ( radio_frame ) ;
/* the aligned toggle button */
Lots of ii8n stuff here and some additions to the de.po. Applied
Wed Oct 14 17:46:15 EDT 1998 Adrian Likins <adrian@gimp.org>
* app/*, po/de.po, de/POTFILES.in, libgimp/gimpintl.h:
Lots of ii8n stuff here and some additions to the de.po.
Applied gimp-egger-981005-1 ,gimp-egger-981006-1,
gimp-egger-981007-1, gimp-egger-981008-1,
gimp-egger-981009-1.patch, gimp-egger-981010-1.patch
* plug-in/guillotine/guillotine.c: added the coordinates
of the split images from the original image to the title.
ie foo.jpg (0,0) for the image in the topleft.
* plug-in/script-fu/scripts/neon-logo.scm,
perspective-shadow.scm, predator.scm,rendermap.scm,
ripply-anim.scm, select_to_image.scm,swirltile.scm,
xach-effect.scm: updated scripts to use new script-fu stuff
wooo boy! a big un!
in testing this, it looks like some of the po files are busted.
but the code stuff seems okay.
-adrian
1998-10-15 07:23:52 +08:00
aligned_toggle = gtk_check_button_new_with_label ( _ ( " Aligned " ) ) ;
1997-11-25 06:05:25 +08:00
gtk_box_pack_start ( GTK_BOX ( vbox ) , aligned_toggle , FALSE , FALSE , 0 ) ;
gtk_signal_connect ( GTK_OBJECT ( aligned_toggle ) , " toggled " ,
( GtkSignalFunc ) clone_toggle_update ,
& options - > aligned ) ;
1999-01-16 01:35:04 +08:00
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( aligned_toggle ) , options - > aligned ) ;
1997-11-25 06:05:25 +08:00
gtk_widget_show ( aligned_toggle ) ;
/* Register this selection options widget with the main tools options dialog */
tools_register_options ( CLONE , vbox ) ;
return options ;
}
void *
clone_paint_func ( PaintCore * paint_core ,
1998-01-22 15:02:57 +08:00
GimpDrawable * drawable ,
1997-11-25 06:05:25 +08:00
int state )
{
GDisplay * gdisp ;
GDisplay * src_gdisp ;
int x1 , y1 , x2 , y2 ;
gdisp = ( GDisplay * ) active_tool - > gdisp_ptr ;
switch ( state )
{
case MOTION_PAINT :
x1 = paint_core - > curx ;
y1 = paint_core - > cury ;
x2 = paint_core - > lastx ;
y2 = paint_core - > lasty ;
/* If the control key is down, move the src target and return */
if ( paint_core - > state & ControlMask )
{
src_x = x1 ;
src_y = y1 ;
first = TRUE ;
}
/* otherwise, update the target */
else
{
dest_x = x1 ;
dest_y = y1 ;
if ( first )
{
offset_x = src_x - dest_x ;
offset_y = src_y - dest_y ;
first = FALSE ;
}
else
{
src_x = dest_x + offset_x ;
src_y = dest_y + offset_y ;
}
1998-01-22 15:02:57 +08:00
clone_motion ( paint_core , drawable , src_drawable_ , clone_options - > type , offset_x , offset_y ) ;
1997-11-25 06:05:25 +08:00
}
draw_core_pause ( paint_core - > core , active_tool ) ;
break ;
case INIT_PAINT :
if ( paint_core - > state & ControlMask )
{
1998-06-30 23:31:32 +08:00
the_src_gdisp = gdisp ;
1998-01-22 15:02:57 +08:00
src_drawable_ = drawable ;
1997-11-25 06:05:25 +08:00
src_x = paint_core - > curx ;
src_y = paint_core - > cury ;
first = TRUE ;
}
else if ( clone_options - > aligned = = FALSE )
first = TRUE ;
if ( clone_options - > type = = PatternClone )
if ( ! get_active_pattern ( ) )
Lots of ii8n stuff here and some additions to the de.po. Applied
Wed Oct 14 17:46:15 EDT 1998 Adrian Likins <adrian@gimp.org>
* app/*, po/de.po, de/POTFILES.in, libgimp/gimpintl.h:
Lots of ii8n stuff here and some additions to the de.po.
Applied gimp-egger-981005-1 ,gimp-egger-981006-1,
gimp-egger-981007-1, gimp-egger-981008-1,
gimp-egger-981009-1.patch, gimp-egger-981010-1.patch
* plug-in/guillotine/guillotine.c: added the coordinates
of the split images from the original image to the title.
ie foo.jpg (0,0) for the image in the topleft.
* plug-in/script-fu/scripts/neon-logo.scm,
perspective-shadow.scm, predator.scm,rendermap.scm,
ripply-anim.scm, select_to_image.scm,swirltile.scm,
xach-effect.scm: updated scripts to use new script-fu stuff
wooo boy! a big un!
in testing this, it looks like some of the po files are busted.
but the code stuff seems okay.
-adrian
1998-10-15 07:23:52 +08:00
g_message ( _ ( " No patterns available for this operation. " ) ) ;
1997-11-25 06:05:25 +08:00
break ;
case FINISH_PAINT :
draw_core_stop ( paint_core - > core , active_tool ) ;
return NULL ;
break ;
default :
break ;
}
/* Calculate the coordinates of the target */
1998-06-30 23:31:32 +08:00
src_gdisp = the_src_gdisp ;
1997-11-25 06:05:25 +08:00
if ( ! src_gdisp )
{
1998-06-30 23:31:32 +08:00
the_src_gdisp = gdisp ;
src_gdisp = the_src_gdisp ;
1997-11-25 06:05:25 +08:00
}
/* Find the target cursor's location onscreen */
gdisplay_transform_coords ( src_gdisp , src_x , src_y , & trans_tx , & trans_ty , 1 ) ;
if ( state = = INIT_PAINT )
/* Initialize the tool drawing core */
draw_core_start ( paint_core - > core ,
src_gdisp - > canvas - > window ,
active_tool ) ;
else if ( state = = MOTION_PAINT )
draw_core_resume ( paint_core - > core , active_tool ) ;
return NULL ;
}
Tool *
tools_new_clone ( )
{
Tool * tool ;
PaintCore * private ;
if ( ! clone_options )
clone_options = create_clone_options ( ) ;
tool = paint_core_new ( CLONE ) ;
private = ( PaintCore * ) tool - > private ;
private - > paint_func = clone_paint_func ;
private - > core - > draw_func = clone_draw ;
return tool ;
}
void
tools_free_clone ( Tool * tool )
{
paint_core_free ( tool ) ;
}
static void
clone_draw ( Tool * tool )
{
PaintCore * paint_core ;
paint_core = ( PaintCore * ) tool - > private ;
if ( clone_options - > type = = ImageClone )
{
gdk_draw_line ( paint_core - > core - > win , paint_core - > core - > gc ,
trans_tx - ( TARGET_WIDTH > > 1 ) , trans_ty ,
trans_tx + ( TARGET_WIDTH > > 1 ) , trans_ty ) ;
gdk_draw_line ( paint_core - > core - > win , paint_core - > core - > gc ,
trans_tx , trans_ty - ( TARGET_HEIGHT > > 1 ) ,
trans_tx , trans_ty + ( TARGET_HEIGHT > > 1 ) ) ;
}
}
static void
clone_motion ( PaintCore * paint_core ,
1998-01-22 15:02:57 +08:00
GimpDrawable * drawable ,
GimpDrawable * src_drawable ,
1997-11-25 06:05:25 +08:00
CloneType type ,
int offset_x ,
int offset_y )
{
GImage * gimage ;
1998-10-19 04:37:43 +08:00
GImage * src_gimage = NULL ;
1997-11-25 06:05:25 +08:00
unsigned char * s ;
unsigned char * d ;
TempBuf * orig ;
TempBuf * area ;
void * pr ;
int y ;
int x1 , y1 , x2 , y2 ;
1998-10-19 04:37:43 +08:00
int has_alpha = - 1 ;
1997-11-25 06:05:25 +08:00
PixelRegion srcPR , destPR ;
GPatternP pattern ;
pr = NULL ;
pattern = NULL ;
1998-10-19 04:37:43 +08:00
/* Make sure we still have a source if we are doing image cloning */
if ( type = = ImageClone )
{
if ( ! src_drawable )
return ;
if ( ! ( src_gimage = drawable_gimage ( src_drawable ) ) )
return ;
/* Determine whether the source image has an alpha channel */
has_alpha = drawable_has_alpha ( src_drawable ) ;
}
/* We always need a destination image */
if ( ! ( gimage = drawable_gimage ( drawable ) ) )
1998-07-10 10:17:20 +08:00
return ;
1997-11-25 06:05:25 +08:00
/* Get a region which can be used to paint to */
1998-01-22 15:02:57 +08:00
if ( ! ( area = paint_core_get_paint_area ( paint_core , drawable ) ) )
1997-11-25 06:05:25 +08:00
return ;
switch ( type )
{
case ImageClone :
/* Set the paint area to transparent */
memset ( temp_buf_data ( area ) , 0 , area - > width * area - > height * area - > bytes ) ;
/* If the source gimage 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
*/
1998-01-22 15:02:57 +08:00
if ( src_drawable ! = drawable )
1997-11-25 06:05:25 +08:00
{
1998-01-22 15:02:57 +08:00
x1 = BOUNDS ( area - > x + offset_x , 0 , drawable_width ( src_drawable ) ) ;
y1 = BOUNDS ( area - > y + offset_y , 0 , drawable_height ( src_drawable ) ) ;
1997-11-25 06:05:25 +08:00
x2 = BOUNDS ( area - > x + offset_x + area - > width ,
1998-01-22 15:02:57 +08:00
0 , drawable_width ( src_drawable ) ) ;
1997-11-25 06:05:25 +08:00
y2 = BOUNDS ( area - > y + offset_y + area - > height ,
1998-01-22 15:02:57 +08:00
0 , drawable_height ( src_drawable ) ) ;
1997-11-25 06:05:25 +08:00
if ( ! ( x2 - x1 ) | | ! ( y2 - y1 ) )
return ;
1998-01-22 15:02:57 +08:00
pixel_region_init ( & srcPR , drawable_data ( src_drawable ) , x1 , y1 , ( x2 - x1 ) , ( y2 - y1 ) , FALSE ) ;
1997-11-25 06:05:25 +08:00
}
else
{
1998-01-22 15:02:57 +08:00
x1 = BOUNDS ( area - > x + offset_x , 0 , drawable_width ( drawable ) ) ;
y1 = BOUNDS ( area - > y + offset_y , 0 , drawable_height ( drawable ) ) ;
1997-11-25 06:05:25 +08:00
x2 = BOUNDS ( area - > x + offset_x + area - > width ,
1998-01-22 15:02:57 +08:00
0 , drawable_width ( drawable ) ) ;
1997-11-25 06:05:25 +08:00
y2 = BOUNDS ( area - > y + offset_y + area - > height ,
1998-01-22 15:02:57 +08:00
0 , drawable_height ( drawable ) ) ;
1997-11-25 06:05:25 +08:00
if ( ! ( x2 - x1 ) | | ! ( y2 - y1 ) )
return ;
/* get the original image */
1998-01-22 15:02:57 +08:00
orig = paint_core_get_orig_image ( paint_core , drawable , x1 , y1 , x2 , y2 ) ;
1997-11-25 06:05:25 +08:00
srcPR . bytes = orig - > bytes ;
srcPR . x = 0 ; srcPR . y = 0 ;
srcPR . w = x2 - x1 ;
srcPR . h = y2 - y1 ;
srcPR . rowstride = srcPR . bytes * orig - > width ;
srcPR . data = temp_buf_data ( orig ) ;
}
offset_x = x1 - ( area - > x + offset_x ) ;
offset_y = y1 - ( area - > y + offset_y ) ;
/* configure the destination */
destPR . bytes = area - > bytes ;
destPR . x = 0 ; destPR . y = 0 ;
destPR . w = srcPR . w ;
destPR . h = srcPR . h ;
destPR . rowstride = destPR . bytes * area - > width ;
destPR . data = temp_buf_data ( area ) + offset_y * destPR . rowstride +
offset_x * destPR . bytes ;
pr = pixel_regions_register ( 2 , & srcPR , & destPR ) ;
break ;
case PatternClone :
pattern = get_active_pattern ( ) ;
if ( ! pattern )
return ;
destPR . bytes = area - > bytes ;
destPR . x = 0 ; destPR . y = 0 ;
destPR . w = area - > width ;
destPR . h = area - > height ;
destPR . rowstride = destPR . bytes * area - > width ;
destPR . data = temp_buf_data ( area ) ;
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 ( type )
{
case ImageClone :
1998-01-22 15:02:57 +08:00
clone_line_image ( gimage , src_gimage , drawable , src_drawable , s , d ,
1997-11-25 06:05:25 +08:00
has_alpha , srcPR . bytes , destPR . bytes , destPR . w ) ;
s + = srcPR . rowstride ;
break ;
case PatternClone :
1998-01-22 15:02:57 +08:00
clone_line_pattern ( gimage , drawable , pattern , d ,
1997-11-25 06:05:25 +08:00
area - > x + offset_x , area - > y + y + offset_y ,
destPR . bytes , destPR . w ) ;
break ;
}
d + = destPR . rowstride ;
}
}
/* paste the newly painted canvas to the gimage which is being worked on */
1998-01-25 09:24:46 +08:00
paint_core_paste_canvas ( paint_core , drawable , OPAQUE_OPACITY ,
1998-07-09 13:31:06 +08:00
( int ) ( gimp_brush_get_opacity ( ) * 255 ) ,
gimp_brush_get_paint_mode ( ) , SOFT , CONSTANT ) ;
1997-11-25 06:05:25 +08:00
}
static void
clone_line_image ( GImage * dest ,
GImage * src ,
1998-01-22 15:02:57 +08:00
GimpDrawable * d_drawable ,
GimpDrawable * s_drawable ,
1997-11-25 06:05:25 +08:00
unsigned char * s ,
unsigned char * d ,
int has_alpha ,
int src_bytes ,
int dest_bytes ,
int width )
{
unsigned char rgb [ 3 ] ;
int src_alpha , dest_alpha ;
src_alpha = src_bytes - 1 ;
dest_alpha = dest_bytes - 1 ;
while ( width - - )
{
gimage_get_color ( src , drawable_type ( s_drawable ) , rgb , s ) ;
gimage_transform_color ( dest , d_drawable , rgb , d , RGB ) ;
if ( has_alpha )
d [ dest_alpha ] = s [ src_alpha ] ;
else
1998-01-25 09:24:46 +08:00
d [ dest_alpha ] = OPAQUE_OPACITY ;
1997-11-25 06:05:25 +08:00
s + = src_bytes ;
d + = dest_bytes ;
}
}
static void
clone_line_pattern ( GImage * dest ,
1998-01-22 15:02:57 +08:00
GimpDrawable * drawable ,
1997-11-25 06:05:25 +08:00
GPatternP pattern ,
unsigned char * d ,
int x ,
int y ,
int bytes ,
int width )
{
unsigned char * pat , * p ;
int color , alpha ;
int i ;
/* 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 * pattern - > mask - > bytes ;
color = ( pattern - > mask - > bytes = = 3 ) ? RGB : GRAY ;
alpha = bytes - 1 ;
for ( i = 0 ; i < width ; i + + )
{
p = pat + ( ( i + x ) % pattern - > mask - > width ) * pattern - > mask - > bytes ;
1998-01-22 15:02:57 +08:00
gimage_transform_color ( dest , drawable , p , d , color ) ;
1997-11-25 06:05:25 +08:00
1998-01-25 09:24:46 +08:00
d [ alpha ] = OPAQUE_OPACITY ;
1997-11-25 06:05:25 +08:00
d + = bytes ;
}
}
static void *
clone_non_gui_paint_func ( PaintCore * paint_core ,
1998-01-22 15:02:57 +08:00
GimpDrawable * drawable ,
1997-11-25 06:05:25 +08:00
int state )
{
1998-01-22 15:02:57 +08:00
clone_motion ( paint_core , drawable , non_gui_src_drawable ,
1997-11-25 06:05:25 +08:00
non_gui_type , non_gui_offset_x , non_gui_offset_y ) ;
return NULL ;
}
/* The clone procedure definition */
ProcArg clone_args [ ] =
{
{ PDB_DRAWABLE ,
" drawable " ,
1998-12-16 08:37:09 +08:00
" the drawable "
1997-11-25 06:05:25 +08:00
} ,
{ PDB_DRAWABLE ,
" src_drawable " ,
1998-12-16 08:37:09 +08:00
" the source drawable "
1997-11-25 06:05:25 +08:00
} ,
{ PDB_INT32 ,
" clone_type " ,
1998-12-16 08:37:09 +08:00
" the type of clone: { IMAGE-CLONE (0), PATTERN-CLONE (1) } "
1997-11-25 06:05:25 +08:00
} ,
{ PDB_FLOAT ,
" src_x " ,
1998-12-16 08:37:09 +08:00
" the x coordinate in the source image "
1997-11-25 06:05:25 +08:00
} ,
{ PDB_FLOAT ,
" src_y " ,
1998-12-16 08:37:09 +08:00
" the y coordinate in the source image "
1997-11-25 06:05:25 +08:00
} ,
{ PDB_INT32 ,
" num_strokes " ,
1998-12-16 08:37:09 +08:00
" number of stroke control points (count each coordinate as 2 points) "
1997-11-25 06:05:25 +08:00
} ,
{ PDB_FLOATARRAY ,
" strokes " ,
1998-12-16 08:37:09 +08:00
" array of stroke coordinates: {s1.x, s1.y, s2.x, s2.y, ..., sn.x, sn.y} "
1997-11-25 06:05:25 +08:00
}
} ;
ProcRecord clone_proc =
{
" gimp_clone " ,
1998-12-16 08:37:09 +08:00
" Clone from the source to the dest drawable using the current brush " ,
" This tool clones (copies) from the source drawable starting at the specified source coordinates to the dest drawable. If the \" clone_type \" argument is set to PATTERN-CLONE, then the current pattern is used as the source and the \" src_drawable \" argument is ignored. Pattern cloning assumes a tileable pattern and mods the sum of the src coordinates and subsequent stroke offsets with the width and height of the pattern. For image cloning, if the sum of the src coordinates and subsequent stroke offsets exceeds the extents of the src drawable, then no paint is transferred. The clone tool is capable of transforming between any image types including RGB->Indexed--although converting from any type to indexed is significantly slower. " ,
1997-11-25 06:05:25 +08:00
" Spencer Kimball & Peter Mattis " ,
" Spencer Kimball & Peter Mattis " ,
" 1995-1996 " ,
PDB_INTERNAL ,
/* Input arguments */
API-mega-break-it-all patch part one: removed the unnecessary PDB_IMAGE
* airbrush.c, blend.c, brightness_contrast.c, bucket_fill.c
by_color_select.c, channel_ops.c, clone.c, color_balance.c
color_picker.c, convolve.c, curves.c, desaturate.c, edit_cmds.c
equalize.c, eraser.c, flip_tool.c, fuzzy_select.c,
gimage_mask_cmds.c histogram_tool.c, hue_saturation.c, invert.c,
levels.c, pencil.c paintbrush.c, perspective_tool.c, posterize.c,
rotate_tool.c scale_tool.c, shear_tool.c, text_tool.c, threshold.c:
API-mega-break-it-all patch part one: removed the unnecessary
PDB_IMAGE argument from many functions.
Affected functions:
gimp_airbrush gimp_blend gimp_brightness_contrast gimp_bucket_fill
gimp_by_color_select gimp_channel_ops_offset gimp_clone gimp_color_balance
gimp_color_picker gimp_convolve gimp_curves_explicit gimp_curves_spline
gimp_desaturate gimp_edit_clear gimp_edit_copy gimp_edit_cut gimp_edit_fill
gimp_edit_paste gimp_edit_stroke gimp_equalize gimp_eraser
gimp_eraser_extended gimp_flip gimp_fuzzy_select gimp_histogram
gimp_hue_saturation gimp_invert gimp_levels gimp_paintbrush
gimp_paintbrush_extended gimp_pencil gimp_perspective gimp_posterize
gimp_rotate gimp_scale gimp_selection_float gimp_selection_layer_alpha
gimp_selection_load gimp_shear gimp_threshold
1998-11-14 04:40:00 +08:00
7 ,
1997-11-25 06:05:25 +08:00
clone_args ,
/* Output arguments */
0 ,
NULL ,
/* Exec method */
{ { clone_invoker } } ,
} ;
static Argument *
clone_invoker ( Argument * args )
{
int success = TRUE ;
GImage * gimage ;
1998-01-22 15:02:57 +08:00
GimpDrawable * drawable ;
GimpDrawable * src_drawable ;
1997-11-25 06:05:25 +08:00
double src_x , src_y ;
int num_strokes ;
double * stroke_array ;
CloneType int_value ;
int i ;
1998-01-22 15:02:57 +08:00
drawable = NULL ;
1997-11-25 06:05:25 +08:00
num_strokes = 0 ;
/* the drawable */
if ( success )
{
API-mega-break-it-all patch part one: removed the unnecessary PDB_IMAGE
* airbrush.c, blend.c, brightness_contrast.c, bucket_fill.c
by_color_select.c, channel_ops.c, clone.c, color_balance.c
color_picker.c, convolve.c, curves.c, desaturate.c, edit_cmds.c
equalize.c, eraser.c, flip_tool.c, fuzzy_select.c,
gimage_mask_cmds.c histogram_tool.c, hue_saturation.c, invert.c,
levels.c, pencil.c paintbrush.c, perspective_tool.c, posterize.c,
rotate_tool.c scale_tool.c, shear_tool.c, text_tool.c, threshold.c:
API-mega-break-it-all patch part one: removed the unnecessary
PDB_IMAGE argument from many functions.
Affected functions:
gimp_airbrush gimp_blend gimp_brightness_contrast gimp_bucket_fill
gimp_by_color_select gimp_channel_ops_offset gimp_clone gimp_color_balance
gimp_color_picker gimp_convolve gimp_curves_explicit gimp_curves_spline
gimp_desaturate gimp_edit_clear gimp_edit_copy gimp_edit_cut gimp_edit_fill
gimp_edit_paste gimp_edit_stroke gimp_equalize gimp_eraser
gimp_eraser_extended gimp_flip gimp_fuzzy_select gimp_histogram
gimp_hue_saturation gimp_invert gimp_levels gimp_paintbrush
gimp_paintbrush_extended gimp_pencil gimp_perspective gimp_posterize
gimp_rotate gimp_scale gimp_selection_float gimp_selection_layer_alpha
gimp_selection_load gimp_shear gimp_threshold
1998-11-14 04:40:00 +08:00
int_value = args [ 0 ] . value . pdb_int ;
1998-01-22 15:02:57 +08:00
drawable = drawable_get_ID ( int_value ) ;
API-mega-break-it-all patch part one: removed the unnecessary PDB_IMAGE
* airbrush.c, blend.c, brightness_contrast.c, bucket_fill.c
by_color_select.c, channel_ops.c, clone.c, color_balance.c
color_picker.c, convolve.c, curves.c, desaturate.c, edit_cmds.c
equalize.c, eraser.c, flip_tool.c, fuzzy_select.c,
gimage_mask_cmds.c histogram_tool.c, hue_saturation.c, invert.c,
levels.c, pencil.c paintbrush.c, perspective_tool.c, posterize.c,
rotate_tool.c scale_tool.c, shear_tool.c, text_tool.c, threshold.c:
API-mega-break-it-all patch part one: removed the unnecessary
PDB_IMAGE argument from many functions.
Affected functions:
gimp_airbrush gimp_blend gimp_brightness_contrast gimp_bucket_fill
gimp_by_color_select gimp_channel_ops_offset gimp_clone gimp_color_balance
gimp_color_picker gimp_convolve gimp_curves_explicit gimp_curves_spline
gimp_desaturate gimp_edit_clear gimp_edit_copy gimp_edit_cut gimp_edit_fill
gimp_edit_paste gimp_edit_stroke gimp_equalize gimp_eraser
gimp_eraser_extended gimp_flip gimp_fuzzy_select gimp_histogram
gimp_hue_saturation gimp_invert gimp_levels gimp_paintbrush
gimp_paintbrush_extended gimp_pencil gimp_perspective gimp_posterize
gimp_rotate gimp_scale gimp_selection_float gimp_selection_layer_alpha
gimp_selection_load gimp_shear gimp_threshold
1998-11-14 04:40:00 +08:00
if ( drawable = = NULL )
success = FALSE ;
else
gimage = drawable_gimage ( drawable ) ;
1997-11-25 06:05:25 +08:00
}
/* the src drawable */
if ( success )
{
API-mega-break-it-all patch part one: removed the unnecessary PDB_IMAGE
* airbrush.c, blend.c, brightness_contrast.c, bucket_fill.c
by_color_select.c, channel_ops.c, clone.c, color_balance.c
color_picker.c, convolve.c, curves.c, desaturate.c, edit_cmds.c
equalize.c, eraser.c, flip_tool.c, fuzzy_select.c,
gimage_mask_cmds.c histogram_tool.c, hue_saturation.c, invert.c,
levels.c, pencil.c paintbrush.c, perspective_tool.c, posterize.c,
rotate_tool.c scale_tool.c, shear_tool.c, text_tool.c, threshold.c:
API-mega-break-it-all patch part one: removed the unnecessary
PDB_IMAGE argument from many functions.
Affected functions:
gimp_airbrush gimp_blend gimp_brightness_contrast gimp_bucket_fill
gimp_by_color_select gimp_channel_ops_offset gimp_clone gimp_color_balance
gimp_color_picker gimp_convolve gimp_curves_explicit gimp_curves_spline
gimp_desaturate gimp_edit_clear gimp_edit_copy gimp_edit_cut gimp_edit_fill
gimp_edit_paste gimp_edit_stroke gimp_equalize gimp_eraser
gimp_eraser_extended gimp_flip gimp_fuzzy_select gimp_histogram
gimp_hue_saturation gimp_invert gimp_levels gimp_paintbrush
gimp_paintbrush_extended gimp_pencil gimp_perspective gimp_posterize
gimp_rotate gimp_scale gimp_selection_float gimp_selection_layer_alpha
gimp_selection_load gimp_shear gimp_threshold
1998-11-14 04:40:00 +08:00
int_value = args [ 1 ] . value . pdb_int ;
1998-01-22 15:02:57 +08:00
src_drawable = drawable_get_ID ( int_value ) ;
if ( src_drawable = = NULL | | gimage ! = drawable_gimage ( src_drawable ) )
1997-11-25 06:05:25 +08:00
success = FALSE ;
else
1998-01-22 15:02:57 +08:00
non_gui_src_drawable = src_drawable ;
1997-11-25 06:05:25 +08:00
}
/* the clone type */
if ( success )
{
API-mega-break-it-all patch part one: removed the unnecessary PDB_IMAGE
* airbrush.c, blend.c, brightness_contrast.c, bucket_fill.c
by_color_select.c, channel_ops.c, clone.c, color_balance.c
color_picker.c, convolve.c, curves.c, desaturate.c, edit_cmds.c
equalize.c, eraser.c, flip_tool.c, fuzzy_select.c,
gimage_mask_cmds.c histogram_tool.c, hue_saturation.c, invert.c,
levels.c, pencil.c paintbrush.c, perspective_tool.c, posterize.c,
rotate_tool.c scale_tool.c, shear_tool.c, text_tool.c, threshold.c:
API-mega-break-it-all patch part one: removed the unnecessary
PDB_IMAGE argument from many functions.
Affected functions:
gimp_airbrush gimp_blend gimp_brightness_contrast gimp_bucket_fill
gimp_by_color_select gimp_channel_ops_offset gimp_clone gimp_color_balance
gimp_color_picker gimp_convolve gimp_curves_explicit gimp_curves_spline
gimp_desaturate gimp_edit_clear gimp_edit_copy gimp_edit_cut gimp_edit_fill
gimp_edit_paste gimp_edit_stroke gimp_equalize gimp_eraser
gimp_eraser_extended gimp_flip gimp_fuzzy_select gimp_histogram
gimp_hue_saturation gimp_invert gimp_levels gimp_paintbrush
gimp_paintbrush_extended gimp_pencil gimp_perspective gimp_posterize
gimp_rotate gimp_scale gimp_selection_float gimp_selection_layer_alpha
gimp_selection_load gimp_shear gimp_threshold
1998-11-14 04:40:00 +08:00
int_value = args [ 2 ] . value . pdb_int ;
1997-11-25 06:05:25 +08:00
switch ( int_value )
{
case 0 : non_gui_type = ImageClone ; break ;
case 1 : non_gui_type = PatternClone ; break ;
default : success = FALSE ;
}
}
/* x, y offsets */
if ( success )
{
API-mega-break-it-all patch part one: removed the unnecessary PDB_IMAGE
* airbrush.c, blend.c, brightness_contrast.c, bucket_fill.c
by_color_select.c, channel_ops.c, clone.c, color_balance.c
color_picker.c, convolve.c, curves.c, desaturate.c, edit_cmds.c
equalize.c, eraser.c, flip_tool.c, fuzzy_select.c,
gimage_mask_cmds.c histogram_tool.c, hue_saturation.c, invert.c,
levels.c, pencil.c paintbrush.c, perspective_tool.c, posterize.c,
rotate_tool.c scale_tool.c, shear_tool.c, text_tool.c, threshold.c:
API-mega-break-it-all patch part one: removed the unnecessary
PDB_IMAGE argument from many functions.
Affected functions:
gimp_airbrush gimp_blend gimp_brightness_contrast gimp_bucket_fill
gimp_by_color_select gimp_channel_ops_offset gimp_clone gimp_color_balance
gimp_color_picker gimp_convolve gimp_curves_explicit gimp_curves_spline
gimp_desaturate gimp_edit_clear gimp_edit_copy gimp_edit_cut gimp_edit_fill
gimp_edit_paste gimp_edit_stroke gimp_equalize gimp_eraser
gimp_eraser_extended gimp_flip gimp_fuzzy_select gimp_histogram
gimp_hue_saturation gimp_invert gimp_levels gimp_paintbrush
gimp_paintbrush_extended gimp_pencil gimp_perspective gimp_posterize
gimp_rotate gimp_scale gimp_selection_float gimp_selection_layer_alpha
gimp_selection_load gimp_shear gimp_threshold
1998-11-14 04:40:00 +08:00
src_x = args [ 3 ] . value . pdb_float ;
src_y = args [ 4 ] . value . pdb_float ;
1997-11-25 06:05:25 +08:00
}
/* num strokes */
if ( success )
{
API-mega-break-it-all patch part one: removed the unnecessary PDB_IMAGE
* airbrush.c, blend.c, brightness_contrast.c, bucket_fill.c
by_color_select.c, channel_ops.c, clone.c, color_balance.c
color_picker.c, convolve.c, curves.c, desaturate.c, edit_cmds.c
equalize.c, eraser.c, flip_tool.c, fuzzy_select.c,
gimage_mask_cmds.c histogram_tool.c, hue_saturation.c, invert.c,
levels.c, pencil.c paintbrush.c, perspective_tool.c, posterize.c,
rotate_tool.c scale_tool.c, shear_tool.c, text_tool.c, threshold.c:
API-mega-break-it-all patch part one: removed the unnecessary
PDB_IMAGE argument from many functions.
Affected functions:
gimp_airbrush gimp_blend gimp_brightness_contrast gimp_bucket_fill
gimp_by_color_select gimp_channel_ops_offset gimp_clone gimp_color_balance
gimp_color_picker gimp_convolve gimp_curves_explicit gimp_curves_spline
gimp_desaturate gimp_edit_clear gimp_edit_copy gimp_edit_cut gimp_edit_fill
gimp_edit_paste gimp_edit_stroke gimp_equalize gimp_eraser
gimp_eraser_extended gimp_flip gimp_fuzzy_select gimp_histogram
gimp_hue_saturation gimp_invert gimp_levels gimp_paintbrush
gimp_paintbrush_extended gimp_pencil gimp_perspective gimp_posterize
gimp_rotate gimp_scale gimp_selection_float gimp_selection_layer_alpha
gimp_selection_load gimp_shear gimp_threshold
1998-11-14 04:40:00 +08:00
int_value = args [ 5 ] . value . pdb_int ;
1997-11-25 06:05:25 +08:00
if ( int_value > 0 )
num_strokes = int_value / 2 ;
else
success = FALSE ;
}
/* point array */
if ( success )
API-mega-break-it-all patch part one: removed the unnecessary PDB_IMAGE
* airbrush.c, blend.c, brightness_contrast.c, bucket_fill.c
by_color_select.c, channel_ops.c, clone.c, color_balance.c
color_picker.c, convolve.c, curves.c, desaturate.c, edit_cmds.c
equalize.c, eraser.c, flip_tool.c, fuzzy_select.c,
gimage_mask_cmds.c histogram_tool.c, hue_saturation.c, invert.c,
levels.c, pencil.c paintbrush.c, perspective_tool.c, posterize.c,
rotate_tool.c scale_tool.c, shear_tool.c, text_tool.c, threshold.c:
API-mega-break-it-all patch part one: removed the unnecessary
PDB_IMAGE argument from many functions.
Affected functions:
gimp_airbrush gimp_blend gimp_brightness_contrast gimp_bucket_fill
gimp_by_color_select gimp_channel_ops_offset gimp_clone gimp_color_balance
gimp_color_picker gimp_convolve gimp_curves_explicit gimp_curves_spline
gimp_desaturate gimp_edit_clear gimp_edit_copy gimp_edit_cut gimp_edit_fill
gimp_edit_paste gimp_edit_stroke gimp_equalize gimp_eraser
gimp_eraser_extended gimp_flip gimp_fuzzy_select gimp_histogram
gimp_hue_saturation gimp_invert gimp_levels gimp_paintbrush
gimp_paintbrush_extended gimp_pencil gimp_perspective gimp_posterize
gimp_rotate gimp_scale gimp_selection_float gimp_selection_layer_alpha
gimp_selection_load gimp_shear gimp_threshold
1998-11-14 04:40:00 +08:00
stroke_array = ( double * ) args [ 6 ] . value . pdb_pointer ;
1997-11-25 06:05:25 +08:00
if ( success )
/* init the paint core */
1998-01-22 15:02:57 +08:00
success = paint_core_init ( & non_gui_paint_core , drawable ,
1997-11-25 06:05:25 +08:00
stroke_array [ 0 ] , stroke_array [ 1 ] ) ;
if ( success )
{
/* set the paint core's paint func */
non_gui_paint_core . paint_func = clone_non_gui_paint_func ;
non_gui_paint_core . startx = non_gui_paint_core . lastx = stroke_array [ 0 ] ;
non_gui_paint_core . starty = non_gui_paint_core . lasty = stroke_array [ 1 ] ;
non_gui_offset_x = ( int ) ( src_x - non_gui_paint_core . startx ) ;
non_gui_offset_y = ( int ) ( src_y - non_gui_paint_core . starty ) ;
if ( num_strokes = = 1 )
1998-01-22 15:02:57 +08:00
clone_non_gui_paint_func ( & non_gui_paint_core , drawable , 0 ) ;
1997-11-25 06:05:25 +08:00
for ( i = 1 ; i < num_strokes ; i + + )
{
non_gui_paint_core . curx = stroke_array [ i * 2 + 0 ] ;
non_gui_paint_core . cury = stroke_array [ i * 2 + 1 ] ;
1998-01-22 15:02:57 +08:00
paint_core_interpolate ( & non_gui_paint_core , drawable ) ;
1997-11-25 06:05:25 +08:00
non_gui_paint_core . lastx = non_gui_paint_core . curx ;
non_gui_paint_core . lasty = non_gui_paint_core . cury ;
}
/* finish the painting */
1998-01-22 15:02:57 +08:00
paint_core_finish ( & non_gui_paint_core , drawable , - 1 ) ;
1997-11-25 06:05:25 +08:00
/* cleanup */
paint_core_cleanup ( ) ;
}
return procedural_db_return_args ( & clone_proc , success ) ;
}