give format_table in save a default value

This commit is contained in:
John Cupitt 2013-09-23 17:15:06 +01:00
parent cbe165f6c5
commit fd7414ec1d
5 changed files with 22 additions and 97 deletions

View File

@ -80,24 +80,6 @@ vips_foreign_save_csv_build( VipsObject *object )
return( 0 );
}
/* Save a bit of typing.
*/
#define UC VIPS_FORMAT_UCHAR
#define C VIPS_FORMAT_CHAR
#define US VIPS_FORMAT_USHORT
#define S VIPS_FORMAT_SHORT
#define UI VIPS_FORMAT_UINT
#define I VIPS_FORMAT_INT
#define F VIPS_FORMAT_FLOAT
#define X VIPS_FORMAT_COMPLEX
#define D VIPS_FORMAT_DOUBLE
#define DX VIPS_FORMAT_DPCOMPLEX
static int bandfmt_csv[10] = {
/* UC C US S UI I F X D DX */
UC, C, US, S, UI, I, F, X, D, DX
};
static void
vips_foreign_save_csv_class_init( VipsForeignSaveCsvClass *class )
{
@ -116,7 +98,6 @@ vips_foreign_save_csv_class_init( VipsForeignSaveCsvClass *class )
foreign_class->suffs = vips__foreign_csv_suffs;
save_class->saveable = VIPS_SAVEABLE_MONO;
save_class->format_table = bandfmt_csv;
VIPS_ARG_STRING( class, "filename", 1,
_( "Filename" ),

View File

@ -292,22 +292,6 @@ vips_foreign_save_csv_build( VipsObject *object )
return( 0 );
}
#define UC VIPS_FORMAT_UCHAR
#define C VIPS_FORMAT_CHAR
#define US VIPS_FORMAT_USHORT
#define S VIPS_FORMAT_SHORT
#define UI VIPS_FORMAT_UINT
#define I VIPS_FORMAT_INT
#define F VIPS_FORMAT_FLOAT
#define X VIPS_FORMAT_COMPLEX
#define D VIPS_FORMAT_DOUBLE
#define DX VIPS_FORMAT_DPCOMPLEX
static int bandfmt_csv[10] = {
// UC C US S UI I F X D DX
UC, C, US, S, UI, I, F, X, D, DX
};
static void
vips_foreign_save_csv_class_init( VipsForeignSaveCsvClass *class )
{
@ -326,7 +310,8 @@ vips_foreign_save_csv_class_init( VipsForeignSaveCsvClass *class )
foreign_class->suffs = vips__foreign_csv_suffs;
save_class->saveable = VIPS_SAVEABLE_MONO;
save_class->format_table = bandfmt_csv;
// no need to define ->format_table, we don't want the input
// cast for us
VIPS_ARG_STRING( class, "filename", 1,
_( "Filename" ),
@ -1348,6 +1333,22 @@ vips_foreign_save_build( VipsObject *object )
return( 0 );
}
#define UC VIPS_FORMAT_UCHAR
#define C VIPS_FORMAT_CHAR
#define US VIPS_FORMAT_USHORT
#define S VIPS_FORMAT_SHORT
#define UI VIPS_FORMAT_UINT
#define I VIPS_FORMAT_INT
#define F VIPS_FORMAT_FLOAT
#define X VIPS_FORMAT_COMPLEX
#define D VIPS_FORMAT_DOUBLE
#define DX VIPS_FORMAT_DPCOMPLEX
static int vips_foreign_save_format_table[10] = {
// UC C US S UI I F X D DX
UC, C, US, S, UI, I, F, X, D, DX
};
static void
vips_foreign_save_class_init( VipsForeignSaveClass *class )
{
@ -1381,6 +1382,10 @@ vips_foreign_save_class_init( VipsForeignSaveClass *class )
class->coding[i] = FALSE;
class->coding[VIPS_CODING_NONE] = TRUE;
/* Default to no cast on save.
*/
class->format_table = vips_foreign_save_format_table;
VIPS_ARG_IMAGE( class, "in", 0,
_( "Input" ),
_( "Image to save" ),

View File

@ -124,27 +124,6 @@ vips_foreign_save_raw_build( VipsObject *object )
return( 0 );
}
/* Save a bit of typing.
*/
#define UC VIPS_FORMAT_UCHAR
#define C VIPS_FORMAT_CHAR
#define US VIPS_FORMAT_USHORT
#define S VIPS_FORMAT_SHORT
#define UI VIPS_FORMAT_UINT
#define I VIPS_FORMAT_INT
#define F VIPS_FORMAT_FLOAT
#define X VIPS_FORMAT_COMPLEX
#define D VIPS_FORMAT_DOUBLE
#define DX VIPS_FORMAT_DPCOMPLEX
/* Type promotion for division. Sign and value preserving. Make sure
* these match the case statement in complexform_buffer() above.
*/
static int vips_bandfmt_raw[10] = {
/* UC C US S UI I F X D DX */
UC, C, US, S, UI, I, F, X, D, DX
};
static void
vips_foreign_save_raw_class_init( VipsForeignSaveRawClass *class )
{
@ -161,7 +140,6 @@ vips_foreign_save_raw_class_init( VipsForeignSaveRawClass *class )
object_class->build = vips_foreign_save_raw_build;
save_class->saveable = VIPS_SAVEABLE_ANY;
save_class->format_table = vips_bandfmt_raw;
VIPS_ARG_STRING( class, "filename", 1,
_( "Filename" ),
@ -268,7 +246,6 @@ vips_foreign_save_raw_fd_class_init( VipsForeignSaveRawFdClass *class )
object_class->build = vips_foreign_save_raw_fd_build;
save_class->saveable = VIPS_SAVEABLE_ANY;
save_class->format_table = vips_bandfmt_raw;
VIPS_ARG_INT( class, "fd", 1,
_( "File descriptor" ),

View File

@ -129,24 +129,6 @@ vips_foreign_save_tiff_build( VipsObject *object )
return( 0 );
}
/* Save a bit of typing.
*/
#define UC VIPS_FORMAT_UCHAR
#define C VIPS_FORMAT_CHAR
#define US VIPS_FORMAT_USHORT
#define S VIPS_FORMAT_SHORT
#define UI VIPS_FORMAT_UINT
#define I VIPS_FORMAT_INT
#define F VIPS_FORMAT_FLOAT
#define X VIPS_FORMAT_COMPLEX
#define D VIPS_FORMAT_DOUBLE
#define DX VIPS_FORMAT_DPCOMPLEX
static int bandfmt_tiff[10] = {
/* UC C US S UI I F X D DX */
UC, UC, US, S, US, US, F, F, F, F
};
static void
vips_foreign_save_tiff_class_init( VipsForeignSaveTiffClass *class )
{
@ -165,7 +147,6 @@ vips_foreign_save_tiff_class_init( VipsForeignSaveTiffClass *class )
foreign_class->suffs = vips__foreign_tiff_suffs;
save_class->saveable = VIPS_SAVEABLE_ANY;
save_class->format_table = bandfmt_tiff;
save_class->coding[VIPS_CODING_LABQ] = TRUE;
VIPS_ARG_STRING( class, "filename", 1,

View File

@ -75,24 +75,6 @@ vips_foreign_save_vips_build( VipsObject *object )
return( 0 );
}
/* Save a bit of typing.
*/
#define UC VIPS_FORMAT_UCHAR
#define C VIPS_FORMAT_CHAR
#define US VIPS_FORMAT_USHORT
#define S VIPS_FORMAT_SHORT
#define UI VIPS_FORMAT_UINT
#define I VIPS_FORMAT_INT
#define F VIPS_FORMAT_FLOAT
#define X VIPS_FORMAT_COMPLEX
#define D VIPS_FORMAT_DOUBLE
#define DX VIPS_FORMAT_DPCOMPLEX
static int vips_bandfmt_vips[10] = {
/* UC C US S UI I F X D DX */
UC, C, US, S, UI, I, F, X, D, DX
};
static const char *vips_suffs[] = { ".v", NULL };
static void
@ -115,7 +97,6 @@ vips_foreign_save_vips_class_init( VipsForeignSaveVipsClass *class )
foreign_class->suffs = vips_suffs;
save_class->saveable = VIPS_SAVEABLE_ANY;
save_class->format_table = vips_bandfmt_vips;
for( i = 0; i < VIPS_CODING_LAST; i++ )
save_class->coding[i] = TRUE;