more linemask hackery
This commit is contained in:
parent
ba25922f8e
commit
c394f8567d
@ -220,7 +220,7 @@ vips_circlev( VipsImage *image,
|
|||||||
* vips_circle:
|
* vips_circle:
|
||||||
* @image: image to draw on
|
* @image: image to draw on
|
||||||
* @ink: (array length=n): value to draw
|
* @ink: (array length=n): value to draw
|
||||||
* @n length of ink array
|
* @n: length of ink array
|
||||||
* @cx: centre of circle
|
* @cx: centre of circle
|
||||||
* @cy: centre of circle
|
* @cy: centre of circle
|
||||||
* @radius: circle radius
|
* @radius: circle radius
|
||||||
|
@ -533,7 +533,7 @@ vips_floodv( VipsImage *image,
|
|||||||
* vips_flood:
|
* vips_flood:
|
||||||
* @image: image to draw on
|
* @image: image to draw on
|
||||||
* @ink: (array length=n): value to draw
|
* @ink: (array length=n): value to draw
|
||||||
* @n length of ink array
|
* @n: length of ink array
|
||||||
* @x: centre of circle
|
* @x: centre of circle
|
||||||
* @y: centre of circle
|
* @y: centre of circle
|
||||||
*
|
*
|
||||||
|
@ -317,7 +317,11 @@ vips_linev( VipsImage *image,
|
|||||||
* vips_line:
|
* vips_line:
|
||||||
* @image: image to draw on
|
* @image: image to draw on
|
||||||
* @ink: (array length=n): value to draw
|
* @ink: (array length=n): value to draw
|
||||||
* @n length of ink array
|
* @n: length of ink array
|
||||||
|
* @x1: start of line
|
||||||
|
* @y1: start of line
|
||||||
|
* @x2: end of line
|
||||||
|
* @y2: end of line
|
||||||
*
|
*
|
||||||
* Draws a 1-pixel-wide line on an image. Subclass and override ::plot to draw
|
* Draws a 1-pixel-wide line on an image. Subclass and override ::plot to draw
|
||||||
* lines made of other objects. See vips_draw_mask().
|
* lines made of other objects. See vips_draw_mask().
|
||||||
@ -346,6 +350,10 @@ vips_line( VipsImage *image,
|
|||||||
* vips_line1:
|
* vips_line1:
|
||||||
* @image: image to draw on
|
* @image: image to draw on
|
||||||
* @ink: value to draw
|
* @ink: value to draw
|
||||||
|
* @x1: start of line
|
||||||
|
* @y1: start of line
|
||||||
|
* @x2: end of line
|
||||||
|
* @y2: end of line
|
||||||
*
|
*
|
||||||
* As vips_line(), but just takes a single double for @ink.
|
* As vips_line(), but just takes a single double for @ink.
|
||||||
*
|
*
|
||||||
|
@ -2,28 +2,27 @@
|
|||||||
*
|
*
|
||||||
* Copyright: J. Cupitt
|
* Copyright: J. Cupitt
|
||||||
* Written: 15/06/1992
|
* Written: 15/06/1992
|
||||||
* Modified : 22/10/92 - clipping constraints changed
|
|
||||||
* 22/7/93 JC
|
* 22/7/93 JC
|
||||||
* - im_incheck() added
|
* - im_incheck() added
|
||||||
* 16/8/94 JC
|
* 16/8/94 JC
|
||||||
* - im_incheck() changed to im_makerw()
|
* - im_incheck() changed to im_makerw()
|
||||||
|
* 24/10/03 JC
|
||||||
|
* - now blends with 0-255 mask
|
||||||
* 5/12/06
|
* 5/12/06
|
||||||
* - im_invalidate() after paint
|
* - im_invalidate() after paint
|
||||||
* 1/3/10
|
|
||||||
* - oops, lineset needs to ask for WIO of mask and ink
|
|
||||||
* 6/3/10
|
* 6/3/10
|
||||||
* - don't im_invalidate() after paint, this now needs to be at a higher
|
* - don't im_invalidate() after paint, this now needs to be at a higher
|
||||||
* level
|
* level
|
||||||
* 27/9/10
|
* 28/9/10
|
||||||
* - gtk-doc
|
* - gtk-doc
|
||||||
* - use draw.c base class
|
* - renamed as im_draw_mask()
|
||||||
* - do pointwise clipping
|
* - use Draw base class
|
||||||
* - rename as im_draw_line() for consistency
|
|
||||||
* - cleanups!
|
|
||||||
* 6/2/14
|
* 6/2/14
|
||||||
* - redo as a class
|
* - now a subclass of VipsLine
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
This file is part of VIPS.
|
This file is part of VIPS.
|
||||||
@ -67,6 +66,8 @@
|
|||||||
typedef struct _VipsLineMask {
|
typedef struct _VipsLineMask {
|
||||||
VipsLine parent_object;
|
VipsLine parent_object;
|
||||||
|
|
||||||
|
VipsImage *mask;
|
||||||
|
|
||||||
} VipsLineMask;
|
} VipsLineMask;
|
||||||
|
|
||||||
typedef VipsLineClass VipsLineMaskClass;
|
typedef VipsLineClass VipsLineMaskClass;
|
||||||
@ -76,12 +77,20 @@ G_DEFINE_TYPE( VipsLineMask, vips_line_mask, VIPS_TYPE_LINE );
|
|||||||
static int
|
static int
|
||||||
vips_line_mask_build( VipsObject *object )
|
vips_line_mask_build( VipsObject *object )
|
||||||
{
|
{
|
||||||
|
VipsObjectClass *class = VIPS_OBJECT_GET_CLASS( object );
|
||||||
VipsDraw *draw = VIPS_DRAW( object );
|
VipsDraw *draw = VIPS_DRAW( object );
|
||||||
VipsLine *line = (VipsLine *) object;
|
VipsLine *line = (VipsLine *) object;
|
||||||
|
|
||||||
if( VIPS_OBJECT_CLASS( vips_line_mask_parent_class )->build( object ) )
|
if( VIPS_OBJECT_CLASS( vips_line_mask_parent_class )->build( object ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
|
if( vips_check_coding_noneorlabq( class->nickname, draw->image ) ||
|
||||||
|
im_incheck( mask_im ) ||
|
||||||
|
vips_check_mono( class->nickname, mask_im ) ||
|
||||||
|
vips_check_uncoded( class->nickname, mask_im ) ||
|
||||||
|
vips_check_format( class->nickname, mask_im, VIPS_FORMAT_UCHAR ) ||
|
||||||
|
return( NULL );
|
||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,7 +122,7 @@ vips_line_mask_class_init( VipsLineClass *class )
|
|||||||
|
|
||||||
class->plot_point = vips_line_mask_plot_point;
|
class->plot_point = vips_line_mask_plot_point;
|
||||||
|
|
||||||
VIPS_ARG_IMAGE( class, "mask", 6,
|
VIPS_ARG_IMAGE( class, "mask", 7,
|
||||||
_( "Mask" ),
|
_( "Mask" ),
|
||||||
_( "Mask image" ),
|
_( "Mask image" ),
|
||||||
VIPS_ARGUMENT_REQUIRED_INPUT,
|
VIPS_ARGUMENT_REQUIRED_INPUT,
|
||||||
@ -128,14 +137,15 @@ vips_line_mask_init( VipsLine *line )
|
|||||||
|
|
||||||
static int
|
static int
|
||||||
vips_line_maskv( VipsImage *image,
|
vips_line_maskv( VipsImage *image,
|
||||||
double *ink, int n, int x1, int y1, int x2, int y2, va_list ap )
|
double *ink, int n, int x1, int y1, int x2, int y2, VipsImage *mask,
|
||||||
|
va_list ap )
|
||||||
{
|
{
|
||||||
VipsArea *area_ink;
|
VipsArea *area_ink;
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
area_ink = (VipsArea *) vips_array_double_new( ink, n );
|
area_ink = (VipsArea *) vips_array_double_new( ink, n );
|
||||||
result = vips_call_split( "line_mask", ap,
|
result = vips_call_split( "line_mask", ap,
|
||||||
image, area_ink, x1, y1, x2, y2 );
|
image, area_ink, x1, y1, x2, y2, mask );
|
||||||
vips_area_unref( area_ink );
|
vips_area_unref( area_ink );
|
||||||
|
|
||||||
return( result );
|
return( result );
|
||||||
@ -145,10 +155,14 @@ vips_line_maskv( VipsImage *image,
|
|||||||
* vips_line_mask:
|
* vips_line_mask:
|
||||||
* @image: image to draw on
|
* @image: image to draw on
|
||||||
* @ink: (array length=n): value to draw
|
* @ink: (array length=n): value to draw
|
||||||
* @n length of ink array
|
* @n: length of ink array
|
||||||
|
* @x1: start of line
|
||||||
|
* @y1: start of line
|
||||||
|
* @x2: end of line
|
||||||
|
* @y2: end of line
|
||||||
|
* @mask: mask to draw along line
|
||||||
*
|
*
|
||||||
* Draws a 1-pixel-wide line on an image. Subclass and override ::plot to draw
|
* Draws a line on an image.
|
||||||
* lines made of other objects. See vips_draw_mask().
|
|
||||||
*
|
*
|
||||||
* @ink is an array of double containing values to draw.
|
* @ink is an array of double containing values to draw.
|
||||||
*
|
*
|
||||||
@ -158,13 +172,14 @@ vips_line_maskv( VipsImage *image,
|
|||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
vips_line_mask( VipsImage *image,
|
vips_line_mask( VipsImage *image,
|
||||||
double *ink, int n, int x1, int y1, int x2, int y2, ... )
|
double *ink, int n, int x1, int y1, int x2, int y2,
|
||||||
|
VipsImage *mask, ... )
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
va_start( ap, y2 );
|
va_start( ap, mask );
|
||||||
result = vips_line_maskv( image, ink, n, x1, y1, x2, y2, ap );
|
result = vips_line_maskv( image, ink, n, x1, y1, x2, y2, mask, ap );
|
||||||
va_end( ap );
|
va_end( ap );
|
||||||
|
|
||||||
return( result );
|
return( result );
|
||||||
@ -174,6 +189,11 @@ vips_line_mask( VipsImage *image,
|
|||||||
* vips_line_mask1:
|
* vips_line_mask1:
|
||||||
* @image: image to draw on
|
* @image: image to draw on
|
||||||
* @ink: value to draw
|
* @ink: value to draw
|
||||||
|
* @x1: start of line
|
||||||
|
* @y1: start of line
|
||||||
|
* @x2: end of line
|
||||||
|
* @y2: end of line
|
||||||
|
* @mask: mask to draw along line
|
||||||
*
|
*
|
||||||
* As vips_line_mask(), but just takes a single double for @ink.
|
* As vips_line_mask(), but just takes a single double for @ink.
|
||||||
*
|
*
|
||||||
@ -182,7 +202,8 @@ vips_line_mask( VipsImage *image,
|
|||||||
* Returns: 0 on success, or -1 on error.
|
* Returns: 0 on success, or -1 on error.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
vips_line_mask1( VipsImage *image, double ink, int x1, int y1, int x2, int y2, ... )
|
vips_line_mask1( VipsImage *image,
|
||||||
|
double ink, int x1, int y1, int x2, int y2, VipsImage *mask, ... )
|
||||||
{
|
{
|
||||||
double array_ink[1];
|
double array_ink[1];
|
||||||
va_list ap;
|
va_list ap;
|
||||||
@ -190,8 +211,9 @@ vips_line_mask1( VipsImage *image, double ink, int x1, int y1, int x2, int y2, .
|
|||||||
|
|
||||||
array_ink[0] = ink;
|
array_ink[0] = ink;
|
||||||
|
|
||||||
va_start( ap, y2 );
|
va_start( ap, mask );
|
||||||
result = vips_line_maskv( image, array_ink, 1, x1, y1, x2, y2, ap );
|
result = vips_line_maskv( image,
|
||||||
|
array_ink, 1, x1, y1, x2, y2, mask, ap );
|
||||||
va_end( ap );
|
va_end( ap );
|
||||||
|
|
||||||
return( result );
|
return( result );
|
||||||
|
Loading…
Reference in New Issue
Block a user