rename ppmsave "squash" as "bitdepth"
in line with the tiffsave change
This commit is contained in:
parent
94b137d526
commit
1f8d007d19
@ -33,6 +33,7 @@
|
|||||||
- add --vips-config flag to show configuration info
|
- add --vips-config flag to show configuration info
|
||||||
- add "bitdepth" param to tiff load and save, deprecate "squash" [MathemanFlo]
|
- add "bitdepth" param to tiff load and save, deprecate "squash" [MathemanFlo]
|
||||||
- tiff load and save now supports 2 and 4 bit data [MathemanFlo]
|
- tiff load and save now supports 2 and 4 bit data [MathemanFlo]
|
||||||
|
- ppmsave also uses "bitdepth" now, for consistency
|
||||||
|
|
||||||
24/4/20 started 8.9.3
|
24/4/20 started 8.9.3
|
||||||
- better iiif tile naming [IllyaMoskvin]
|
- better iiif tile naming [IllyaMoskvin]
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
* - wrap a class around the ppm writer
|
* - wrap a class around the ppm writer
|
||||||
* 13/11/19
|
* 13/11/19
|
||||||
* - redone with targets
|
* - redone with targets
|
||||||
|
* 18/6/20
|
||||||
|
* - add "bitdepth" param, cf. tiffsave
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -63,9 +65,13 @@ typedef struct _VipsForeignSavePpm {
|
|||||||
|
|
||||||
VipsTarget *target;
|
VipsTarget *target;
|
||||||
gboolean ascii;
|
gboolean ascii;
|
||||||
gboolean squash;
|
int bitdepth;
|
||||||
|
|
||||||
VipsSavePpmFn fn;
|
VipsSavePpmFn fn;
|
||||||
|
|
||||||
|
/* Deprecated.
|
||||||
|
*/
|
||||||
|
gboolean squash;
|
||||||
} VipsForeignSavePpm;
|
} VipsForeignSavePpm;
|
||||||
|
|
||||||
typedef VipsForeignSaveClass VipsForeignSavePpmClass;
|
typedef VipsForeignSaveClass VipsForeignSavePpmClass;
|
||||||
@ -123,7 +129,7 @@ vips_foreign_save_ppm_line_ascii( VipsForeignSavePpm *ppm,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
vips_foreign_save_ppm_line_ascii_squash( VipsForeignSavePpm *ppm,
|
vips_foreign_save_ppm_line_ascii_1bit( VipsForeignSavePpm *ppm,
|
||||||
VipsImage *image, VipsPel *p )
|
VipsImage *image, VipsPel *p )
|
||||||
{
|
{
|
||||||
int x;
|
int x;
|
||||||
@ -149,7 +155,7 @@ vips_foreign_save_ppm_line_binary( VipsForeignSavePpm *ppm,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
vips_foreign_save_ppm_line_binary_squash( VipsForeignSavePpm *ppm,
|
vips_foreign_save_ppm_line_binary_1bit( VipsForeignSavePpm *ppm,
|
||||||
VipsImage *image, VipsPel *p )
|
VipsImage *image, VipsPel *p )
|
||||||
{
|
{
|
||||||
int x;
|
int x;
|
||||||
@ -214,14 +220,14 @@ vips_foreign_save_ppm( VipsForeignSavePpm *ppm, VipsImage *image )
|
|||||||
magic = "Pf";
|
magic = "Pf";
|
||||||
else if( image->Bands == 1 &&
|
else if( image->Bands == 1 &&
|
||||||
ppm->ascii &&
|
ppm->ascii &&
|
||||||
ppm->squash )
|
ppm->bitdepth )
|
||||||
magic = "P1";
|
magic = "P1";
|
||||||
else if( image->Bands == 1 &&
|
else if( image->Bands == 1 &&
|
||||||
ppm->ascii )
|
ppm->ascii )
|
||||||
magic = "P2";
|
magic = "P2";
|
||||||
else if( image->Bands == 1 &&
|
else if( image->Bands == 1 &&
|
||||||
!ppm->ascii &&
|
!ppm->ascii &&
|
||||||
ppm->squash )
|
ppm->bitdepth )
|
||||||
magic = "P4";
|
magic = "P4";
|
||||||
else if( image->Bands == 1 &&
|
else if( image->Bands == 1 &&
|
||||||
!ppm->ascii )
|
!ppm->ascii )
|
||||||
@ -243,7 +249,7 @@ vips_foreign_save_ppm( VipsForeignSavePpm *ppm, VipsImage *image )
|
|||||||
vips_target_writef( ppm->target,
|
vips_target_writef( ppm->target,
|
||||||
"%d %d\n", image->Xsize, image->Ysize );
|
"%d %d\n", image->Xsize, image->Ysize );
|
||||||
|
|
||||||
if( !ppm->squash )
|
if( !ppm->bitdepth )
|
||||||
switch( image->BandFmt ) {
|
switch( image->BandFmt ) {
|
||||||
case VIPS_FORMAT_UCHAR:
|
case VIPS_FORMAT_UCHAR:
|
||||||
vips_target_writef( ppm->target,
|
vips_target_writef( ppm->target,
|
||||||
@ -281,10 +287,10 @@ vips_foreign_save_ppm( VipsForeignSavePpm *ppm, VipsImage *image )
|
|||||||
g_assert_not_reached();
|
g_assert_not_reached();
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ppm->squash )
|
if( ppm->bitdepth )
|
||||||
ppm->fn = ppm->ascii ?
|
ppm->fn = ppm->ascii ?
|
||||||
vips_foreign_save_ppm_line_ascii_squash :
|
vips_foreign_save_ppm_line_ascii_1bit :
|
||||||
vips_foreign_save_ppm_line_binary_squash;
|
vips_foreign_save_ppm_line_binary_1bit;
|
||||||
else
|
else
|
||||||
ppm->fn = ppm->ascii ?
|
ppm->fn = ppm->ascii ?
|
||||||
vips_foreign_save_ppm_line_ascii :
|
vips_foreign_save_ppm_line_ascii :
|
||||||
@ -308,6 +314,11 @@ vips_foreign_save_ppm_build( VipsObject *object )
|
|||||||
build( object ) )
|
build( object ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
|
/* Handle the deprecated squash parameter.
|
||||||
|
*/
|
||||||
|
if( vips_object_argument_isset( object, "squash" ) )
|
||||||
|
ppm->bitdepth = 1;
|
||||||
|
|
||||||
image = save->ready;
|
image = save->ready;
|
||||||
if( vips_check_uintorf( "vips2ppm", image ) ||
|
if( vips_check_uintorf( "vips2ppm", image ) ||
|
||||||
vips_check_bands_1or3( "vips2ppm", image ) ||
|
vips_check_bands_1or3( "vips2ppm", image ) ||
|
||||||
@ -324,13 +335,13 @@ vips_foreign_save_ppm_build( VipsObject *object )
|
|||||||
|
|
||||||
/* One bit images must come from a 8 bit, one band source.
|
/* One bit images must come from a 8 bit, one band source.
|
||||||
*/
|
*/
|
||||||
if( ppm->squash &&
|
if( ppm->bitdepth &&
|
||||||
(image->Bands != 1 ||
|
(image->Bands != 1 ||
|
||||||
image->BandFmt != VIPS_FORMAT_UCHAR) ) {
|
image->BandFmt != VIPS_FORMAT_UCHAR) ) {
|
||||||
g_warning( "%s",
|
g_warning( "%s",
|
||||||
_( "can only squash 1 band uchar images -- "
|
_( "can only save 1 band uchar images as 1 bit -- "
|
||||||
"disabling squash" ) );
|
"disabling 1 bit save" ) );
|
||||||
ppm->squash = FALSE;
|
ppm->bitdepth = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( vips_foreign_save_ppm( ppm, image ) )
|
if( vips_foreign_save_ppm( ppm, image ) )
|
||||||
@ -385,10 +396,17 @@ vips_foreign_save_ppm_class_init( VipsForeignSavePpmClass *class )
|
|||||||
G_STRUCT_OFFSET( VipsForeignSavePpm, ascii ),
|
G_STRUCT_OFFSET( VipsForeignSavePpm, ascii ),
|
||||||
FALSE );
|
FALSE );
|
||||||
|
|
||||||
|
VIPS_ARG_INT( class, "bitdepth", 15,
|
||||||
|
_( "bitdepth" ),
|
||||||
|
_( "Write as a 1 bit image" ),
|
||||||
|
VIPS_ARGUMENT_OPTIONAL_INPUT,
|
||||||
|
G_STRUCT_OFFSET( VipsForeignSavePpm, bitdepth ),
|
||||||
|
0, 1, 0 );
|
||||||
|
|
||||||
VIPS_ARG_BOOL( class, "squash", 11,
|
VIPS_ARG_BOOL( class, "squash", 11,
|
||||||
_( "Squash" ),
|
_( "Squash" ),
|
||||||
_( "save as one bit" ),
|
_( "save as one bit" ),
|
||||||
VIPS_ARGUMENT_OPTIONAL_INPUT,
|
VIPS_ARGUMENT_OPTIONAL_INPUT | VIPS_ARGUMENT_DEPRECATED,
|
||||||
G_STRUCT_OFFSET( VipsForeignSavePpm, squash ),
|
G_STRUCT_OFFSET( VipsForeignSavePpm, squash ),
|
||||||
FALSE );
|
FALSE );
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user