add vips_crop()

a synonym for vips_extract_area()
This commit is contained in:
John Cupitt 2013-11-11 14:28:41 +00:00
parent 0200e229c7
commit b1f01af01b
5 changed files with 65 additions and 2 deletions

View File

@ -15,6 +15,7 @@
times
- radiance load supports sequential read
- rewritten radiance decode is much faster
- add vips_crop(), a synonym for vips_extract_area()
18/10/13 started 7.36.3
- fix compiler warnings in ubuntu 13.10

2
TODO
View File

@ -12,8 +12,6 @@
note on memuse page
- add "crop" as a synonym for "extract_area"
- add vips_gamma(), see rad etc.
- do conv and morph quickly as simple wrappers over the vips7 operations

View File

@ -206,6 +206,7 @@ vips_conversion_operation_init( void )
extern GType vips_insert_get_type( void );
extern GType vips_join_get_type( void );
extern GType vips_extract_area_get_type( void );
extern GType vips_crop_get_type( void );
extern GType vips_extract_band_get_type( void );
extern GType vips_replicate_get_type( void );
extern GType vips_cast_get_type( void );
@ -243,6 +244,7 @@ vips_conversion_operation_init( void )
vips_insert_get_type();
vips_join_get_type();
vips_extract_area_get_type();
vips_crop_get_type();
vips_extract_band_get_type();
vips_replicate_get_type();
vips_cast_get_type();

View File

@ -267,6 +267,65 @@ vips_extract_area( VipsImage *in, VipsImage **out,
return( result );
}
/* A synonym for extract_area.
*/
GType
vips_crop_get_type( void )
{
static GType type = 0;
if( !type ) {
static const GTypeInfo info = {
sizeof( VipsExtractAreaClass ),
NULL, /* base_init */
NULL, /* base_finalize */
(GClassInitFunc) vips_extract_area_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof( VipsExtractArea ),
32, /* n_preallocs */
(GInstanceInitFunc) vips_extract_area_init,
};
type = g_type_register_static( VIPS_TYPE_CONVERSION,
"crop", &info, 0 );
}
return( type );
}
/**
* vips_crop:
* @in: input image
* @out: output image
* @left: left edge of area to extract
* @top: top edge of area to extract
* @width: width of area to extract
* @height: height of area to extract
* @...: %NULL-terminated list of optional named arguments
*
* A synonym for vips_extract_area().
*
* See also: vips_extract_bands().
*
* Returns: 0 on success, -1 on error.
*/
int
vips_crop( VipsImage *in, VipsImage **out,
int left, int top, int width, int height, ... )
{
va_list ap;
int result;
va_start( ap, height );
result = vips_call_split( "crop", ap, in, out,
left, top, width, height );
va_end( ap );
return( result );
}
typedef struct _VipsExtractBand {
VipsBandary parent_instance;

View File

@ -108,6 +108,9 @@ int vips_join( VipsImage *main, VipsImage *sub, VipsImage **out,
int vips_extract_area( VipsImage *input, VipsImage **output,
int left, int top, int width, int height, ... )
__attribute__((sentinel));
int vips_crop( VipsImage *input, VipsImage **output,
int left, int top, int width, int height, ... )
__attribute__((sentinel));
int vips_extract_band( VipsImage *input, VipsImage **output, int band, ... )
__attribute__((sentinel));
int vips_replicate( VipsImage *in, VipsImage **out, int across, int down, ... )