diff --git a/ChangeLog b/ChangeLog index 394834ea..b1b01f68 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 diff --git a/TODO b/TODO index f4c7b471..4b46c1cd 100644 --- a/TODO +++ b/TODO @@ -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! diff --git a/libvips/conversion/rot.c b/libvips/conversion/rot.c index d4aee53a..d07f9e15 100644 --- a/libvips/conversion/rot.c +++ b/libvips/conversion/rot.c @@ -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 ); diff --git a/libvips/include/vips/conversion.h b/libvips/include/vips/conversion.h index 7c419f61..fa9857b9 100644 --- a/libvips/include/vips/conversion.h +++ b/libvips/include/vips/conversion.h @@ -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 );