more save work
This commit is contained in:
parent
7496381fc9
commit
1028907e58
|
@ -84,31 +84,60 @@ static int
|
||||||
vips_foreign_save_nifti_header_vips( VipsForeignSaveNifti *nifti,
|
vips_foreign_save_nifti_header_vips( VipsForeignSaveNifti *nifti,
|
||||||
VipsImage *image )
|
VipsImage *image )
|
||||||
{
|
{
|
||||||
|
g_assert( FALSE );
|
||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typedef struct _VipsNdimInfo {
|
||||||
|
VipsImage *image;
|
||||||
|
int *dims;
|
||||||
|
int n;
|
||||||
|
} VipsNdimInfo;
|
||||||
|
|
||||||
|
static void *
|
||||||
|
vips_foreign_save_nifti_set_dims( const char *name, GValue *value, glong offset,
|
||||||
|
void *a, void *b )
|
||||||
|
{
|
||||||
|
VipsNdimInfo *info = (VipsNdimInfo *) a;
|
||||||
|
|
||||||
|
/* The first 8 members are the dims fields.
|
||||||
|
*/
|
||||||
|
if( info->n < 7 ) {
|
||||||
|
char txt[256];
|
||||||
|
|
||||||
|
vips_snprintf( txt, 256, "nifti-%s", name );
|
||||||
|
if( vips_image_get_int( image, name, &info->dims[i] ) )
|
||||||
|
return( info );
|
||||||
|
}
|
||||||
|
|
||||||
|
info->n += 1;
|
||||||
|
|
||||||
|
return( NULL );
|
||||||
|
}
|
||||||
|
|
||||||
/* Make ->nim from the nifti- fields.
|
/* Make ->nim from the nifti- fields.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
vips_foreign_save_nifti_header_nifti( VipsForeignSaveNifti *nifti,
|
vips_foreign_save_nifti_header_nifti( VipsForeignSaveNifti *nifti,
|
||||||
VipsImage *image )
|
VipsImage *image )
|
||||||
{
|
{
|
||||||
|
VipsObjectClass *class = VIPS_OBJECT_GET_CLASS( nifti );
|
||||||
|
|
||||||
|
VipsNdimInfo info;
|
||||||
int dims[8];
|
int dims[8];
|
||||||
int datatype;
|
int datatype;
|
||||||
int height;
|
int height;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* The first 8 members of vips_foreign_nifti_fields[] are the dims
|
info.image = image;
|
||||||
* fields.
|
info.dims = dims;
|
||||||
*/
|
info.n = 0;
|
||||||
for( i = 0; i < VIPS_NUMBER( dims ); i++ ) {
|
if( vips__foreign_nifti_map(
|
||||||
static char name[256];
|
vips_foreign_save_nifti_set_dims, &info, NULL ) )
|
||||||
|
|
||||||
vips_snprintf( name, 256, "nifti-%s",
|
|
||||||
vips_foreign_nifti_fields[i].name );
|
|
||||||
if( vips_image_get_int( image, name, &dims[i] ) )
|
|
||||||
return( -1 );
|
return( -1 );
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
height = 1;
|
height = 1;
|
||||||
for( i = 2; i < VIPS_NUMBER( dims ) && i < dims[0]; i++ )
|
for( i = 2; i < VIPS_NUMBER( dims ) && i < dims[0]; i++ )
|
||||||
|
@ -120,12 +149,7 @@ vips_foreign_save_nifti_header_nifti( VipsForeignSaveNifti *nifti,
|
||||||
return( -1 );
|
return( -1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
datatype = -1;
|
datatype = vips__foreign_nifti_BandFmt2datatype( image->BandFmt );
|
||||||
for( i = 0; i < vips_foreign_DT2Vips; i++ )
|
|
||||||
if( vips_foreign_DT2Vips[i].format == image.format ) {
|
|
||||||
datatype = vips_foreign_DT2Vips[i].datatype;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if( datatype == -1 ) {
|
if( datatype == -1 ) {
|
||||||
vips_error( class->nickname,
|
vips_error( class->nickname,
|
||||||
"%s", _( "unsupported libvips image type" ) );
|
"%s", _( "unsupported libvips image type" ) );
|
||||||
|
|
Loading…
Reference in New Issue