im_draw_point() -> vips8

This commit is contained in:
John Cupitt 2014-02-10 13:00:04 +00:00
parent 6b54181707
commit 4c732ce369
4 changed files with 73 additions and 42 deletions

View File

@ -4591,6 +4591,18 @@ im_draw_rect( IMAGE *image,
NULL ) );
}
int
im_draw_point( VipsImage *image, int x, int y, VipsPel *ink )
{
double *vec;
int n;
if( !(vec = vips__ink_to_vector( "im_draw_rect", image, ink, &n )) )
return( -1 );
return( vips_draw_point( image, vec, n, x, y, NULL ) );
}
int
im_draw_flood( IMAGE *image, int x, int y, VipsPel *ink, Rect *dout )
{

View File

@ -264,8 +264,7 @@ vips_draw_rect( VipsImage *image,
/**
* vips_draw_rect1:
* @image: image to draw on
* @ink: (array length=n): value to draw
* @n: length of ink array
* @ink: value to draw
* @left: area to paint
* @top: area to paint
* @width: area to paint
@ -299,3 +298,59 @@ vips_draw_rect1( VipsImage *image,
return( result );
}
/**
* vips_draw_point:
* @image: image to draw on
* @ink: (array length=n): value to draw
* @n: length of ink array
* @left: point to paint
* @top: point to paint
*
* As vips_draw_rect(), but draw a single pixel at @x, @y.
*
* See also: vips_draw_rect().
*
* Returns: 0 on success, or -1 on error.
*/
int
vips_draw_point( VipsImage *image, double *ink, int n, int x, int y, ... )
{
va_list ap;
int result;
va_start( ap, y );
result = vips_draw_rectv( image, ink, n, x, y, 1, 1, ap );
va_end( ap );
return( result );
}
/**
* vips_draw_point1:
* @image: image to draw on
* @ink: value to draw
* @x: point to draw
* @y: point to draw
*
* As vips_draw_point(), but just take a single double for @ink.
*
* See also: vips_draw_point().
*
* Returns: 0 on success, or -1 on error.
*/
int
vips_draw_point1( VipsImage *image, double ink, int x, int y, ... )
{
double array_ink[1];
va_list ap;
int result;
array_ink[0] = ink;
va_start( ap, y );
result = vips_draw_rectv( image, array_ink, 1, x, y, 1, 1, ap );
va_end( ap );
return( result );
}

View File

@ -57,46 +57,6 @@
#include "old_draw.h"
typedef struct _Point {
Draw draw;
} Point;
/**
* im_draw_point:
* @image: image to draw on
* @x: position to draw
* @y: position to draw
* @ink: value to draw
*
* Draws a single point on an 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.
*
* See also: im_draw_line().
*
* Returns: 0 on success, or -1 on error.
*/
int
im_draw_point( VipsImage *image, int x, int y, VipsPel *ink )
{
Point point;
if( im_check_coding_known( "im_draw_point", image ) ||
im__draw_init( DRAW( &point ), image, NULL ) )
return( -1 );
/* Check coordinates.
*/
if( x >= 0 && x < image->Xsize && y >= 0 && y < image->Ysize )
memcpy( IM_IMAGE_ADDR( image, x, y ), ink,
DRAW( image )->psize );
im__draw_free( DRAW( &point ) );
return( 0 );
}
/**
* im_read_point:
* @image: image to read from

View File

@ -44,6 +44,10 @@ int vips_draw_rect( VipsImage *image,
int vips_draw_rect1( VipsImage *image,
double ink, int left, int top, int width, int height, ... )
__attribute__((sentinel));
int vips_draw_point( VipsImage *image, double *ink, int n, int x, int y, ... )
__attribute__((sentinel));
int vips_draw_point1( VipsImage *image, double ink, int x, int y, ... )
__attribute__((sentinel));
int vips_draw_image( VipsImage *image, VipsImage *sub, int x, int y, ... )
__attribute__((sentinel));