vipscopy copies

but some work still needed on arg processing, see TODO
This commit is contained in:
John Cupitt 2011-10-02 10:22:21 +01:00
parent 4d63d5a359
commit 3acf9fd2aa
4 changed files with 34 additions and 13 deletions

4
TODO
View File

@ -2,9 +2,9 @@
how would we do meta sets?
copy_swap needs doing too, a separate class I guess
vips_object_set_argument_from_string() needs more arg types
or add a "swap" prop? we have a enum for native etc. somewhere
must be some way to make this more automatic

View File

@ -346,6 +346,8 @@ vips_copy_class_init( VipsCopyClass *class )
GParamSpec *pspec;
VIPS_DEBUG_MSG( "vips_copy_class_init\n" );
gobject_class->set_property = vips_object_set_property;
gobject_class->get_property = vips_object_get_property;

View File

@ -960,7 +960,7 @@ vips_image_class_init( VipsImageClass *class )
vobject_class->output_to_arg = vips_image_write_object;
vobject_class->nickname = "image";
vobject_class->description = _( "VIPS image class" );
vobject_class->description = _( "image class" );
vobject_class->print = vips_image_print;
vobject_class->sanity = vips_image_sanity;
@ -1581,6 +1581,9 @@ vips_image_new_mode( const char *filename, const char *mode )
{
VipsImage *image;
g_assert( filename );
g_assert( mode );
vips_check_init();
image = VIPS_IMAGE( g_object_new( VIPS_TYPE_IMAGE, NULL ) );
@ -1770,6 +1773,8 @@ vips_image_write( VipsImage *image, const char *filename )
{
VipsImage *out;
g_assert( filename );
if( !(out = vips_image_new_mode( filename, "w" )) )
return( -1 );
if( im_copy( image, out ) ) {

View File

@ -41,6 +41,7 @@
#include <vips/intl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <vips/vips.h>
@ -1243,6 +1244,14 @@ vips_object_set_argument_from_string( VipsObject *object,
b = FALSE;
g_value_set_boolean( &gvalue, b );
}
else if( G_IS_PARAM_SPEC_INT( pspec ) ) {
g_value_init( &gvalue, G_TYPE_INT );
g_value_set_int( &gvalue, atoi( value ) );
}
else if( G_IS_PARAM_SPEC_DOUBLE( pspec ) ) {
g_value_init( &gvalue, G_TYPE_DOUBLE );
g_value_set_double( &gvalue, atof( value ) );
}
else {
g_value_init( &gvalue, G_TYPE_STRING );
g_value_set_string( &gvalue, value );
@ -1254,7 +1263,7 @@ vips_object_set_argument_from_string( VipsObject *object,
return( 0 );
}
/* Does a named output arg need an argument to write to? For example, an image
/* Does an vipsargument need an argument to write to? For example, an image
* output needs a filename, a double output just prints.
*/
gboolean
@ -1274,16 +1283,21 @@ vips_object_get_argument_needs_string( VipsObject *object, const char *name )
&pspec, &argument_class, &argument_instance ) )
return( -1 );
otype = G_PARAM_SPEC_VALUE_TYPE( pspec );
g_assert( argument_class->flags & VIPS_ARGUMENT_OUTPUT );
if( G_IS_PARAM_SPEC_BOOLEAN( pspec ) )
/* Bools, input or output, don't need args.
*/
return( FALSE );
else if( argument_class->flags & VIPS_ARGUMENT_INPUT )
/* All other inputs need something.
*/
return( TRUE );
if( (otype = G_PARAM_SPEC_VALUE_TYPE( pspec )) &&
g_type_is_a( otype, VIPS_TYPE_OBJECT ) &&
(oclass = g_type_class_ref( otype )) )
/* For now, only vipsobject subclasses can ask for args.
*/
if( g_type_is_a( otype, VIPS_TYPE_OBJECT ) &&
(oclass = g_type_class_ref( otype )) )
return( oclass->output_needs_arg );
else
return( FALSE );
}