From 3cae292f4fe4f3dc5cf12a54672faf7e616e53a0 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Wed, 22 Sep 2010 22:02:44 +0000 Subject: [PATCH] stuff --- ChangeLog | 1 + libvips/deprecated/deprecated_dispatch.c | 32 +++++++++++++++++++ libvips/deprecated/rename.c | 5 +++ libvips/include/vips/almostdeprecated.h | 1 + libvips/include/vips/inplace.h | 2 +- libvips/inplace/Makefile.am | 2 +- .../{im_insertplace.c => im_draw_image.c} | 13 +++++--- libvips/inplace/inplace_dispatch.c | 32 +++++++++---------- 8 files changed, 65 insertions(+), 23 deletions(-) rename libvips/inplace/{im_insertplace.c => im_draw_image.c} (92%) diff --git a/ChangeLog b/ChangeLog index 5a6705ba..cd052d76 100644 --- a/ChangeLog +++ b/ChangeLog @@ -23,6 +23,7 @@ - moved the stupid _copy() versions of the inplace ops to deprecated, since nip2 can call inplace ops directly now - added im_draw_rect(), moved im_paintrect() to deprecated +- added im_draw_image(), moved im_insertplace() to deprecated 12/5/10 started 7.22.2 - the conditional image of ifthenelse can be any format, a (!=0) is added if diff --git a/libvips/deprecated/deprecated_dispatch.c b/libvips/deprecated/deprecated_dispatch.c index 722f720a..188374cf 100644 --- a/libvips/deprecated/deprecated_dispatch.c +++ b/libvips/deprecated/deprecated_dispatch.c @@ -1372,6 +1372,37 @@ static im_function flood_other_copy_desc = { flood_other_copy_args /* Arg list */ }; +/* Args for im_insertplace. + */ +static im_arg_desc insertplace_args[] = { + IM_RW_IMAGE( "main" ), + IM_INPUT_IMAGE( "sub" ), + IM_INPUT_INT( "x" ), + IM_INPUT_INT( "y" ) +}; + +/* Call im_insertplace via arg vector. + */ +static int +insertplace_vec( im_object *argv ) +{ + int x = *((int *) argv[2]); + int y = *((int *) argv[3]); + + return( im_insertplace( argv[0], argv[1], x, y ) ); +} + +/* Description of im_insertplace. + */ +static im_function insertplace_desc = { + "im_insertplace", /* Name */ + "draw image sub inside image main at position (x,y)", + 0, /* Flags */ + insertplace_vec, /* Dispatch function */ + IM_NUMBER( insertplace_args ), /* Size of arg list */ + insertplace_args /* Arg list */ +}; + /* Package up all these functions. */ static im_function *deprecated_list[] = { @@ -1421,6 +1452,7 @@ static im_function *deprecated_list[] = { &erode_raw_desc, &similarity_area_desc, &similarity_desc, + &insertplace_desc, &circle_desc }; diff --git a/libvips/deprecated/rename.c b/libvips/deprecated/rename.c index eec585f4..41714b11 100644 --- a/libvips/deprecated/rename.c +++ b/libvips/deprecated/rename.c @@ -513,3 +513,8 @@ im_paintrect( IMAGE *im, Rect *r, PEL *ink ) r->left, r->top, r->width, r->height, 1, ink ) ); } +int +im_insertplace( IMAGE *main, IMAGE *sub, int x, int y ) +{ + return( im_draw_image( main, x, y, sub ) ); +} diff --git a/libvips/include/vips/almostdeprecated.h b/libvips/include/vips/almostdeprecated.h index 1483e116..008af744 100644 --- a/libvips/include/vips/almostdeprecated.h +++ b/libvips/include/vips/almostdeprecated.h @@ -232,6 +232,7 @@ int im_circle( IMAGE *im, int cx, int cy, int radius, int intensity ); int im_line( IMAGE *, int, int, int, int, int ); int im_segment( IMAGE *test, IMAGE *mask, int *segments ); int im_paintrect( IMAGE *im, Rect *r, PEL *ink ); +int im_insertplace( IMAGE *main, IMAGE *sub, int x, int y ); 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 ); diff --git a/libvips/include/vips/inplace.h b/libvips/include/vips/inplace.h index f414e4a8..f2093df4 100644 --- a/libvips/include/vips/inplace.h +++ b/libvips/include/vips/inplace.h @@ -46,7 +46,7 @@ int im_draw_rect( IMAGE *image, int im_draw_circle( IMAGE *im, int cx, int cy, int radius, gboolean fill, PEL *ink ); -int im_insertplace( IMAGE *main, IMAGE *sub, int x, int y ); +int im_draw_image( IMAGE *main, int x, int y, IMAGE *sub ); int im_fastline( IMAGE *im, int x1, int y1, int x2, int y2, PEL *pel ); int im_fastlineuser( IMAGE *im, int x1, int y1, int x2, int y2, diff --git a/libvips/inplace/Makefile.am b/libvips/inplace/Makefile.am index b3813a20..b6c38168 100644 --- a/libvips/inplace/Makefile.am +++ b/libvips/inplace/Makefile.am @@ -3,7 +3,7 @@ noinst_LTLIBRARIES = libinplace.la libinplace_la_SOURCES = \ im_draw_circle.c \ flood.c \ - im_insertplace.c \ + im_draw_image.c \ im_draw_rect.c \ im_plotmask.c \ inplace_dispatch.c \ diff --git a/libvips/inplace/im_insertplace.c b/libvips/inplace/im_draw_image.c similarity index 92% rename from libvips/inplace/im_insertplace.c rename to libvips/inplace/im_draw_image.c index 3afc9fc8..90fe7282 100644 --- a/libvips/inplace/im_insertplace.c +++ b/libvips/inplace/im_draw_image.c @@ -21,6 +21,8 @@ * level * 25/8/10 * - cast and bandalike sub to main + * 22/9/10 + * - rename to im_draw_image() */ /* @@ -95,12 +97,13 @@ im__inplace_base( const char *domain, /** * im_insertplace: - * @main: main image - * @sub: sub-image to insert + * @main: image to draw on * @x: position to insert * @y: position to insert + * @sub: image to draw * - * Copy @sub into @main at position @x, @y. The two images must have the same + * Draw @sub on top of @main at position @x, @y. The two images must have the + * same * Coding. If @sub has 1 band, the bands will be duplicated to match the * number of bands in @main. @sub will be converted to @main's format, see * im_clip2fmt(). @@ -113,7 +116,7 @@ im__inplace_base( const char *domain, * Returns: 0 on success, or -1 on error. */ int -im_insertplace( IMAGE *main, IMAGE *sub, int x, int y ) +im_draw_image( IMAGE *main, int x, int y, IMAGE *sub ) { Rect br, sr, clip; PEL *p, *q; @@ -133,7 +136,7 @@ im_insertplace( IMAGE *main, IMAGE *sub, int x, int y ) if( im_rect_isempty( &clip ) ) return( 0 ); - if( !(sub = im__inplace_base( "im_insertplace", main, sub, main )) || + if( !(sub = im__inplace_base( "im_draw_image", main, sub, main )) || im_rwcheck( main ) || im_incheck( sub ) ) return( -1 ); diff --git a/libvips/inplace/inplace_dispatch.c b/libvips/inplace/inplace_dispatch.c index c943ec7b..7b7fd92d 100644 --- a/libvips/inplace/inplace_dispatch.c +++ b/libvips/inplace/inplace_dispatch.c @@ -54,35 +54,35 @@ * */ -/* Args for im_insertplace. +/* Args for im_draw_image. */ -static im_arg_desc insertplace_args[] = { +static im_arg_desc draw_image_args[] = { IM_RW_IMAGE( "main" ), - IM_INPUT_IMAGE( "sub" ), IM_INPUT_INT( "x" ), - IM_INPUT_INT( "y" ) + IM_INPUT_INT( "y" ), + IM_INPUT_IMAGE( "sub" ) }; -/* Call im_insertplace via arg vector. +/* Call im_draw_image via arg vector. */ static int -insertplace_vec( im_object *argv ) +draw_image_vec( im_object *argv ) { - int x = *((int *) argv[2]); - int y = *((int *) argv[3]); + int x = *((int *) argv[1]); + int y = *((int *) argv[2]); - return( im_insertplace( argv[0], argv[1], x, y ) ); + return( im_draw_image( argv[0], x, y, argv[3] ) ); } -/* Description of im_insertplace. +/* Description of im_draw_image. */ -static im_function insertplace_desc = { - "im_insertplace", /* Name */ +static im_function draw_image_desc = { + "im_draw_image", /* Name */ "draw image sub inside image main at position (x,y)", 0, /* Flags */ - insertplace_vec, /* Dispatch function */ - IM_NUMBER( insertplace_args ), /* Size of arg list */ - insertplace_args /* Arg list */ + draw_image_vec, /* Dispatch function */ + IM_NUMBER( draw_image_args ), /* Size of arg list */ + draw_image_args /* Arg list */ }; /* Args for im_lineset. @@ -372,7 +372,7 @@ static im_function *inplace_list[] = { &flood_desc, &flood_blob_desc, &flood_other_desc, - &insertplace_desc, + &draw_image_desc, &lineset_desc };