Beispiel #1
0
static int
vips_replicate_build( VipsObject *object )
{
	VipsConversion *conversion = VIPS_CONVERSION( object );
	VipsReplicate *replicate = (VipsReplicate *) object;

	if( VIPS_OBJECT_CLASS( vips_replicate_parent_class )->build( object ) )
		return( -1 );

	if( vips_image_pio_input( replicate->in ) )
		return( -1 );

	if( vips_image_copy_fields( conversion->out, replicate->in ) )
		return( -1 );
	vips_demand_hint( conversion->out, 
		VIPS_DEMAND_STYLE_SMALLTILE, replicate->in, NULL );

	conversion->out->Xsize *= replicate->across;
	conversion->out->Ysize *= replicate->down;

	if( vips_image_generate( conversion->out,
		vips_start_one, vips_replicate_gen, vips_stop_one, 
		replicate->in, replicate ) )
		return( -1 );

	return( 0 );
}
Beispiel #2
0
static int
vips_sequential_build( VipsObject *object )
{
	VipsConversion *conversion = VIPS_CONVERSION( object );
	VipsSequential *sequential = (VipsSequential *) object;

	VIPS_DEBUG_MSG( "vips_sequential_build\n" );

	if( VIPS_OBJECT_CLASS( vips_sequential_parent_class )->build( object ) )
		return( -1 );

	if( vips_image_pio_input( sequential->in ) )
		return( -1 );

	if( vips_image_copy_fields( conversion->out, sequential->in ) )
		return( -1 );
        vips_demand_hint( conversion->out, 
		VIPS_DEMAND_STYLE_FATSTRIP, sequential->in, NULL );

	if( vips_image_generate( conversion->out,
		vips_start_one, vips_sequential_generate, vips_stop_one, 
		sequential->in, sequential ) )
		return( -1 );

	return( 0 );
}
Beispiel #3
0
static int
vips_tile_cache_build( VipsObject *object )
{
	VipsConversion *conversion = VIPS_CONVERSION( object );
	VipsTileCache *cache = (VipsTileCache *) object;

	VIPS_DEBUG_MSG( "vips_tile_cache_build\n" );

	if( VIPS_OBJECT_CLASS( vips_tile_cache_parent_class )->build( object ) )
		return( -1 );

	if( vips_image_pio_input( cache->in ) )
		return( -1 );

	if( vips_image_copy_fields( conversion->out, cache->in ) )
		return( -1 );
        vips_demand_hint( conversion->out, 
		VIPS_DEMAND_STYLE_SMALLTILE, cache->in, NULL );

	if( vips_image_generate( conversion->out,
		vips_start_one, vips_tile_cache_gen, vips_stop_one, 
		cache->in, cache ) )
		return( -1 );

	return( 0 );
}
Beispiel #4
0
static int
vips_sequential_build( VipsObject *object )
{
	VipsConversion *conversion = VIPS_CONVERSION( object );
	VipsSequential *sequential = (VipsSequential *) object;

	VipsImage *t;

	VIPS_DEBUG_MSG( "vips_sequential_build\n" );

	if( VIPS_OBJECT_CLASS( vips_sequential_parent_class )->build( object ) )
		return( -1 );

	if( vips_image_pio_input( sequential->in ) )
		return( -1 );

	if( vips_linecache( sequential->in, &t, 
		"tile_height", sequential->tile_height,
		"strategy", VIPS_CACHE_SEQUENTIAL,
		NULL ) )
		return( -1 );

	vips_object_local( object, t ); 

	if( vips_image_copy_fields( conversion->out, t ) )
		return( -1 );
        vips_demand_hint( conversion->out,
		VIPS_DEMAND_STYLE_THINSTRIP, t, NULL );
	if( vips_image_generate( conversion->out,
		vips_start_one, vips_sequential_generate, vips_stop_one, 
		t, sequential ) )
		return( -1 );

	return( 0 );
}
Beispiel #5
0
static int
vips_recomb_build( VipsObject *object )
{
	VipsConversion *conversion = (VipsConversion *) object;
	VipsRecomb *recomb = (VipsRecomb *) object;
	VipsImage **t = (VipsImage **) vips_object_local_array( object, 2 );

	if( VIPS_OBJECT_CLASS( vips_recomb_parent_class )->build( object ) )
		return( -1 );

	if( vips_image_pio_input( recomb->in ) || 
		vips_check_uncoded( "VipsRecomb", recomb->in ) ||
		vips_check_noncomplex( "VipsRecomb", recomb->in ) )
		return( -1 );
	if( vips_image_pio_input( recomb->m ) || 
		vips_check_uncoded( "VipsRecomb", recomb->m ) ||
		vips_check_noncomplex( "VipsRecomb", recomb->m ) ||
		vips_check_mono( "VipsRecomb", recomb->m ) )
		return( -1 );
	if( recomb->in->Bands != recomb->m->Xsize ) {
		vips_error( "VipsRecomb", 
			"%s", _( "bands in must equal matrix width" ) );
		return( -1 );
	}

	if( vips_cast( recomb->m, &t[0], VIPS_FORMAT_DOUBLE, NULL ) ||
		vips_image_wio_input( t[0] ) )
		return( -1 );
	recomb->coeff = (double *) VIPS_IMAGE_ADDR( t[0], 0, 0 );

	if( vips_image_copy_fields( conversion->out, recomb->in ) )
		return( -1 );
        vips_demand_hint( conversion->out, 
		VIPS_DEMAND_STYLE_THINSTRIP, recomb->in, NULL );

	conversion->out->Bands = recomb->m->Ysize;
	if( vips_bandfmt_isint( recomb->in->BandFmt ) ) 
		conversion->out->BandFmt = VIPS_FORMAT_FLOAT;

	if( vips_image_generate( conversion->out,
		vips_start_one, vips_recomb_gen, vips_stop_one, 
		recomb->in, recomb ) )
		return( -1 );

	return( 0 );
}
Beispiel #6
0
static int
vips_flip_build( VipsObject *object )
{
	VipsConversion *conversion = VIPS_CONVERSION( object );
	VipsFlip *flip = (VipsFlip *) object;

	VipsGenerateFn generate_fn;

	if( VIPS_OBJECT_CLASS( vips_flip_parent_class )->build( object ) )
		return( -1 );

	if( vips_image_pio_input( flip->in ) )
		return( -1 );

	if( vips_image_copy_fields( conversion->out, flip->in ) )
		return( -1 );
	vips_demand_hint( conversion->out, 
		VIPS_DEMAND_STYLE_THINSTRIP, flip->in, NULL );

	if( flip->direction == VIPS_DIRECTION_HORIZONTAL ) {
		generate_fn = vips_flip_horizontal_gen;
		conversion->out->Xoffset = flip->in->Xsize;
		conversion->out->Yoffset = 0;
	}
	else {
		generate_fn = vips_flip_vertical_gen;
		conversion->out->Xoffset = 0;
		conversion->out->Yoffset = flip->in->Ysize;
	}

	if( vips_image_generate( conversion->out,
		vips_start_one, generate_fn, vips_stop_one, 
		flip->in, flip ) )
		return( -1 );

	return( 0 );
}
Beispiel #7
0
static int
vips_copy_build( VipsObject *object )
{
	VipsConversion *conversion = VIPS_CONVERSION( object );
	VipsCopy *copy = (VipsCopy *) object;

	int i;

	if( VIPS_OBJECT_CLASS( vips_copy_parent_class )->build( object ) )
		return( -1 );

	if( vips_image_pio_input( copy->in ) )
		return( -1 );

	if( vips_image_copy_fields( conversion->out, copy->in ) )
		return( -1 );
        vips_demand_hint( conversion->out, 
		VIPS_DEMAND_STYLE_THINSTRIP, copy->in, NULL );

	/* Use props to adjust header fields.
	 */
	for( i = 0; i < VIPS_NUMBER( vips_copy_names ); i++ ) {
		const char *name = vips_copy_names[i];

		GParamSpec *pspec;
		VipsArgumentClass *argument_class;
		VipsArgumentInstance *argument_instance;

		if( vips_object_get_argument( object, name,
			&pspec, &argument_class, &argument_instance ) )
			return( -1 );

		if( argument_instance->assigned ) {
			GType type = G_PARAM_SPEC_VALUE_TYPE( pspec );
			GValue value = { 0, };

			g_value_init( &value, type );
			g_object_get_property( G_OBJECT( object ), 
				name, &value );

#ifdef VIPS_DEBUG
{
			char *str;

			str = g_strdup_value_contents( &value );
			printf( "vips_copy_build: %s = %s\n", name, str );
			g_free( str );
}
#endif /* VIPS_DEBUG */

			g_object_set_property( G_OBJECT( conversion->out ), 
				name, &value );
			g_value_unset( &value );
		}
	}

	if( vips_image_generate( conversion->out,
		vips_start_one, vips_copy_gen, vips_stop_one, 
		copy->in, copy ) )
		return( -1 );

	return( 0 );
}
Beispiel #8
0
static int
vips_rot_build( VipsObject *object )
{
	VipsConversion *conversion = VIPS_CONVERSION( object );
	VipsRot *rot = (VipsRot *) object;

	VipsGenerateFn generate_fn;
	VipsDemandStyle hint;

	if( VIPS_OBJECT_CLASS( vips_rot_parent_class )->build( object ) )
		return( -1 );

	if( rot->angle == VIPS_ANGLE_0 )
		return( vips_image_write( rot->in, conversion->out ) );

	if( vips_image_pio_input( rot->in ) )
		return( -1 );

	if( vips_image_copy_fields( conversion->out, rot->in ) )
		return( -1 );

	switch( rot->angle ) {
	case VIPS_ANGLE_90:
		generate_fn = vips_rot90_gen;
		hint = VIPS_DEMAND_STYLE_SMALLTILE;
		conversion->out->Xsize = rot->in->Ysize;
		conversion->out->Ysize = rot->in->Xsize;
		conversion->out->Xoffset = rot->in->Ysize;
		conversion->out->Yoffset = 0;
		break;

	case VIPS_ANGLE_180:
		generate_fn = vips_rot180_gen;
		hint = VIPS_DEMAND_STYLE_THINSTRIP;
		conversion->out->Xoffset = rot->in->Xsize;
		conversion->out->Yoffset = rot->in->Ysize;
		break;

	case VIPS_ANGLE_270:
		generate_fn = vips_rot270_gen;
		hint = VIPS_DEMAND_STYLE_SMALLTILE;
		conversion->out->Xsize = rot->in->Ysize;
		conversion->out->Ysize = rot->in->Xsize;
		conversion->out->Xoffset = 0;
		conversion->out->Yoffset = rot->in->Xsize;
		break;

	default:
		g_assert( 0 );

		/* Keep -Wall happy.
		 */
		return( 0 );
	}

	vips_demand_hint( conversion->out, hint, rot->in, NULL );

	if( vips_image_generate( conversion->out,
		vips_start_one, generate_fn, vips_stop_one, 
		rot->in, rot ) )
		return( -1 );

	return( 0 );
}