move C API back to int operations
always return results through params
This commit is contained in:
parent
b28cda68a7
commit
b5cadc1815
@ -8,6 +8,7 @@
|
|||||||
- in im_vips2tiff, enable YCbCr compression for jpeg write
|
- in im_vips2tiff, enable YCbCr compression for jpeg write
|
||||||
- VipsMin stops search early if it can
|
- VipsMin stops search early if it can
|
||||||
- C API supports optional output args
|
- C API supports optional output args
|
||||||
|
- switch back to int-valued operations
|
||||||
|
|
||||||
10/8/11 started 7.26.3
|
10/8/11 started 7.26.3
|
||||||
- don't use G_VALUE_COLLECT_INIT(), many platforms do not have a glib this
|
- don't use G_VALUE_COLLECT_INIT(), many platforms do not have a glib this
|
||||||
|
23
TODO
23
TODO
@ -1,25 +1,4 @@
|
|||||||
- is our C API too awkward? we'll need
|
- revise vipspool, write a test prog
|
||||||
|
|
||||||
if( !(c = vips_add( a, b )) ||
|
|
||||||
!(d = vips_add( a, c )) )
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
seems wordy compared to
|
|
||||||
|
|
||||||
if( vips_add( a, b, &c ) ||
|
|
||||||
vips_add( a, c, &d ) )
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
plus VipsPool will be more natural with #2, I think, and things like
|
|
||||||
vips_avg() have to be form #2
|
|
||||||
|
|
||||||
also, we have
|
|
||||||
|
|
||||||
if( vips_call( "add", a, b, &c ) ||
|
|
||||||
vips_call( "add", a, c, &d ) )
|
|
||||||
return( -1 );
|
|
||||||
|
|
||||||
which is much closer to #2
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -321,19 +321,15 @@ vips_add_init( VipsAdd *add )
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
VipsImage *
|
int
|
||||||
vips_add( VipsImage *in1, VipsImage *in2, ... )
|
vips_add( VipsImage *in1, VipsImage *in2, VipsImage **out, ... )
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
int result;
|
int result;
|
||||||
VipsImage *out;
|
|
||||||
|
|
||||||
va_start( ap, in2 );
|
va_start( ap, out );
|
||||||
result = vips_call_split( "add", ap, in1, in2, &out );
|
result = vips_call_split( "add", ap, in1, in2, out );
|
||||||
va_end( ap );
|
va_end( ap );
|
||||||
|
|
||||||
if( result )
|
return( result );
|
||||||
return( NULL );
|
|
||||||
|
|
||||||
return( out );
|
|
||||||
}
|
}
|
||||||
|
@ -254,24 +254,20 @@ vips_subtract_class_init( VipsSubtractClass *class )
|
|||||||
bclass->process_line = subtract_buffer;
|
bclass->process_line = subtract_buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
VipsImage *
|
|
||||||
vips_subtract( VipsImage *in1, VipsImage *in2, ... )
|
|
||||||
{
|
|
||||||
va_list ap;
|
|
||||||
int result;
|
|
||||||
VipsImage *out;
|
|
||||||
|
|
||||||
va_start( ap, in2 );
|
|
||||||
result = vips_call_split( "subtract", ap, in1, in2, &out );
|
|
||||||
va_end( ap );
|
|
||||||
|
|
||||||
if( result )
|
|
||||||
return( NULL );
|
|
||||||
|
|
||||||
return( out );
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
vips_subtract_init( VipsSubtract *subtract )
|
vips_subtract_init( VipsSubtract *subtract )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
vips_subtract( VipsImage *in1, VipsImage *in2, VipsImage **out, ... )
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
int result;
|
||||||
|
|
||||||
|
va_start( ap, in2 );
|
||||||
|
result = vips_call_split( "subtract", ap, in1, in2, out );
|
||||||
|
va_end( ap );
|
||||||
|
|
||||||
|
return( result );
|
||||||
|
}
|
||||||
|
@ -37,8 +37,8 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif /*__cplusplus*/
|
#endif /*__cplusplus*/
|
||||||
|
|
||||||
VipsImage *vips_add( VipsImage *in1, VipsImage *in2, ... );
|
int vips_add( VipsImage *in1, VipsImage *in2, VipsImage **out, ... );
|
||||||
VipsImage *vips_subtract( VipsImage *in1, VipsImage *in2, ... );
|
int vips_subtract( VipsImage *in1, VipsImage *in2, VipsImage **out, ... );
|
||||||
int vips_avg( VipsImage *in, double *out, ... );
|
int vips_avg( VipsImage *in, double *out, ... );
|
||||||
int vips_min( VipsImage *in, double *out, ... );
|
int vips_min( VipsImage *in, double *out, ... );
|
||||||
|
|
||||||
|
@ -53,21 +53,20 @@
|
|||||||
|
|
||||||
Here's how to handle ref counts when calling vips operations:
|
Here's how to handle ref counts when calling vips operations:
|
||||||
|
|
||||||
VipsImage *
|
int
|
||||||
thing( VipsImage *in1, VipsImage *in2 )
|
thing( VipsImage *in1, VipsImage *in2, VipsImage **out )
|
||||||
{
|
{
|
||||||
VipsImage *t;
|
VipsImage *t;
|
||||||
VipsImage *out;
|
|
||||||
|
|
||||||
if( vips_add( in1, in2, &t, NULL ) )
|
if( vips_add( in1, in2, &t, NULL ) )
|
||||||
return( NULL );
|
return( -1 );
|
||||||
if( vips_add( in1, t, &out, NULL ) ) {
|
if( vips_add( in1, t, out, NULL ) ) {
|
||||||
g_object_unref( t );
|
g_object_unref( t );
|
||||||
return( NULL );
|
return( -1 );
|
||||||
}
|
}
|
||||||
g_object_unref( t );
|
g_object_unref( t );
|
||||||
|
|
||||||
return( out );
|
return( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
The first vips_add() call returns (via the reference argument) a new
|
The first vips_add() call returns (via the reference argument) a new
|
||||||
@ -79,18 +78,16 @@
|
|||||||
VipsPool provides a nicer way to track the objects that you create and free
|
VipsPool provides a nicer way to track the objects that you create and free
|
||||||
them safely. The above function would become:
|
them safely. The above function would become:
|
||||||
|
|
||||||
VipsImage *
|
int
|
||||||
thing( VipsPool *pool, VipsImage *in1, VipsImage *in2 )
|
thing( VipsPool *pool, VipsImage *in1, VipsImage *in2, VipsImage **out )
|
||||||
{
|
{
|
||||||
VipsPoolContext *context = vips_pool_context_new( pool );
|
VipsPoolContext *context = vips_pool_context_new( pool );
|
||||||
|
|
||||||
VipsImage *out;
|
|
||||||
|
|
||||||
if( vips_add( in1, in2, VIPS_VAR_IMAGE_REF( 1 ), NULL ) ||
|
if( vips_add( in1, in2, VIPS_VAR_IMAGE_REF( 1 ), NULL ) ||
|
||||||
vips_add( in1, VIPS_VAR_IMAGE( 1 ), &out, NULL ) )
|
vips_add( in1, VIPS_VAR_IMAGE( 1 ), out, NULL ) )
|
||||||
return( NULL );
|
return( -1 );
|
||||||
|
|
||||||
return( out );
|
return( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
vips_pool_context_new() creates a new context to hold a set of temporary
|
vips_pool_context_new() creates a new context to hold a set of temporary
|
||||||
|
Loading…
Reference in New Issue
Block a user