deprecate _copy() inplace ops

This commit is contained in:
John Cupitt 2010-09-22 12:51:52 +00:00
parent 72c402eba8
commit de026e0750
10 changed files with 249 additions and 192 deletions

View File

@ -20,6 +20,8 @@
- add IM_TYPE_RW flag for im__rw_image, helps nip2 auto-wrap inplace ops - add IM_TYPE_RW flag for im__rw_image, helps nip2 auto-wrap inplace ops
- im_insertplace() casts and bandalikes - im_insertplace() casts and bandalikes
- copy iconv.m4 and friends in bootstrap, thanks Mike - copy iconv.m4 and friends in bootstrap, thanks Mike
- moved the stupid _copy() versions of the inplace ops to deprecated, since
nip2 can call inplace ops directly now
12/5/10 started 7.22.2 12/5/10 started 7.22.2
- the conditional image of ifthenelse can be any format, a (!=0) is added if - the conditional image of ifthenelse can be any format, a (!=0) is added if

2
TODO
View File

@ -4,8 +4,6 @@
- use im__inplace_base() in more places - use im__inplace_base() in more places
- nip2 should be able to call RW image ops by copying them, see
im_draw_circle_copy()

View File

@ -1251,9 +1251,140 @@ static im_function circle_desc = {
circle_args /* Arg list */ circle_args /* Arg list */
}; };
/* Args for im_flood_blob_copy().
*/
static im_arg_desc flood_blob_copy_args[] = {
IM_INPUT_IMAGE( "in" ),
IM_OUTPUT_IMAGE( "out" ),
IM_INPUT_INT( "start_x" ),
IM_INPUT_INT( "start_y" ),
IM_INPUT_DOUBLEVEC( "ink" )
};
/* Call im_flood_blob_copy() via arg vector.
*/
static int
flood_blob_copy_vec( im_object *argv )
{
IMAGE *in = argv[0];
IMAGE *out = argv[1];
int start_x = *((int *) argv[2]);
int start_y = *((int *) argv[3]);
im_doublevec_object *dv = (im_doublevec_object *) argv[4];
PEL *ink;
if( dv->n != in->Bands ) {
im_error( "im_flood_blob_copy",
"%s", _( "bad vector length" ) );
return( -1 );
}
if( !(ink = im__vector_to_ink( in, dv->vec )) )
return( -1 );
return( im_flood_blob_copy( in, out, start_x, start_y, ink ) );
}
/* Description of im_flood_blob_copy().
*/
static im_function flood_blob_copy_desc = {
"im_flood_blob_copy", /* Name */
"flood with ink from start_x, start_y while pixel == start pixel",
0, /* Flags */
flood_blob_copy_vec, /* Dispatch function */
IM_NUMBER( flood_blob_copy_args ),/* Size of arg list */
flood_blob_copy_args /* Arg list */
};
/* Args for im_flood_copy().
*/
static im_arg_desc flood_copy_args[] = {
IM_INPUT_IMAGE( "in" ),
IM_OUTPUT_IMAGE( "out" ),
IM_INPUT_INT( "start_x" ),
IM_INPUT_INT( "start_y" ),
IM_INPUT_DOUBLEVEC( "ink" )
};
/* Call im_flood_copy() via arg vector.
*/
static int
flood_copy_vec( im_object *argv )
{
IMAGE *in = argv[0];
IMAGE *out = argv[1];
int start_x = *((int *) argv[2]);
int start_y = *((int *) argv[3]);
im_doublevec_object *dv = (im_doublevec_object *) argv[4];
PEL *ink;
if( dv->n != in->Bands ) {
im_error( "im_flood_copy",
"%s", _( "bad vector length" ) );
return( -1 );
}
if( !(ink = im__vector_to_ink( in, dv->vec )) )
return( -1 );
return( im_flood_copy( in, out, start_x, start_y, ink ) );
}
/* Description of im_flood_copy().
*/
static im_function flood_copy_desc = {
"im_flood_copy", /* Name */
"flood with ink from start_x, start_y while pixel == start pixel",
0, /* Flags */
flood_copy_vec, /* Dispatch function */
IM_NUMBER( flood_copy_args ),/* Size of arg list */
flood_copy_args /* Arg list */
};
/* Args for im_flood_other_copy().
*/
static im_arg_desc flood_other_copy_args[] = {
IM_INPUT_IMAGE( "test" ),
IM_INPUT_IMAGE( "mark" ),
IM_OUTPUT_IMAGE( "out" ),
IM_INPUT_INT( "start_x" ),
IM_INPUT_INT( "start_y" ),
IM_INPUT_INT( "serial" )
};
/* Call im_flood_other_copy() via arg vector.
*/
static int
flood_other_copy_vec( im_object *argv )
{
IMAGE *test = argv[0];
IMAGE *mark = argv[1];
IMAGE *out = argv[2];
int start_x = *((int *) argv[3]);
int start_y = *((int *) argv[4]);
int serial = *((int *) argv[5]);
return( im_flood_other_copy( test, mark, out,
start_x, start_y, serial ) );
}
/* Description of im_flood_other_copy().
*/
static im_function flood_other_copy_desc = {
"im_flood_other_copy", /* Name */
"flood mark with serial from start_x, start_y while pixel == start pixel",
0, /* Flags */
flood_other_copy_vec, /* Dispatch function */
IM_NUMBER( flood_other_copy_args ),/* Size of arg list */
flood_other_copy_args /* Arg list */
};
/* Package up all these functions. /* Package up all these functions.
*/ */
static im_function *deprecated_list[] = { static im_function *deprecated_list[] = {
&flood_copy_desc,
&flood_blob_copy_desc,
&flood_other_copy_desc,
&clip_desc, &clip_desc,
&c2ps_desc, &c2ps_desc,
&resize_linear_desc, &resize_linear_desc,

View File

@ -458,3 +458,51 @@ im_circle( IMAGE *im, int cx, int cy, int radius, int intensity )
return( im_draw_circle( im, cx, cy, radius, FALSE, ink ) ); return( im_draw_circle( im, cx, cy, radius, FALSE, ink ) );
} }
/* A flood blob we can call from nip. Grr! Should be a way to wrap these
* automatically. Maybe nip could do it if it sees a RW image argument?
*/
int
im_flood_copy( IMAGE *in, IMAGE *out, int x, int y, PEL *ink )
{
IMAGE *t;
if( !(t = im_open_local( out, "im_flood_blob_copy", "t" )) ||
im_copy( in, t ) ||
im_flood( t, x, y, ink, NULL ) ||
im_copy( t, out ) )
return( -1 );
return( 0 );
}
int
im_flood_blob_copy( IMAGE *in, IMAGE *out, int x, int y, PEL *ink )
{
IMAGE *t;
if( !(t = im_open_local( out, "im_flood_blob_copy", "t" )) ||
im_copy( in, t ) ||
im_flood_blob( t, x, y, ink, NULL ) ||
im_copy( t, out ) )
return( -1 );
return( 0 );
}
int
im_flood_other_copy( IMAGE *test, IMAGE *mark, IMAGE *out,
int x, int y, int serial )
{
IMAGE *t;
if( !(t = im_open_local( out, "im_flood_other_copy", "t" )) ||
im_copy( mark, t ) ||
im_flood_other( test, t, x, y, serial, NULL ) ||
im_copy( t, out ) )
return( -1 );
return( 0 );
}

View File

@ -232,6 +232,11 @@ int im_circle( IMAGE *im, int cx, int cy, int radius, int intensity );
int im_line( IMAGE *, int, int, int, int, int ); int im_line( IMAGE *, int, int, int, int, int );
int im_segment( IMAGE *test, IMAGE *mask, int *segments ); int im_segment( IMAGE *test, IMAGE *mask, int *segments );
int im_flood_copy( IMAGE *in, IMAGE *out, int x, int y, PEL *ink );
int im_flood_blob_copy( IMAGE *in, IMAGE *out, int x, int y, PEL *ink );
int im_flood_other_copy( IMAGE *test, IMAGE *mark, IMAGE *out,
int x, int y, int serial );
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif /*__cplusplus*/ #endif /*__cplusplus*/

View File

@ -43,8 +43,6 @@ int im_smudge( IMAGE *im, int ix, int iy, Rect *r );
int im_paintrect( IMAGE *im, Rect *r, PEL *ink ); int im_paintrect( IMAGE *im, Rect *r, PEL *ink );
int im_draw_circle( IMAGE *im, int im_draw_circle( IMAGE *im,
int cx, int cy, int radius, gboolean fill, PEL *ink ); int cx, int cy, int radius, gboolean fill, PEL *ink );
int im_draw_circle_copy( IMAGE *in, IMAGE *out,
int cx, int cy, int radius, gboolean fill, PEL *ink );
int im_insertplace( IMAGE *main, IMAGE *sub, int x, int y ); int im_insertplace( IMAGE *main, IMAGE *sub, int x, int y );
int im_fastline( IMAGE *im, int x1, int y1, int x2, int y2, PEL *pel ); int im_fastline( IMAGE *im, int x1, int y1, int x2, int y2, PEL *pel );
int im_fastlineuser( IMAGE *im, int im_fastlineuser( IMAGE *im,
@ -57,11 +55,6 @@ int im_flood_blob( IMAGE *im, int x, int y, PEL *ink, Rect *dout );
int im_flood_other( IMAGE *test, IMAGE *mark, int im_flood_other( IMAGE *test, IMAGE *mark,
int x, int y, int serial, Rect *dout ); int x, int y, int serial, Rect *dout );
int im_flood_copy( IMAGE *in, IMAGE *out, int x, int y, PEL *ink );
int im_flood_blob_copy( IMAGE *in, IMAGE *out, int x, int y, PEL *ink );
int im_flood_other_copy( IMAGE *test, IMAGE *mark, IMAGE *out,
int x, int y, int serial );
int im_lineset( IMAGE *in, IMAGE *out, IMAGE *mask, IMAGE *ink, int im_lineset( IMAGE *in, IMAGE *out, IMAGE *mask, IMAGE *ink,
int n, int *x1v, int *y1v, int *x2v, int *y2v ); int n, int *x1v, int *y1v, int *x2v, int *y2v );

View File

@ -277,6 +277,7 @@ int im__fmaskcir( IMAGE *out, VipsMaskType flag, va_list ap );
/* inplace /* inplace
*/ */
PEL *im__vector_to_ink( IMAGE *im, double *vec );
IMAGE *im__inplace_base( const char *domain, IMAGE *im__inplace_base( const char *domain,
IMAGE *main, IMAGE *sub, IMAGE *out ); IMAGE *main, IMAGE *sub, IMAGE *out );

View File

@ -593,51 +593,3 @@ im_flood_other( IMAGE *test, IMAGE *mark, int x, int y, int serial, Rect *dout )
return( 0 ); return( 0 );
} }
/* A flood blob we can call from nip. Grr! Should be a way to wrap these
* automatically. Maybe nip could do it if it sees a RW image argument?
*/
int
im_flood_copy( IMAGE *in, IMAGE *out, int x, int y, PEL *ink )
{
IMAGE *t;
if( !(t = im_open_local( out, "im_flood_blob_copy", "t" )) ||
im_copy( in, t ) ||
im_flood( t, x, y, ink, NULL ) ||
im_copy( t, out ) )
return( -1 );
return( 0 );
}
int
im_flood_blob_copy( IMAGE *in, IMAGE *out, int x, int y, PEL *ink )
{
IMAGE *t;
if( !(t = im_open_local( out, "im_flood_blob_copy", "t" )) ||
im_copy( in, t ) ||
im_flood_blob( t, x, y, ink, NULL ) ||
im_copy( t, out ) )
return( -1 );
return( 0 );
}
int
im_flood_other_copy( IMAGE *test, IMAGE *mark, IMAGE *out,
int x, int y, int serial )
{
IMAGE *t;
if( !(t = im_open_local( out, "im_flood_other_copy", "t" )) ||
im_copy( mark, t ) ||
im_flood_other( test, t, x, y, serial, NULL ) ||
im_copy( t, out ) )
return( -1 );
return( 0 );
}

View File

@ -277,22 +277,3 @@ im_draw_circle( IMAGE *im, int cx, int cy, int radius, gboolean fill, PEL *ink )
return( 0 ); return( 0 );
} }
/* One we can call from nip. Grr! Should be a way to wrap these
* automatically. Maybe nip could do it if it sees a RW image argument?
*/
int
im_draw_circle_copy( IMAGE *in, IMAGE *out,
int cx, int cy, int radius, gboolean fill, PEL *ink )
{
IMAGE *t;
if( !(t = im_open_local( out, "im_flood_blob_copy", "t" )) ||
im_copy( in, t ) ||
im_draw_circle( t, cx, cy, radius, fill, ink ) ||
im_copy( t, out ) )
return( -1 );
return( 0 );
}

View File

@ -131,8 +131,8 @@ static im_function lineset_desc = {
/* Calculate a pixel for an image from a vec of double. Valid while im is /* Calculate a pixel for an image from a vec of double. Valid while im is
* valid. * valid.
*/ */
static PEL * PEL *
vector_to_ink( IMAGE *im, double *vec ) im__vector_to_ink( IMAGE *im, double *vec )
{ {
const int n = im->Bands; const int n = im->Bands;
@ -154,132 +154,123 @@ vector_to_ink( IMAGE *im, double *vec )
return( (PEL *) t[2]->data ); return( (PEL *) t[2]->data );
} }
/* Args for im_flood_blob_copy(). /* Args for im_flood_blob().
*/ */
static im_arg_desc flood_blob_copy_args[] = { static im_arg_desc flood_blob_args[] = {
IM_INPUT_IMAGE( "in" ), IM_RW_IMAGE( "image" ),
IM_OUTPUT_IMAGE( "out" ),
IM_INPUT_INT( "start_x" ), IM_INPUT_INT( "start_x" ),
IM_INPUT_INT( "start_y" ), IM_INPUT_INT( "start_y" ),
IM_INPUT_DOUBLEVEC( "ink" ) IM_INPUT_DOUBLEVEC( "ink" )
}; };
/* Call im_flood_blob_copy() via arg vector. /* Call im_flood_blob() via arg vector.
*/ */
static int static int
flood_blob_copy_vec( im_object *argv ) flood_blob_vec( im_object *argv )
{ {
IMAGE *in = argv[0]; IMAGE *image = argv[0];
IMAGE *out = argv[1]; int start_x = *((int *) argv[1]);
int start_x = *((int *) argv[2]); int start_y = *((int *) argv[2]);
int start_y = *((int *) argv[3]); im_doublevec_object *dv = (im_doublevec_object *) argv[3];
im_doublevec_object *dv = (im_doublevec_object *) argv[4];
PEL *ink; PEL *ink;
if( dv->n != in->Bands ) { if( dv->n != image->Bands ) {
im_error( "im_flood_blob_copy", im_error( "im_flood_blob", "%s", _( "bad vector length" ) );
"%s", _( "bad vector length" ) );
return( -1 ); return( -1 );
} }
if( !(ink = vector_to_ink( in, dv->vec )) ) if( !(ink = im__vector_to_ink( image, dv->vec )) )
return( -1 ); return( -1 );
return( im_flood_blob_copy( in, out, start_x, start_y, ink ) ); return( im_flood_blob( image, start_x, start_y, ink, NULL ) );
} }
/* Description of im_flood_blob_copy(). /* Description of im_flood_blob().
*/ */
static im_function flood_blob_copy_desc = { static im_function flood_blob_desc = {
"im_flood_blob_copy", /* Name */ "im_flood_blob", /* Name */
"flood with ink from start_x, start_y while pixel == start pixel", "flood with ink from start_x, start_y while pixel == start pixel",
0, /* Flags */ 0, /* Flags */
flood_blob_copy_vec, /* Dispatch function */ flood_blob_vec, /* Dispatch function */
IM_NUMBER( flood_blob_copy_args ),/* Size of arg list */ IM_NUMBER( flood_blob_args ),/* Size of arg list */
flood_blob_copy_args /* Arg list */ flood_blob_args /* Arg list */
}; };
/* Args for im_flood_copy(). /* Args for im_flood().
*/ */
static im_arg_desc flood_copy_args[] = { static im_arg_desc flood_args[] = {
IM_INPUT_IMAGE( "in" ), IM_RW_IMAGE( "image" ),
IM_OUTPUT_IMAGE( "out" ),
IM_INPUT_INT( "start_x" ), IM_INPUT_INT( "start_x" ),
IM_INPUT_INT( "start_y" ), IM_INPUT_INT( "start_y" ),
IM_INPUT_DOUBLEVEC( "ink" ) IM_INPUT_DOUBLEVEC( "ink" )
}; };
/* Call im_flood_copy() via arg vector. /* Call im_flood() via arg vector.
*/ */
static int static int
flood_copy_vec( im_object *argv ) flood_vec( im_object *argv )
{ {
IMAGE *in = argv[0]; IMAGE *image = argv[0];
IMAGE *out = argv[1]; int start_x = *((int *) argv[1]);
int start_x = *((int *) argv[2]); int start_y = *((int *) argv[2]);
int start_y = *((int *) argv[3]); im_doublevec_object *dv = (im_doublevec_object *) argv[3];
im_doublevec_object *dv = (im_doublevec_object *) argv[4];
PEL *ink; PEL *ink;
if( dv->n != in->Bands ) { if( dv->n != image->Bands ) {
im_error( "im_flood_copy", im_error( "im_flood", "%s", _( "bad vector length" ) );
"%s", _( "bad vector length" ) );
return( -1 ); return( -1 );
} }
if( !(ink = vector_to_ink( in, dv->vec )) ) if( !(ink = im__vector_to_ink( image, dv->vec )) )
return( -1 ); return( -1 );
return( im_flood_copy( in, out, start_x, start_y, ink ) ); return( im_flood( image, start_x, start_y, ink, NULL ) );
} }
/* Description of im_flood_copy(). /* Description of im_flood().
*/ */
static im_function flood_copy_desc = { static im_function flood_desc = {
"im_flood_copy", /* Name */ "im_flood", /* Name */
"flood with ink from start_x, start_y while pixel == start pixel", "flood with ink from start_x, start_y while pixel != ink",
0, /* Flags */ 0, /* Flags */
flood_copy_vec, /* Dispatch function */ flood_vec, /* Dispatch function */
IM_NUMBER( flood_copy_args ),/* Size of arg list */ IM_NUMBER( flood_args ),/* Size of arg list */
flood_copy_args /* Arg list */ flood_args /* Arg list */
}; };
/* Args for im_flood_other_copy(). /* Args for im_flood_other().
*/ */
static im_arg_desc flood_other_copy_args[] = { static im_arg_desc flood_other_args[] = {
IM_INPUT_IMAGE( "test" ), IM_INPUT_IMAGE( "test" ),
IM_INPUT_IMAGE( "mark" ), IM_RW_IMAGE( "mark" ),
IM_OUTPUT_IMAGE( "out" ),
IM_INPUT_INT( "start_x" ), IM_INPUT_INT( "start_x" ),
IM_INPUT_INT( "start_y" ), IM_INPUT_INT( "start_y" ),
IM_INPUT_INT( "serial" ) IM_INPUT_INT( "serial" )
}; };
/* Call im_flood_other_copy() via arg vector. /* Call im_flood_other() via arg vector.
*/ */
static int static int
flood_other_copy_vec( im_object *argv ) flood_other_vec( im_object *argv )
{ {
IMAGE *test = argv[0]; IMAGE *test = argv[0];
IMAGE *mark = argv[1]; IMAGE *mark = argv[1];
IMAGE *out = argv[2]; int start_x = *((int *) argv[2]);
int start_x = *((int *) argv[3]); int start_y = *((int *) argv[3]);
int start_y = *((int *) argv[4]); int serial = *((int *) argv[4]);
int serial = *((int *) argv[5]);
return( im_flood_other_copy( test, mark, out, return( im_flood_other( test, mark, start_x, start_y, serial, NULL ) );
start_x, start_y, serial ) );
} }
/* Description of im_flood_other_copy(). /* Description of im_flood_other().
*/ */
static im_function flood_other_copy_desc = { static im_function flood_other_desc = {
"im_flood_other_copy", /* Name */ "im_flood_other", /* Name */
"flood mark with serial from start_x, start_y while pixel == start pixel", "flood mark with serial from start_x, start_y while pixel == start pixel",
0, /* Flags */ 0, /* Flags */
flood_other_copy_vec, /* Dispatch function */ flood_other_vec, /* Dispatch function */
IM_NUMBER( flood_other_copy_args ),/* Size of arg list */ IM_NUMBER( flood_other_args ),/* Size of arg list */
flood_other_copy_args /* Arg list */ flood_other_args /* Arg list */
}; };
/* Args for im_draw_circle. /* Args for im_draw_circle.
@ -298,7 +289,7 @@ static im_arg_desc draw_circle_args[] = {
static int static int
draw_circle_vec( im_object *argv ) draw_circle_vec( im_object *argv )
{ {
IMAGE *in = argv[0]; IMAGE *image = argv[0];
int cx = *((int *) argv[1]); int cx = *((int *) argv[1]);
int cy = *((int *) argv[2]); int cy = *((int *) argv[2]);
int radius = *((int *) argv[3]); int radius = *((int *) argv[3]);
@ -307,10 +298,10 @@ draw_circle_vec( im_object *argv )
PEL *ink; PEL *ink;
if( !(ink = vector_to_ink( in, dv->vec )) ) if( !(ink = im__vector_to_ink( image, dv->vec )) )
return( -1 ); return( -1 );
return( im_draw_circle( in, cx, cy, radius, fill, ink ) ); return( im_draw_circle( image, cx, cy, radius, fill, ink ) );
} }
/* Description of im_draw_circle. /* Description of im_draw_circle.
@ -324,50 +315,6 @@ static im_function draw_circle_desc = {
draw_circle_args /* Arg list */ draw_circle_args /* Arg list */
}; };
/* Args for im_draw_circle_copy.
*/
static im_arg_desc draw_circle_copy_args[] = {
IM_INPUT_IMAGE( "in" ),
IM_OUTPUT_IMAGE( "out" ),
IM_INPUT_INT( "cx" ),
IM_INPUT_INT( "cy" ),
IM_INPUT_INT( "radius" ),
IM_INPUT_INT( "fill" ),
IM_INPUT_DOUBLEVEC( "ink" )
};
/* Call im_draw_circle_copy via arg vector.
*/
static int
draw_circle_copy_vec( im_object *argv )
{
IMAGE *in = argv[0];
IMAGE *out = argv[1];
int cx = *((int *) argv[2]);
int cy = *((int *) argv[3]);
int radius = *((int *) argv[4]);
int fill = *((int *) argv[5]);
im_doublevec_object *dv = (im_doublevec_object *) argv[6];
PEL *ink;
if( !(ink = vector_to_ink( in, dv->vec )) )
return( -1 );
return( im_draw_circle_copy( in, out, cx, cy, radius, fill, ink ) );
}
/* Description of im_draw_circle_copy.
*/
static im_function draw_circle_copy_desc = {
"im_draw_circle_copy", /* Name */
"draw circle on image",
0, /* Flags */
draw_circle_copy_vec, /* Dispatch function */
IM_NUMBER( draw_circle_copy_args ), /* Size of arg list */
draw_circle_copy_args /* Arg list */
};
/* To do: /* To do:
* these all need some kind of pel type * these all need some kind of pel type
* *
@ -384,10 +331,9 @@ static im_function draw_circle_copy_desc = {
*/ */
static im_function *inplace_list[] = { static im_function *inplace_list[] = {
&draw_circle_desc, &draw_circle_desc,
&draw_circle_copy_desc, &flood_desc,
&flood_copy_desc, &flood_blob_desc,
&flood_blob_copy_desc, &flood_other_desc,
&flood_other_copy_desc,
&insertplace_desc, &insertplace_desc,
&lineset_desc &lineset_desc
}; };