コード例 #1
0
ファイル: fits.c プロジェクト: FlavioFalcao/libvips
int
vips__fits_read( const char *filename, VipsImage *out )
{
	VipsImage *t;
	int n_bands;

	VIPS_DEBUG_MSG( "fits2vips: reading \"%s\"\n", filename );

	/* fits is naturally a band-separated format. For single-band images
	 * we can just read out. For many bands we read each band out
	 * separately then join them.
	 */

	t = vips_image_new();
	if( vips__fits_read_header( filename, t ) ) {
		g_object_unref( t );
		return( -1 );
	}
	n_bands = t->Bands;
	g_object_unref( t );

	if( n_bands == 1 ) {
		if( fits2vips( filename, out, 0 ) )
			return( -1 );
	}
	else {
		VipsImage **x;
		int i;

		t = vips_image_new();
		x = (VipsImage **) vips_object_local_array( VIPS_OBJECT( t ), 
			n_bands + 1 );

		for( i = 0; i < n_bands; i++ ) {
			x[i] = vips_image_new();
			if( fits2vips( filename, x[i], i ) ) {
				g_object_unref( t );
				return( -1 );
			}
		}

		if( vips_bandjoin( x, &x[n_bands], n_bands, NULL ) ||
			vips_image_write( x[n_bands], out ) ) {
			g_object_unref( t );
			return( -1 );
		}

		g_object_unref( t );
	}

	return( 0 );
}
コード例 #2
0
static int
vips_BW2sRGB_op( VipsImage *in, VipsImage **out, ... )
{
	VipsImage *t[3];

	t[0] = in;
	t[1] = in;
	t[2] = in;
	if( vips_bandjoin( t, out, 3, NULL ) )
		return( -1 );

	return( 0 );
}
コード例 #3
0
ファイル: arithmetic.c プロジェクト: imclab/libvips
/* Make an n-band image. Input 1 or n bands.
 */
int
vips__bandup( const char *domain, VipsImage *in, VipsImage **out, int n )
{
    VipsImage *bands[256];
    int i;

    if( in->Bands == n )
        return( vips_copy( in, out, NULL ) );
    if( in->Bands != 1 ) {
        vips_error( domain, _( "not one band or %d bands" ), n );
        return( -1 );
    }
    if( n > 256 || n < 1 ) {
        vips_error( domain, "%s", _( "bad bands" ) );
        return( -1 );
    }

    for( i = 0; i < n; i++ )
        bands[i] = in;

    return( vips_bandjoin( bands, out, n, NULL ) );
}