add vips_rot90() etc. convenience funcs

90/180/270 rotate as convenience functions
This commit is contained in:
John Cupitt 2017-03-07 17:36:49 +00:00
parent 205fb817e8
commit 55dcaa4ae4
4 changed files with 91 additions and 9 deletions

View File

@ -37,6 +37,7 @@
- the C functions vips_math2_const(), vips_boolean_const() and
vips_relational_const() have changed argument order to match
Python/CLI/C++ ... sorry
- added vips_rot90() etc. convenience functions
8/12/16 started 8.4.5
- allow libgsf-1.14.26 to help centos, thanks tdiprima

8
TODO
View File

@ -1,11 +1,3 @@
- vips_object_class_install_argument() should check for duplicate priorities,
it's been behind a few nasty bugs
- add vips_rot90() / _rot180() / _rot270(), cf. vips_sin() etc.
it's currently
vips_rot( smartcrop->sobel, &smartcrop->sobel90, VIPS_ANGLE_D90, NULL )
- vips linecache has access there twice!

View File

@ -26,6 +26,8 @@
* - gtkdoc
* 4/11/11
* - rewrite as a class
* 7/3/17
* - added 90/180/270 convenience functions
*/
/*
@ -374,6 +376,12 @@ vips_rot_init( VipsRot *rot )
{
}
static int
vips_rotv( VipsImage *in, VipsImage **out, VipsAngle angle, va_list ap )
{
return( vips_call_split( "rot", ap, in, out, angle ) );
}
/**
* vips_rot:
* @in: input image
@ -397,7 +405,82 @@ vips_rot( VipsImage *in, VipsImage **out, VipsAngle angle, ... )
int result;
va_start( ap, angle );
result = vips_call_split( "rot", ap, in, out, angle );
result = vips_rotv( in, out, angle, ap );
va_end( ap );
return( result );
}
/**
* vips_rot90:
* @in: input image
* @out: output image
* @...: %NULL-terminated list of optional named arguments
*
* Rotate @in by 90 degress clockwise. A convenience function over vips_rot().
*
* See also: vips_rot().
*
* Returns: 0 on success, -1 on error
*/
int
vips_rot90( VipsImage *in, VipsImage **out, ... )
{
va_list ap;
int result;
va_start( ap, out );
result = vips_rotv( in, out, VIPS_ANGLE_D90, ap );
va_end( ap );
return( result );
}
/**
* vips_rot180:
* @in: input image
* @out: output image
* @...: %NULL-terminated list of optional named arguments
*
* Rotate @in by 180 degress. A convenience function over vips_rot().
*
* See also: vips_rot().
*
* Returns: 0 on success, -1 on error
*/
int
vips_rot180( VipsImage *in, VipsImage **out, ... )
{
va_list ap;
int result;
va_start( ap, out );
result = vips_rotv( in, out, VIPS_ANGLE_D180, ap );
va_end( ap );
return( result );
}
/**
* vips_rot270:
* @in: input image
* @out: output image
* @...: %NULL-terminated list of optional named arguments
*
* Rotate @in by 270 degress clockwise. A convenience function over vips_rot().
*
* See also: vips_rot().
*
* Returns: 0 on success, -1 on error
*/
int
vips_rot270( VipsImage *in, VipsImage **out, ... )
{
va_list ap;
int result;
va_start( ap, out );
result = vips_rotv( in, out, VIPS_ANGLE_D270, ap );
va_end( ap );
return( result );

View File

@ -124,6 +124,12 @@ int vips_wrap( VipsImage *in, VipsImage **out, ... )
__attribute__((sentinel));
int vips_rot( VipsImage *in, VipsImage **out, VipsAngle angle, ... )
__attribute__((sentinel));
int vips_rot90( VipsImage *in, VipsImage **out, ... )
__attribute__((sentinel));
int vips_rot180( VipsImage *in, VipsImage **out, ... )
__attribute__((sentinel));
int vips_rot270( VipsImage *in, VipsImage **out, ... )
__attribute__((sentinel));
int vips_rot45( VipsImage *in, VipsImage **out, ... )
__attribute__((sentinel));
VipsAngle vips_autorot_get_angle( VipsImage *image );