"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "libvips/foreign/spngload.c" between
vips-8.10.6.tar.gz and vips-8.11.0.tar.gz

About: VIPS is a free image processing system (see also the GUI nip2).

spngload.c  (vips-8.10.6):spngload.c  (vips-8.11.0)
/* load PNG with libspng /* load PNG with libspng
* *
* 1/5/20 * 1/5/20
* - from pngload.c * - from pngload.c
* 19/2/21 781545872
* - read out background, if we can
*/ */
/* /*
This file is part of VIPS. This file is part of VIPS.
VIPS is free software; you can redistribute it and/or modify VIPS is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
skipping to change at line 202 skipping to change at line 204
} }
} }
static void static void
vips_foreign_load_png_set_header( VipsForeignLoadPng *png, VipsImage *image ) vips_foreign_load_png_set_header( VipsForeignLoadPng *png, VipsImage *image )
{ {
double xres, yres; double xres, yres;
struct spng_iccp iccp; struct spng_iccp iccp;
struct spng_exif exif; struct spng_exif exif;
struct spng_phys phys; struct spng_phys phys;
struct spng_bkgd bkgd;
guint32 n_text; guint32 n_text;
/* Get resolution. Default to 72 pixels per inch. /* Get resolution. Default to 72 pixels per inch.
*/ */
xres = 72.0 / 25.4; xres = 72.0 / 25.4;
yres = 72.0 / 25.4; yres = 72.0 / 25.4;
if( !spng_get_phys( png->ctx, &phys ) ) { if( !spng_get_phys( png->ctx, &phys ) ) {
/* unit 1 means pixels per metre, otherwise unspecified. /* unit 1 means pixels per metre, otherwise unspecified.
*/ */
xres = phys.unit_specifier == 1 ? xres = phys.unit_specifier == 1 ?
skipping to change at line 270 skipping to change at line 273
/* Attach original palette bit depth, if any, as metadata. /* Attach original palette bit depth, if any, as metadata.
*/ */
if( png->ihdr.color_type == SPNG_COLOR_TYPE_INDEXED ) if( png->ihdr.color_type == SPNG_COLOR_TYPE_INDEXED )
vips_image_set_int( image, vips_image_set_int( image,
"palette-bit-depth", png->ihdr.bit_depth ); "palette-bit-depth", png->ihdr.bit_depth );
/* Let our caller know. These are very expensive to decode. /* Let our caller know. These are very expensive to decode.
*/ */
if( png->ihdr.interlace_method != SPNG_INTERLACE_NONE ) if( png->ihdr.interlace_method != SPNG_INTERLACE_NONE )
vips_image_set_int( image, "interlaced", 1 ); vips_image_set_int( image, "interlaced", 1 );
if( !spng_get_bkgd( png->ctx, &bkgd ) ) {
const int scale = image->BandFmt ==
VIPS_FORMAT_UCHAR ? 1 : 256;
double array[3];
int n;
switch( png->ihdr.color_type ) {
case SPNG_COLOR_TYPE_GRAYSCALE:
case SPNG_COLOR_TYPE_GRAYSCALE_ALPHA:
array[0] = bkgd.gray / scale;
n = 1;
break;
case SPNG_COLOR_TYPE_TRUECOLOR:
case SPNG_COLOR_TYPE_TRUECOLOR_ALPHA:
array[0] = bkgd.red / scale;
array[1] = bkgd.green / scale;
array[2] = bkgd.blue / scale;
n = 3;
break;
case SPNG_COLOR_TYPE_INDEXED:
default:
/* Not sure what to do here. I suppose we should read
* the palette.
*/
n = 0;
break;
}
if( n > 0 )
vips_image_set_array_double( image, "background",
array, n );
}
} }
static int static int
vips_foreign_load_png_header( VipsForeignLoad *load ) vips_foreign_load_png_header( VipsForeignLoad *load )
{ {
VipsObjectClass *class = VIPS_OBJECT_GET_CLASS( load ); VipsObjectClass *class = VIPS_OBJECT_GET_CLASS( load );
VipsForeignLoadPng *png = (VipsForeignLoadPng *) load; VipsForeignLoadPng *png = (VipsForeignLoadPng *) load;
int flags; int flags;
int error; int error;
 End of changes. 3 change blocks. 
0 lines changed or deleted 39 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)