byteswap on ppm save, if necessary
this was missing, thanks ewelot see https://github.com/libvips/libvips/issues/1894
This commit is contained in:
parent
c0bace8f91
commit
6340e14303
|
@ -11,7 +11,7 @@
|
|||
- add missing read loops to spng, heif, giflib and ppm load [kleisauke]
|
||||
- block zero width or height images from imagemagick load [Koen1999]
|
||||
- check for overflow in gifload height [lovell]
|
||||
- fix msb_first default in ppm load [ewelot]
|
||||
- fix msb_first default in ppm load and save [ewelot]
|
||||
|
||||
6/9/20 started 8.10.2
|
||||
- update magicksave/load profile handling [kelilevi]
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
* - add "bitdepth" param, cf. tiffsave
|
||||
* 27/6/20
|
||||
* - add ppmsave_target
|
||||
* 20/11/20
|
||||
* - byteswap on save, if necessary [ewelot]
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@ -298,6 +300,19 @@ vips_foreign_save_ppm( VipsForeignSavePpm *ppm, VipsImage *image )
|
|||
vips_foreign_save_ppm_line_ascii :
|
||||
vips_foreign_save_ppm_line_binary;
|
||||
|
||||
/* 16 and 32-bit binary write might need byteswapping.
|
||||
*/
|
||||
if( !ppm->ascii &&
|
||||
(image->BandFmt == VIPS_FORMAT_USHORT ||
|
||||
image->BandFmt == VIPS_FORMAT_UINT) ) {
|
||||
VipsImage *x;
|
||||
|
||||
if( vips__byteswap_bool( image, &x, !vips_amiMSBfirst() ) )
|
||||
return( -1 );
|
||||
VIPS_UNREF( image );
|
||||
image = x;
|
||||
}
|
||||
|
||||
if( vips_sink_disc( image, vips_foreign_save_ppm_block, ppm ) )
|
||||
return( -1 );
|
||||
|
||||
|
@ -402,7 +417,7 @@ vips_foreign_save_ppm_class_init( VipsForeignSavePpmClass *class )
|
|||
|
||||
VIPS_ARG_INT( class, "bitdepth", 15,
|
||||
_( "bitdepth" ),
|
||||
_( "Write as a 1 bit image" ),
|
||||
_( "set to 1 to write as a 1 bit image" ),
|
||||
VIPS_ARGUMENT_OPTIONAL_INPUT,
|
||||
G_STRUCT_OFFSET( VipsForeignSavePpm, bitdepth ),
|
||||
0, 1, 0 );
|
||||
|
|
Loading…
Reference in New Issue