static int vips_statistic_build( VipsObject *object ) { VipsStatistic *statistic = VIPS_STATISTIC( object ); VipsObjectClass *class = VIPS_OBJECT_GET_CLASS( object ); const char *domain = class->nickname; #ifdef DEBUG printf( "vips_statistic_build: " ); vips_object_print_name( object ); printf( "\n" ); #endif /*DEBUG*/ if( VIPS_OBJECT_CLASS( vips_statistic_parent_class )->build( object ) ) return( -1 ); if( vips_image_pio_input( statistic->in ) || vips_check_uncoded( domain, statistic->in ) ) return( -1 ); if( vips_sink( statistic->in, vips_statistic_scan_start, vips_statistic_scan, vips_statistic_scan_stop, statistic, NULL ) ) return( -1 ); return( 0 ); }
static void vips_interpolate_finalize( GObject *gobject ) { printf( "vips_interpolate_finalize: " ); vips_object_print_name( VIPS_OBJECT( gobject ) ); G_OBJECT_CLASS( vips_interpolate_parent_class )->finalize( gobject ); }
// walk the options and fetch any requested outputs void VOption::get_operation( VipsOperation *operation ) { std::list<Pair *>::iterator i; for( i = options.begin(); i != options.end(); ++i ) if( ! (*i)->input ) { const char *name = (*i)->name; g_object_get_property( G_OBJECT( operation ), name, &(*i)->value ); #ifdef VIPS_DEBUG_VERBOSE printf( "get_operation: " ); vips_object_print_name( VIPS_OBJECT( operation ) ); char *str_value = g_strdup_value_contents( &(*i)->value ); printf( ".%s = %s\n", name, str_value ); g_free( str_value ); #endif /*VIPS_DEBUG_VERBOSE*/ GValue *value = &(*i)->value; GType type = G_VALUE_TYPE( value ); if( type == VIPS_TYPE_IMAGE ) { // rebox object VipsImage *image = VIPS_IMAGE( g_value_get_object( value ) ); *((*i)->vimage) = VImage( image ); } else if( type == G_TYPE_INT ) *((*i)->vint) = g_value_get_int( value ); else if( type == G_TYPE_BOOLEAN ) *((*i)->vbool) = g_value_get_boolean( value ); else if( type == G_TYPE_DOUBLE ) *((*i)->vdouble) = g_value_get_double( value ); else if( type == VIPS_TYPE_ARRAY_DOUBLE ) { int length; double *array = vips_value_get_array_double( value, &length ); int j; ((*i)->vvector)->resize( length ); for( j = 0; j < length; j++ ) (*((*i)->vvector))[j] = array[j]; } else if( type == VIPS_TYPE_BLOB ) { // our caller gets a reference *((*i)->vblob) = (VipsBlob *) g_value_dup_boxed( value ); } } }
int vips_object_build( VipsObject *object ) { VipsObjectClass *object_class = VIPS_OBJECT_GET_CLASS( object ); #ifdef DEBUG printf( "vips_object_build: " ); vips_object_print_name( object ); printf( "\n" ); #endif /*DEBUG*/ return( object_class->build( object ) ); }
static void vips_object_close( VipsObject *object ) { if( !object->close ) { object->close = TRUE; #ifdef DEBUG printf( "vips_object_close: " ); vips_object_print_name( object ); printf( "\n" ); #endif /*DEBUG*/ g_signal_emit( object, vips_object_signals[SIG_CLOSE], 0 ); } }
static void vips_convi_dispose( GObject *gobject ) { VipsConvi *convi = (VipsConvi *) gobject; #ifdef DEBUG printf( "vips_convi_dispose: " ); vips_object_print_name( VIPS_OBJECT( gobject ) ); printf( "\n" ); #endif /*DEBUG*/ vips_convi_compile_free( convi ); G_OBJECT_CLASS( vips_convi_parent_class )->dispose( gobject ); }
static void vips_wrap7_dispose( GObject *gobject ) { VipsWrap7 *wrap7 = VIPS_WRAP7( gobject ); VipsWrap7Class *class = VIPS_WRAP7_GET_CLASS( wrap7 ); #ifdef DEBUG printf( "vips_wrap7_dispose: " ); vips_object_print_name( VIPS_OBJECT( wrap7 ) ); printf( "\n" ); #endif /*DEBUG*/ vips_wrap7_vargv_dispose( class->fn, wrap7->vargv ); G_OBJECT_CLASS( vips_wrap7_parent_class )->dispose( gobject ); }
static void vips_wrap7_finalize( GObject *gobject ) { VipsWrap7 *wrap7 = VIPS_WRAP7( gobject ); VipsWrap7Class *class = VIPS_WRAP7_GET_CLASS( wrap7 ); #ifdef DEBUG printf( "vips_wrap7_finalize: " ); vips_object_print_name( VIPS_OBJECT( wrap7 ) ); printf( "\n" ); #endif /*DEBUG*/ if( wrap7->vargv ) { vips_wrap7_vargv_finalize( class->fn, wrap7->vargv ); im_free_vargv( class->fn, wrap7->vargv ); VIPS_FREE( wrap7->vargv ); }
static void vips_region_finalize( GObject *gobject ) { #ifdef VIPS_DEBUG VIPS_DEBUG_MSG( "vips_region_finalize: " ); vips_object_print_name( VIPS_OBJECT( gobject ) ); VIPS_DEBUG_MSG( "\n" ); #endif /*VIPS_DEBUG*/ #ifdef VIPS_DEBUG g_mutex_lock( vips__global_lock ); vips__regions_all = g_slist_remove( vips__regions_all, gobject ); g_mutex_unlock( vips__global_lock ); #endif /*VIPS_DEBUG*/ G_OBJECT_CLASS( vips_region_parent_class )->finalize( gobject ); }
static int vips_resample_build( VipsObject *object ) { VipsResample *resample = VIPS_RESAMPLE( object ); #ifdef DEBUG printf( "vips_resample_build: " ); vips_object_print_name( object ); printf( "\n" ); #endif /*DEBUG*/ g_object_set( resample, "out", vips_image_new(), NULL ); if( VIPS_OBJECT_CLASS( vips_resample_parent_class )->build( object ) ) return( -1 ); return( 0 ); }
static int vips_conversion_build( VipsObject *object ) { VipsConversion *conversion = VIPS_CONVERSION( object ); #ifdef DEBUG printf( "vips_conversion_build: " ); vips_object_print_name( object ); printf( "\n" ); #endif /*DEBUG*/ g_object_set( conversion, "out", vips_image_new(), NULL ); if( VIPS_OBJECT_CLASS( vips_conversion_parent_class )->build( object ) ) return( -1 ); return( 0 ); }
static int vips_histogram_build( VipsObject *object ) { VipsHistogram *histogram = VIPS_HISTOGRAM( object ); #ifdef DEBUG printf( "vips_histogram_build: " ); vips_object_print_name( object ); printf( "\n" ); #endif /*DEBUG*/ g_object_set( histogram, "out", vips_image_new(), NULL ); if( VIPS_OBJECT_CLASS( vips_histogram_parent_class )->build( object ) ) return( -1 ); return( 0 ); }
// walk the options and set props on the operation void VOption::set_operation( VipsOperation *operation ) { std::list<Pair *>::iterator i; for( i = options.begin(); i != options.end(); ++i ) if( (*i)->input ) { #ifdef VIPS_DEBUG_VERBOSE printf( "set_operation: " ); vips_object_print_name( VIPS_OBJECT( operation ) ); char *str_value = g_strdup_value_contents( &(*i)->value ); printf( ".%s = %s\n", (*i)->name, str_value ); g_free( str_value ); #endif /*VIPS_DEBUG_VERBOSE*/ set_property( VIPS_OBJECT( operation ), (*i)->name, &(*i)->value ); } }
static void vips_region_dispose( GObject *gobject ) { VipsRegion *region = VIPS_REGION( gobject ); VipsImage *image = region->im; #ifdef VIPS_DEBUG VIPS_DEBUG_MSG( "vips_region_dispose: " ); vips_object_print_name( VIPS_OBJECT( gobject ) ); VIPS_DEBUG_MSG( "\n" ); #endif /*VIPS_DEBUG*/ vips_object_preclose( VIPS_OBJECT( gobject ) ); /* Stop this sequence. */ vips__region_stop( region ); /* Free any attached memory. */ VIPS_FREEF( vips_window_unref, region->window ); VIPS_FREEF( vips_buffer_unref, region->buffer ); /* Detach from image. */ VIPS_GATE_START( "vips_region_dispose: wait" ); g_mutex_lock( image->sslock ); VIPS_GATE_STOP( "vips_region_dispose: wait" ); image->regions = g_slist_remove( image->regions, region ); g_mutex_unlock( image->sslock ); region->im = NULL; g_object_unref( image ); G_OBJECT_CLASS( vips_region_parent_class )->dispose( gobject ); }
static int vips_statistic_build( VipsObject *object ) { VipsStatistic *statistic = VIPS_STATISTIC( object ); VipsStatisticClass *sclass = VIPS_STATISTIC_GET_CLASS( statistic ); VipsImage **t = (VipsImage **) vips_object_local_array( object, 2 ); #ifdef DEBUG printf( "vips_statistic_build: " ); vips_object_print_name( object ); printf( "\n" ); #endif /*DEBUG*/ if( VIPS_OBJECT_CLASS( vips_statistic_parent_class )->build( object ) ) return( -1 ); statistic->ready = statistic->in; if( vips_image_decode( statistic->ready, &t[0] ) ) return( -1 ); statistic->ready = t[0]; /* If there's a format table, cast the input. */ if( sclass->format_table ) { if( vips_cast( statistic->ready, &t[1], sclass->format_table[statistic->in->BandFmt], NULL ) ) return( -1 ); statistic->ready = t[1]; } if( vips_sink( statistic->ready, vips_statistic_scan_start, vips_statistic_scan, vips_statistic_scan_stop, statistic, NULL ) ) return( -1 ); return( 0 ); }
static int vips_histogram_build( VipsObject *object ) { VipsHistogram *histogram = VIPS_HISTOGRAM( object ); VipsObjectClass *class = VIPS_OBJECT_GET_CLASS( object ); VipsHistogramClass *hclass = VIPS_HISTOGRAM_GET_CLASS( histogram ); VipsImage **decode; VipsImage **format; VipsImage **band; VipsImage **size; VipsImage **memory; VipsPel *outbuf; VipsPel **inbuf; int i; #ifdef DEBUG printf( "vips_histogram_build: " ); vips_object_print_name( object ); printf( "\n" ); #endif /*DEBUG*/ if( VIPS_OBJECT_CLASS( vips_histogram_parent_class )->build( object ) ) return( -1 ); g_assert( histogram->n > 0 ); /* Must be NULL-terminated. */ g_assert( !histogram->in[histogram->n] ); decode = (VipsImage **) vips_object_local_array( object, histogram->n ); format = (VipsImage **) vips_object_local_array( object, histogram->n ); band = (VipsImage **) vips_object_local_array( object, histogram->n ); size = (VipsImage **) vips_object_local_array( object, histogram->n ); memory = (VipsImage **) vips_object_local_array( object, histogram->n ); g_object_set( histogram, "out", vips_image_new(), NULL ); for( i = 0; i < histogram->n; i++ ) if( vips_image_decode( histogram->in[i], &decode[i] ) || vips_check_hist( class->nickname, decode[i] ) ) return( -1 ); /* Cast our input images up to a common format, bands and size. If * input_format is set, cast to a fixed input type. */ if( hclass->input_format != VIPS_FORMAT_NOTSET ) { for( i = 0; i < histogram->n; i++ ) if( vips_cast( decode[i], &format[i], hclass->input_format, NULL ) ) return( -1 ); } else { if( vips__formatalike_vec( decode, format, histogram->n ) ) return( -1 ); } if( vips__bandalike_vec( class->nickname, format, band, histogram->n, 1 ) || vips__hist_sizealike_vec( band, size, histogram->n ) ) return( -1 ); if( vips_image_pipeline_array( histogram->out, VIPS_DEMAND_STYLE_THINSTRIP, size ) ) return( -1 ); /* Need a copy of the inputs in memory. */ if( !(inbuf = VIPS_ARRAY( object, histogram->n + 1, VipsPel * )) ) return( -1 ); for( i = 0; i < histogram->n; i++ ) { if( !(memory[i] = vips_image_copy_memory( size[i] )) ) return( -1 ); inbuf[i] = VIPS_IMAGE_ADDR( memory[i], 0, 0 ); } inbuf[i] = NULL; /* Keep a copy of the memory images here for subclasses. */ histogram->ready = memory; histogram->out->Xsize = VIPS_IMAGE_N_PELS( histogram->ready[0] ); histogram->out->Ysize = 1; if( hclass->format_table ) histogram->out->BandFmt = hclass->format_table[histogram->ready[0]->BandFmt]; histogram->out->Type = VIPS_INTERPRETATION_HISTOGRAM; if( !(outbuf = vips_malloc( object, VIPS_IMAGE_SIZEOF_LINE( histogram->out ))) ) return( -1 ); hclass->process( histogram, outbuf, inbuf, histogram->ready[0]->Xsize ); if( vips_image_write_line( histogram->out, 0, outbuf ) ) return( -1 ); return( 0 ); }