コード例 #1
0
ファイル: header.c プロジェクト: Fasjul/libvips
/**
 * vips_image_get_offset:
 * @image: image to get from
 *
 * Matrix images can have an optional `offset` field for use by integer 
 * convolution. 
 *
 * Returns: the offset.
 */
double
vips_image_get_offset( const VipsImage *image )
{
	double offset;

	offset = 0.0;
	if( vips_image_get_typeof( image, "offset" ) ) 
		vips_image_get_double( image, "offset", &offset );

	return( offset );
}
コード例 #2
0
ファイル: header.c プロジェクト: Fasjul/libvips
/**
 * vips_image_get_scale:
 * @image: image to get from
 *
 * Matrix images can have an optional `scale` field for use by integer 
 * convolution. 
 *
 * Returns: the scale.
 */
double
vips_image_get_scale( const VipsImage *image )
{
	double scale;

	scale = 1.0;
	if( vips_image_get_typeof( image, "scale" ) ) 
		vips_image_get_double( image, "scale", &scale );

	return( scale );
}
コード例 #3
0
ファイル: ppm.c プロジェクト: FlavioFalcao/libvips
static int
write_ppm( Write *write, int ascii ) 
{
	VipsImage *in = write->in;

	char *magic;
	time_t timebuf;

	if( in->BandFmt == VIPS_FORMAT_FLOAT && in->Bands == 3 ) 
		magic = "PF";
	else if( in->BandFmt == VIPS_FORMAT_FLOAT && in->Bands == 1 ) 
		magic = "Pf";
	else if( in->Bands == 1 && ascii )
		magic = "P2";
	else if( in->Bands == 1 && !ascii )
		magic = "P5";
	else if( in->Bands == 3 && ascii )
		magic = "P3";
	else if( in->Bands == 3 && !ascii )
		magic = "P6";
	else
		g_assert( 0 );

	fprintf( write->fp, "%s\n", magic );
	time( &timebuf );
	fprintf( write->fp, "#vips2ppm - %s\n", ctime( &timebuf ) );
	fprintf( write->fp, "%d %d\n", in->Xsize, in->Ysize );

	switch( in->BandFmt ) {
	case VIPS_FORMAT_UCHAR:
		fprintf( write->fp, "%d\n", UCHAR_MAX );
		break;

	case VIPS_FORMAT_USHORT:
		fprintf( write->fp, "%d\n", USHRT_MAX );
		break;

	case VIPS_FORMAT_UINT:
		fprintf( write->fp, "%d\n", UINT_MAX );
		break;

	case VIPS_FORMAT_FLOAT:
{
		double scale;

		if( vips_image_get_double( in, "pfm-scale", &scale ) )
			scale = 1;
		if( !vips_amiMSBfirst() )
			scale *= -1;
		fprintf( write->fp, "%g\n", scale );
}
		break;

	default:
		g_assert( 0 );
	}

	write->fn = ascii ? write_ppm_line_ascii : write_ppm_line_binary;

	if( vips_sink_disc( write->in, write_ppm_block, write ) )
		return( -1 );

	return( 0 );
}