update for latest spng 1/2/4 bit handling

This commit is contained in:
John Cupitt 2020-06-09 02:27:46 +01:00
parent 70a1dc0926
commit f113e64515
1 changed files with 18 additions and 0 deletions

View File

@ -275,6 +275,7 @@ vips_foreign_load_png_header( VipsForeignLoad *load )
int flags;
int error;
struct spng_trns trns;
/* In non-fail mode, ignore CRC errors.
*/
@ -354,6 +355,23 @@ vips_foreign_load_png_header( VipsForeignLoad *load )
return( -1 );
}
if( !spng_get_trns( png->ctx, &trns ) ) {
if( png->ihdr.color_type == SPNG_COLOR_TYPE_TRUECOLOR ) {
if( png->ihdr.bit_depth == 16 )
png->fmt = SPNG_FMT_RGBA16;
else
png->fmt = SPNG_FMT_RGBA8;
}
else if( png->ihdr.color_type == SPNG_COLOR_TYPE_INDEXED )
png->fmt = SPNG_FMT_RGBA8;
else if( png->ihdr.color_type == SPNG_COLOR_TYPE_GRAYSCALE ) {
if( png->ihdr.bit_depth == 16 )
png->fmt = SPNG_FMT_GA16;
else
png->fmt = SPNG_FMT_GA8;
}
}
if( png->ihdr.bit_depth == 16 ) {
png->format = VIPS_FORMAT_USHORT;
if( png->interpretation == VIPS_INTERPRETATION_B_W )