diff --git a/TODO b/TODO index 8ecf60b6..69dc44c6 100644 --- a/TODO +++ b/TODO @@ -3,6 +3,11 @@ still need a rect for x/y/w/h of mask, since we use it with userline and an offset circle to draw fatlines +- im_draw_line() should clip x1/y1 x2/y2, cf. im_draw_line_user() + + perhaps just put a clip in the plot thing, or have two plotters and pick the + clip one if start/end are within the image + - rename most of the inplace ops as im_draw_line() etc. diff --git a/libvips/deprecated/rename.c b/libvips/deprecated/rename.c index 41714b11..2c8ec669 100644 --- a/libvips/deprecated/rename.c +++ b/libvips/deprecated/rename.c @@ -518,3 +518,9 @@ im_insertplace( IMAGE *main, IMAGE *sub, int x, int y ) { return( im_draw_image( main, x, y, sub ) ); } + +int +im_fastline( IMAGE *im, int x1, int y1, int x2, int y2, PEL *pel ) +{ + return( im_draw_line( im, x1, y1, x2, y2, pel ) ); +} diff --git a/libvips/include/vips/almostdeprecated.h b/libvips/include/vips/almostdeprecated.h index 008af744..19f7ea1b 100644 --- a/libvips/include/vips/almostdeprecated.h +++ b/libvips/include/vips/almostdeprecated.h @@ -239,6 +239,8 @@ 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_fastline( IMAGE *im, int x1, int y1, int x2, int y2, PEL *pel ); + #ifdef __cplusplus } #endif /*__cplusplus*/ diff --git a/libvips/include/vips/inplace.h b/libvips/include/vips/inplace.h index f2093df4..f9987d2b 100644 --- a/libvips/include/vips/inplace.h +++ b/libvips/include/vips/inplace.h @@ -47,7 +47,8 @@ int im_draw_circle( IMAGE *im, int cx, int cy, int radius, gboolean fill, PEL *ink ); 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_draw_line( 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, int (*fn)(), void *client1, void *client2, void *client3 ); diff --git a/libvips/inplace/line_draw.c b/libvips/inplace/line_draw.c index aa1c826c..70c8f950 100644 --- a/libvips/inplace/line_draw.c +++ b/libvips/inplace/line_draw.c @@ -91,8 +91,33 @@ /* Draw a line on a image. */ + +/** + * im_draw_line: + * @im: image to draw on + * @x1: start point + * @y1: start point + * @x2: end point + * @y2: end point + * @ink: value to draw + * + * Draws a 1-pixel-wide line on an image. @x1, @y1 and @x2, @y2 must be + * within the image. + * + * @ink is an array of bytes + * containing a valid pixel for the image's format. + * It must have at least IM_IMAGE_SIZEOF_PEL( @im ) bytes. + * + * This an inplace operation, so @im is changed. It does not thread and will + * not work well as part of a pipeline. On 32-bit machines it will be limited + * to 2GB images. + * + * See also: im_draw_circle(). + * + * Returns: 0 on success, or -1 on error. + */ int -im_fastline( IMAGE *im, int x1, int y1, int x2, int y2, PEL *pel ) +im_draw_line( IMAGE *im, int x1, int y1, int x2, int y2, PEL *pel ) { int es = IM_IMAGE_SIZEOF_ELEMENT( im ); int ps = es * im->Bands;