From 8d95ff275b9bba81d5fa55fde58bc367b007b3fd Mon Sep 17 00:00:00 2001 From: wiz Date: Thu, 21 Aug 2014 20:58:23 +0000 Subject: Update to 10.35.92: 14.03.29 BJH Release 10.35.92 ppmrelief: fix out-of-bound values in output. Always broken. Thanks Prophet of the Way . ppmrelief: fix crash when input image is too small. Always broken. Thanks Prophet of the Way . pgmtexture: fix buffer overflow. Always broken. (Program was added in primordial Netpbm in 1991). pamdeinterlace: fix incorrect output with -takeodd and image has only one row. Always broken (pamdeinterlace was introduced in Netpbm 9.21 (January 2001)). Thanks Prophet of the Way . 13.12.24 BJH Release 10.35.91 pbmtoepsi: fix handling of all-white image. Always broken. Thanks Prophet of the Way . pbmtoepsi: fix excessively long raster line. Always broken. Thanks Prophet of the Way . pnmshear: fix incorrect determination of background color. Always broken. ppmpat: fix crash with -squig with aspect ratio < 1:25 or > 25:1. Thanks Prophet of the Way . Always broken. pamgauss: Fix typo in message. 13.09.26 BJH Release 10.35.90 ppmtoxpm: fix bug: ignores inability to open the specified color dictionary file (-rgb) and just doesn't use color names. Introduced in Netpbm 10.15 (April 2003). ppmforge. fix crash when -mesh is 1 or less. Always broken (program was added in Pbmplus (October 1991). Thanks Prophet of the Way . ppmforge: fix array bounds violation. Always broken (program was added in Pbmplus (October 1991). Thanks Prophet of the Way . 13.05.03 BJH Release 10.35.89 ppmtowinicon: fix bug: sometimes creates image truncated in the middle of the AND mask. Always broken (program was new in Netpbm 9.3 (June 2000)). pamtilt: fix bug: incorrect output or invalid memory access crash. Always broken (program was new in Neptbm 10.30 (October 2005)). 13.02.20 BJH Release 10.35.88 ppmpat: fix wrong output with -poles. Windows build: fix compile error on urt/rle_open_f.c due to Unix process management stuff. leaftoppm: fix incorrect determination of whether input is Interleaf on 64 bit systems. Always broken. cmuwmtopbm: fix incorrect determination of whether input is a CMU window manager bitmap on 64 bit systems. Always broken. 12.12.05 BJH Release 10.35.87 pamtotiff: fix bug: XRESOLUTION, YRESOLUTION, and RESOLUTIONUNIT not allowed in -tags. Broken at least since 10.35.00. pnmmontage: fix random stuff placed in unoccupied space in the output image. Always broken (program was new in 9.10 (January 2001). pnmpsnr: fix crash when invoked (invalidly) with only one argument. Always broken. pampick: fix wild pointer in command line parsing. Bug has always been there. pamgauss: Fix bug: erroneously says -maxval is too big. Always broken (Pamgauss was added in 10.23 (July 2004). 12.07.23 BJH Release 10.35.86 ppmtobmp: fix failure with "internal error" message on all uses. Broken in 10.35.78. Build: rename getline() in xpmtoppm.c to avoid collision with some libc. Always broken. 12.06.21 BJH Release 10.35.85 configure: work around Perl bug that causes 'configure' to falsely conclude Svgalib is installed. Build: move -lm to end of -l's. Broken at least since 10.35. 12.02.14 BJH Release 10.35.84 pamscale: fix all black output with resampling. Always broken. pgmtexture: fix integer overflow in difference variance. Always broken. pgmtexture: fix array bounds violations in various calculations. Always broken. Build: always put Netpbm header files before external library header files in search path. 11.11.25 BJH Release 10.35.83 pngtopnm: fix crash with invalid tIME chunk. Always broken. 11.09.25 BJH Release 10.35.82 pnmtopng: fix bug: with -alpha specifying a mask which contains no fully transparent area, output PNG is fully opaque. Introduced in 10.29. pnmquant: work with older Perl that doesn't have 3-argument open. pnmtops: fix message: says "from top edge" where it means "from bottom edge." 11.07.10 BJH Release 10.35.81 pgmtexture: fix wrong sum variance result. Wrong since the beginning. Thanks Francois P. S. Luus . --- graphics/netpbm/Makefile | 5 +- graphics/netpbm/distinfo | 14 +- graphics/netpbm/patches/patch-af | 888 -------------------- graphics/netpbm/patches/patch-ah | 23 - .../patches/patch-converter_other_pngtopnm.c | 898 +++++++++++++++++++++ graphics/netpbm/patches/patch-dc | 8 +- graphics/netpbm/patches/patch-eb | 147 ---- 7 files changed, 910 insertions(+), 1073 deletions(-) delete mode 100644 graphics/netpbm/patches/patch-af delete mode 100644 graphics/netpbm/patches/patch-ah create mode 100644 graphics/netpbm/patches/patch-converter_other_pngtopnm.c delete mode 100644 graphics/netpbm/patches/patch-eb (limited to 'graphics/netpbm') diff --git a/graphics/netpbm/Makefile b/graphics/netpbm/Makefile index ef0b3196dde..b7e08d1fad6 100644 --- a/graphics/netpbm/Makefile +++ b/graphics/netpbm/Makefile @@ -1,7 +1,6 @@ -# $NetBSD: Makefile,v 1.185 2014/07/17 15:52:25 ryoon Exp $ +# $NetBSD: Makefile,v 1.186 2014/08/21 20:58:23 wiz Exp $ -DISTNAME= netpbm-10.35.80 -PKGREVISION= 8 +DISTNAME= netpbm-10.35.92 CATEGORIES= graphics MASTER_SITES= ${MASTER_SITE_SOURCEFORGE:=netpbm/} EXTRACT_SUFX= .tgz diff --git a/graphics/netpbm/distinfo b/graphics/netpbm/distinfo index bed837eab2e..2fb4d0578c9 100644 --- a/graphics/netpbm/distinfo +++ b/graphics/netpbm/distinfo @@ -1,16 +1,14 @@ -$NetBSD: distinfo,v 1.87 2014/07/17 15:52:25 ryoon Exp $ +$NetBSD: distinfo,v 1.88 2014/08/21 20:58:23 wiz Exp $ -SHA1 (netpbm-10.35.80.tgz) = e2bc82c2fc76775a837596f9774f4b24275f794a -RMD160 (netpbm-10.35.80.tgz) = f8c6dc01ada947f27dd851d954d240f248e07c55 -Size (netpbm-10.35.80.tgz) = 2547601 bytes +SHA1 (netpbm-10.35.92.tgz) = b0c480d066cea7560429c156c4f7bfa5f18e0f9b +RMD160 (netpbm-10.35.92.tgz) = c102b79d8aa235b8e3c2e7529d316485869fb098 +Size (netpbm-10.35.92.tgz) = 2557334 bytes SHA1 (patch-aa) = fd533685c5b0058f19d1b4525a4b2b9f2b239627 SHA1 (patch-ab) = 4d6508ad837d455ea3f8ebaa704f33f9e089f6e0 SHA1 (patch-ac) = 11c029673a53e9344a477db6cfcb46f32e9f6a93 SHA1 (patch-ad) = c9ed6aed9d503a94c94a39c8ee088f9ba2a6dd25 SHA1 (patch-ae) = 33a5be2843dd85b530f5e6ba496cd0380cd5edd1 -SHA1 (patch-af) = e8965899d577648c6144098f2aa8e1594551666a SHA1 (patch-ag) = 093fe392a3e6156cc55f225a6f139842c0d00570 -SHA1 (patch-ah) = 10d7e7f59a0d7c857531db872cd35dc02a048ba1 SHA1 (patch-ai) = 083ddf8b36a74ca39508b6a3b0c35956ac19fbb7 SHA1 (patch-aj) = 44521e88f446a9a4eea6d9ffeb20ceba4653faca SHA1 (patch-ak) = f1e06e236442c96670b1f1829d4e67d051ecb776 @@ -20,12 +18,12 @@ SHA1 (patch-aw) = bd890324e95fa7bb893d9d5cdab9d5a33dcff777 SHA1 (patch-ax) = d50e56191192b4caf423ed081581868bb1a63de8 SHA1 (patch-ay) = 60ab532de6d6ec498ada140f795bba327a562e13 SHA1 (patch-cb) = b1be33ae6acfe57bf2f407cd48a6b140c3ddea85 +SHA1 (patch-converter_other_pngtopnm.c) = d0054e042e616758c4a2787d7e9b35c8f232c40f SHA1 (patch-converter_ppm_ppmtompeg_psocket.c) = ebb11ea1867ed401a0299eeb907aad70276ce843 SHA1 (patch-da) = 8ae329469bf0bd55b671dffeb4253b8d14621f5c SHA1 (patch-db) = 23a05e54043ee84a0b7ec507a383d5cd8adfcca5 -SHA1 (patch-dc) = 8ed1365dccf5abb0e158a4f7a65749ff5b244ef3 +SHA1 (patch-dc) = affd0ca1b437a6c5b10f1ffacff5d0ed9185cda7 SHA1 (patch-dd) = 9f9c53959f5afd444ce427b782f9ba2c73068f27 -SHA1 (patch-eb) = 8af326d4be7e280764843ce213672186fce3f9a8 SHA1 (patch-lib_libpbm3.c) = 42e7d49fecb559fb1d55345e5053337e60f7458b SHA1 (patch-lib_libsystem.c) = a140994267e62a90dd63667a0f87c65a2278ed0f SHA1 (patch-ppmdraw) = d901a690f8f21a1af940129d1edef509b369ea1a diff --git a/graphics/netpbm/patches/patch-af b/graphics/netpbm/patches/patch-af deleted file mode 100644 index 3e1c3eee8b0..00000000000 --- a/graphics/netpbm/patches/patch-af +++ /dev/null @@ -1,888 +0,0 @@ -$NetBSD: patch-af,v 1.16 2011/04/04 09:17:24 adam Exp $ - -Fix build with png-1.5. - ---- converter/other/pngtopnm.c.orig 2009-09-03 16:34:36.000000000 +0100 -+++ converter/other/pngtopnm.c 2011-01-15 18:19:09.000000000 +0000 -@@ -44,12 +44,6 @@ - #include "nstring.h" - #include "shhopt.h" - --#if PNG_LIBPNG_VER >= 10400 --#error Your PNG library () is incompatible with this Netpbm source code. --#error You need either an older PNG library (older than 1.4) --#error newer Netpbm source code (at least 10.48) --#endif -- - typedef struct _jmpbuf_wrapper { - jmp_buf jmpbuf; - } jmpbuf_wrapper; -@@ -187,7 +181,7 @@ - - - --#define get_png_val(p) _get_png_val (&(p), info_ptr->bit_depth) -+#define get_png_val(p) _get_png_val (&(p), png_get_bit_depth(png_ptr, info_ptr)) - - static png_uint_16 - _get_png_val (png_byte ** const pp, -@@ -266,33 +260,39 @@ - } - - #ifdef __STDC__ --static void save_text (png_info *info_ptr, FILE *tfp) -+static void save_text (png_structp png_ptr, png_info *info_ptr, FILE *tfp) - #else --static void save_text (info_ptr, tfp) -+static void save_text (png_ptr, info_ptr, tfp) -+png_structp png_ptr; - png_info *info_ptr; - FILE *tfp; - #endif - { - int i, j, k; -+ png_textp text_ptr; -+ int num_text; -+ -+ if (png_get_text(png_ptr, info_ptr, &text_ptr, &num_text) == 0) -+ return; - -- for (i = 0 ; i < info_ptr->num_text ; i++) { -+ for (i = 0 ; i < num_text ; i++) { - j = 0; -- while (info_ptr->text[i].key[j] != '\0' && info_ptr->text[i].key[j] != ' ') -+ while (text_ptr[i].key[j] != '\0' && text_ptr[i].key[j] != ' ') - j++; -- if (info_ptr->text[i].key[j] != ' ') { -- fprintf (tfp, "%s", info_ptr->text[i].key); -- for (j = strlen (info_ptr->text[i].key) ; j < 15 ; j++) -+ if (text_ptr[i].key[j] != ' ') { -+ fprintf (tfp, "%s", text_ptr[i].key); -+ for (j = strlen (text_ptr[i].key) ; j < 15 ; j++) - putc (' ', tfp); - } else { -- fprintf (tfp, "\"%s\"", info_ptr->text[i].key); -- for (j = strlen (info_ptr->text[i].key) ; j < 13 ; j++) -+ fprintf (tfp, "\"%s\"", text_ptr[i].key); -+ for (j = strlen (text_ptr[i].key) ; j < 13 ; j++) - putc (' ', tfp); - } - putc (' ', tfp); /* at least one space between key and text */ - -- for (j = 0 ; j < info_ptr->text[i].text_length ; j++) { -- putc (info_ptr->text[i].text[j], tfp); -- if (info_ptr->text[i].text[j] == '\n') -+ for (j = 0 ; j < text_ptr[i].text_length ; j++) { -+ putc (text_ptr[i].text[j], tfp); -+ if (text_ptr[i].text[j] == '\n') - for (k = 0 ; k < 16 ; k++) - putc ((int)' ', tfp); - } -@@ -301,9 +301,10 @@ - } - - #ifdef __STDC__ --static void show_time (png_info *info_ptr) -+static void show_time (png_structp png_ptr, png_info *info_ptr) - #else --static void show_time (info_ptr) -+static void show_time (png_ptr, info_ptr) -+png_structp png_ptr; - png_info *info_ptr; - #endif - { -@@ -311,12 +312,13 @@ - "", "January", "February", "March", "April", "May", "June", - "July", "August", "September", "October", "November", "December" - }; -+ png_timep mod_time; - -- if (info_ptr->valid & PNG_INFO_tIME) { -+ if (png_get_tIME(png_ptr, info_ptr, &mod_time) & PNG_INFO_tIME) { - pm_message ("modification time: %02d %s %d %02d:%02d:%02d", -- info_ptr->mod_time.day, month[info_ptr->mod_time.month], -- info_ptr->mod_time.year, info_ptr->mod_time.hour, -- info_ptr->mod_time.minute, info_ptr->mod_time.second); -+ mod_time->day, month[mod_time->month], -+ mod_time->year, mod_time->hour, -+ mod_time->minute, mod_time->second); - } - } - -@@ -353,12 +355,28 @@ - - - static void --dump_png_info(png_info *info_ptr) { -+dump_png_info(png_structp png_ptr, png_info *info_ptr) { - - const char *type_string; - const char *filter_string; -+ png_color_16p background; -+ int num_trans; -+ double gamma; -+ png_color_8p sig_bit; -+ png_colorp palette; -+ int num_palette; -+ png_uint_16p hist; -+ int res_x, res_y, unit_type; -+ png_int_32 offset_x, offset_y; -+ png_timep mod_time; -+ png_charp purpose; -+ png_int_32 X0, X1; -+ int type, nparams; -+ png_charp units; -+ png_charpp params; -+ int file_srgb_intent; - -- switch (info_ptr->color_type) { -+ switch (png_get_color_type(png_ptr, info_ptr)) { - case PNG_COLOR_TYPE_GRAY: - type_string = "gray"; - break; -@@ -380,90 +398,101 @@ - break; - } - -- switch (info_ptr->filter_type) { -+ switch (png_get_filter_type(png_ptr, info_ptr)) { - case PNG_FILTER_TYPE_BASE: - asprintfN(&filter_string, "base filter"); - break; - default: - asprintfN(&filter_string, "unknown filter type %d", -- info_ptr->filter_type); -+ png_get_filter_type(png_ptr, info_ptr)); - } - -- pm_message("reading a %ldw x %ldh image, %d bit%s", -- info_ptr->width, info_ptr->height, -- info_ptr->bit_depth, info_ptr->bit_depth > 1 ? "s" : ""); -+ pm_message("reading a %uw x %uh image, %d bit%s", -+ png_get_image_width(png_ptr, info_ptr), -+ png_get_image_height(png_ptr, info_ptr), -+ png_get_bit_depth(png_ptr, info_ptr), -+ png_get_bit_depth(png_ptr, info_ptr) > 1 ? "s" : ""); - pm_message("%s, %s, %s", - type_string, -- info_ptr->interlace_type ? -+ png_get_interlace_type(png_ptr, info_ptr) ? - "Adam7 interlaced" : "not interlaced", - filter_string); -- pm_message("background {index, gray, red, green, blue} = " -- "{%d, %d, %d, %d, %d}", -- info_ptr->background.index, -- info_ptr->background.gray, -- info_ptr->background.red, -- info_ptr->background.green, -- info_ptr->background.blue); -+ -+ if (png_get_bKGD(png_ptr, info_ptr, &background) & PNG_INFO_bKGD) { -+ pm_message("background {index, gray, red, green, blue} = " -+ "{%d, %d, %d, %d, %d}", -+ background->index, -+ background->gray, -+ background->red, -+ background->green, -+ background->blue); -+ } - - strfree(filter_string); - -- if (info_ptr->valid & PNG_INFO_tRNS) -+ if (png_get_tRNS(png_ptr, info_ptr, -+ NULL, &num_trans, NULL) & PNG_INFO_tRNS) - pm_message("tRNS chunk (transparency): %u entries", -- info_ptr->num_trans); -+ num_trans); - else - pm_message("tRNS chunk (transparency): not present"); - -- if (info_ptr->valid & PNG_INFO_gAMA) -- pm_message("gAMA chunk (image gamma): gamma = %4.2f", info_ptr->gamma); -+ if (png_get_gAMA(png_ptr, info_ptr, &gamma) & PNG_INFO_gAMA) -+ pm_message("gAMA chunk (image gamma): gamma = %4.2f", gamma); - else - pm_message("gAMA chunk (image gamma): not present"); - -- if (info_ptr->valid & PNG_INFO_sBIT) -+ if (png_get_sBIT(png_ptr, info_ptr, &sig_bit) & PNG_INFO_sBIT) - pm_message("sBIT chunk: present"); - else - pm_message("sBIT chunk: not present"); - -- if (info_ptr->valid & PNG_INFO_cHRM) -+ if (png_get_cHRM(png_ptr, info_ptr, -+ NULL, NULL, NULL, NULL, -+ NULL, NULL, NULL, NULL) & PNG_INFO_cHRM) - pm_message("cHRM chunk: present"); - else - pm_message("cHRM chunk: not present"); - -- if (info_ptr->valid & PNG_INFO_PLTE) -- pm_message("PLTE chunk: %d entries", info_ptr->num_palette); -+ if (png_get_PLTE(png_ptr, info_ptr, &palette, &num_palette) & PNG_INFO_PLTE) -+ pm_message("PLTE chunk: %d entries", num_palette); - else - pm_message("PLTE chunk: not present"); - -- if (info_ptr->valid & PNG_INFO_bKGD) -+ if (png_get_bKGD(png_ptr, info_ptr, &background) & PNG_INFO_bKGD) - pm_message("bKGD chunk: present"); - else - pm_message("bKGD chunk: not present"); - -- if (info_ptr->valid & PNG_INFO_hIST) -+ if (png_get_hIST(png_ptr, info_ptr, &hist) & PNG_INFO_hIST) - pm_message("hIST chunk: present"); - else - pm_message("hIST chunk: not present"); - -- if (info_ptr->valid & PNG_INFO_pHYs) -+ if (png_get_pHYs(png_ptr, info_ptr, -+ &res_x, &res_y, &unit_type) & PNG_INFO_pHYs) - pm_message("pHYs chunk: present"); - else - pm_message("pHYs chunk: not present"); - -- if (info_ptr->valid & PNG_INFO_oFFs) -+ if (png_get_oFFs(png_ptr, info_ptr, -+ &offset_x, &offset_y, &unit_type) & PNG_INFO_oFFs) - pm_message("oFFs chunk: present"); - else - pm_message("oFFs chunk: not present"); - -- if (info_ptr->valid & PNG_INFO_tIME) -+ if (png_get_tIME(png_ptr, info_ptr, &mod_time) & PNG_INFO_tIME) - pm_message("tIME chunk: present"); - else - pm_message("tIME chunk: not present"); - -- if (info_ptr->valid & PNG_INFO_pCAL) -+ if (png_get_pCAL(png_ptr, info_ptr, &purpose, &X0, &X1, -+ &type, &nparams, &units, ¶ms) & PNG_INFO_pCAL) - pm_message("pCAL chunk: present"); - else - pm_message("pCAL chunk: not present"); - -- if (info_ptr->valid & PNG_INFO_sRGB) -+ if (png_get_sRGB(png_ptr, info_ptr, &file_srgb_intent) & PNG_INFO_sRGB) - pm_message("sRGB chunk: present"); - else - pm_message("sRGB chunk: not present"); -@@ -472,19 +501,19 @@ - - - static bool --isTransparentColor(pngcolor const color, -- png_info * const info_ptr, -- double const totalgamma) { -+isTransparentColor(pngcolor const color, -+ png_structp const png_ptr, -+ png_info * const info_ptr, -+ double const totalgamma) { - /*---------------------------------------------------------------------------- - Return TRUE iff pixels of color 'color' are supposed to be transparent - everywhere they occur. Assume it's an RGB image. - -----------------------------------------------------------------------------*/ - bool retval; -+ png_color_16p transColorP; - -- if (info_ptr->valid & PNG_INFO_tRNS) { -- const png_color_16 * const transColorP = &info_ptr->trans_values; -- -- -+ if (png_get_tRNS(png_ptr, info_ptr, -+ NULL, NULL, &transColorP) & PNG_INFO_tRNS) { - /* There seems to be a problem here: you can't compare real - numbers for equality. Also, I'm not sure the gamma - corrected/uncorrected color spaces are right here. -@@ -530,9 +559,11 @@ - if (displaygamma == -1.0) - *totalgammaP = -1.0; - else { -+ double fileGamma; - float imageGamma; -- if (info_ptr->valid & PNG_INFO_gAMA) -- imageGamma = info_ptr->gamma; -+ -+ if (png_get_gAMA(png_ptr, info_ptr, &fileGamma) & PNG_INFO_gAMA) -+ imageGamma = fileGamma; - else { - if (verbose) - pm_message("PNG doesn't specify image gamma. Assuming 1.0"); -@@ -548,10 +579,14 @@ - } else { - png_set_gamma(png_ptr, displaygamma, imageGamma); - *totalgammaP = imageGamma * displaygamma; -+#ifdef NOT_SUPPORTED_ANYMORE -+ /* The API doesn't clearing PNG_INFO_sBIT. */ -+ - /* in case of gamma-corrections, sBIT's as in the - PNG-file are not valid anymore - */ - info_ptr->valid &= ~PNG_INFO_sBIT; -+#endif - if (verbose) - pm_message("image gamma is %4.2f, " - "converted for display gamma of %4.2f", -@@ -563,20 +598,24 @@ - - - static bool --paletteHasPartialTransparency(png_info * const info_ptr) { -+paletteHasPartialTransparency(png_structp png_ptr, png_info * const info_ptr) { - - bool retval; - -- if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) { -- if (info_ptr->valid & PNG_INFO_tRNS) { -+ if (png_get_color_type(png_ptr, info_ptr) == PNG_COLOR_TYPE_PALETTE) { -+ png_bytep trans_alpha; -+ int num_trans; -+ -+ if (png_get_tRNS(png_ptr, info_ptr, -+ &trans_alpha, &num_trans, NULL) & PNG_INFO_tRNS) { - bool foundGray; - unsigned int i; - - for (i = 0, foundGray = FALSE; -- i < info_ptr->num_trans && !foundGray; -+ i < num_trans && !foundGray; - ++i) { -- if (info_ptr->trans[i] != 0 && -- info_ptr->trans[i] != maxval) { -+ if (trans_alpha[i] != 0 && -+ trans_alpha[i] != maxval) { - foundGray = TRUE; - } - } -@@ -604,14 +643,16 @@ - - Return the result as *maxvalP. - -----------------------------------------------------------------------------*/ -+ png_color_8p sig_bit; -+ - /* Initial assumption of maxval */ -- if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) { -+ if (png_get_color_type(png_ptr, info_ptr) == PNG_COLOR_TYPE_PALETTE) { - if (alpha == ALPHA_ONLY) { -- if (info_ptr->color_type == PNG_COLOR_TYPE_GRAY || -- info_ptr->color_type == PNG_COLOR_TYPE_RGB) -+ if (png_get_color_type(png_ptr, info_ptr) == PNG_COLOR_TYPE_GRAY || -+ png_get_color_type(png_ptr, info_ptr) == PNG_COLOR_TYPE_RGB) - /* The alpha mask will be all opaque, so maxval 1 is plenty */ - *maxvalP = 1; -- else if (paletteHasPartialTransparency(info_ptr)) -+ else if (paletteHasPartialTransparency(png_ptr, info_ptr)) - /* Use same maxval as PNG transparency palette for simplicity*/ - *maxvalP = 255; - else -@@ -621,7 +662,7 @@ - /* Use same maxval as PNG palette for simplicity */ - *maxvalP = 255; - } else { -- *maxvalP = (1l << info_ptr->bit_depth) - 1; -+ *maxvalP = (1l << png_get_bit_depth(png_ptr, info_ptr)) - 1; - } - - /* sBIT handling is very tricky. If we are extracting only the -@@ -634,20 +675,26 @@ - is used - */ - -- if (info_ptr->valid & PNG_INFO_sBIT) { -+ if (png_get_sBIT(png_ptr, info_ptr, &sig_bit) & PNG_INFO_sBIT) { -+ png_byte color_type; -+ png_bytep trans_alpha; -+ int num_trans; -+ -+ color_type = png_get_color_type(png_ptr, info_ptr); - switch (alpha) { - case ALPHA_MIX: -- if (info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA || -- info_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) -+ if (color_type == PNG_COLOR_TYPE_RGB_ALPHA || -+ color_type == PNG_COLOR_TYPE_GRAY_ALPHA) - break; -- if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE && -- (info_ptr->valid & PNG_INFO_tRNS)) { -+ if (color_type == PNG_COLOR_TYPE_PALETTE && -+ png_get_tRNS(png_ptr, info_ptr, -+ &trans_alpha, &num_trans, NULL) & PNG_INFO_tRNS) { - - bool trans_mix; - unsigned int i; - trans_mix = TRUE; -- for (i = 0; i < info_ptr->num_trans; ++i) -- if (info_ptr->trans[i] != 0 && info_ptr->trans[i] != 255) { -+ for (i = 0; i < num_trans; ++i) -+ if (trans_alpha[i] != 0 && trans_alpha[i] != 255) { - trans_mix = FALSE; - break; - } -@@ -658,70 +705,76 @@ - /* else fall though to normal case */ - - case ALPHA_NONE: -- if ((info_ptr->color_type == PNG_COLOR_TYPE_PALETTE || -- info_ptr->color_type == PNG_COLOR_TYPE_RGB || -- info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA) && -- (info_ptr->sig_bit.red != info_ptr->sig_bit.green || -- info_ptr->sig_bit.red != info_ptr->sig_bit.blue) && -+ if ((color_type == PNG_COLOR_TYPE_PALETTE || -+ color_type == PNG_COLOR_TYPE_RGB || -+ color_type == PNG_COLOR_TYPE_RGB_ALPHA) && -+ (sig_bit->red != sig_bit->green || -+ sig_bit->red != sig_bit->blue) && - alpha == ALPHA_NONE) { - pm_message("This program cannot handle " - "different bit depths for color channels"); - pm_message("writing file with %d bit resolution", -- info_ptr->bit_depth); -+ png_get_bit_depth(png_ptr, info_ptr)); - *errorlevelP = PNMTOPNG_WARNING_LEVEL; - } else { -- if ((info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) && -- (info_ptr->sig_bit.red < 255)) { -+ png_colorp palette; -+ int num_palette; -+ -+ if ((color_type == PNG_COLOR_TYPE_PALETTE) && -+ (sig_bit->red < 255) && -+ png_get_PLTE(png_ptr, info_ptr, -+ &palette, &num_palette) & PNG_INFO_PLTE) { - unsigned int i; -- for (i = 0; i < info_ptr->num_palette; ++i) { -- info_ptr->palette[i].red >>= -- (8 - info_ptr->sig_bit.red); -- info_ptr->palette[i].green >>= -- (8 - info_ptr->sig_bit.green); -- info_ptr->palette[i].blue >>= -- (8 - info_ptr->sig_bit.blue); -+ -+ for (i = 0; i < num_palette; ++i) { -+ palette[i].red >>= -+ (8 - sig_bit->red); -+ palette[i].green >>= -+ (8 - sig_bit->green); -+ palette[i].blue >>= -+ (8 - sig_bit->blue); - } -- *maxvalP = (1l << info_ptr->sig_bit.red) - 1; -+ *maxvalP = (1l << sig_bit->red) - 1; - if (verbose) - pm_message ("image has fewer significant bits, " - "writing file with %d bits per channel", -- info_ptr->sig_bit.red); -+ sig_bit->red); - } else -- if ((info_ptr->color_type == PNG_COLOR_TYPE_RGB || -- info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA) && -- (info_ptr->sig_bit.red < info_ptr->bit_depth)) { -- png_set_shift (png_ptr, &(info_ptr->sig_bit)); -- *maxvalP = (1l << info_ptr->sig_bit.red) - 1; -+ if ((color_type == PNG_COLOR_TYPE_RGB || -+ color_type == PNG_COLOR_TYPE_RGB_ALPHA) && -+ (sig_bit->red < png_get_bit_depth(png_ptr, info_ptr))) { -+ png_set_shift (png_ptr, sig_bit); -+ *maxvalP = (1l << sig_bit->red) - 1; - if (verbose) - pm_message("image has fewer significant bits, " - "writing file with %d " - "bits per channel", -- info_ptr->sig_bit.red); -+ sig_bit->red); - } else -- if ((info_ptr->color_type == PNG_COLOR_TYPE_GRAY || -- info_ptr->color_type == -+ if ((color_type == PNG_COLOR_TYPE_GRAY || -+ color_type == - PNG_COLOR_TYPE_GRAY_ALPHA) && -- (info_ptr->sig_bit.gray < info_ptr->bit_depth)) { -- png_set_shift (png_ptr, &(info_ptr->sig_bit)); -- *maxvalP = (1l << info_ptr->sig_bit.gray) - 1; -+ (sig_bit->gray < png_get_bit_depth(png_ptr, info_ptr))) { -+ png_set_shift (png_ptr, sig_bit); -+ *maxvalP = (1l << sig_bit->gray) - 1; - if (verbose) - pm_message("image has fewer significant bits, " - "writing file with %d bits", -- info_ptr->sig_bit.gray); -+ sig_bit->gray); - } - } - break; - - case ALPHA_ONLY: -- if ((info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA || -- info_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) && -- (info_ptr->sig_bit.gray < info_ptr->bit_depth)) { -- png_set_shift (png_ptr, &(info_ptr->sig_bit)); -+ if ((color_type == PNG_COLOR_TYPE_RGB_ALPHA || -+ color_type == PNG_COLOR_TYPE_GRAY_ALPHA) && -+ (sig_bit->gray < png_get_bit_depth(png_ptr, info_ptr))) { -+ png_set_shift (png_ptr, sig_bit); - if (verbose) - pm_message ("image has fewer significant bits, " - "writing file with %d bits", -- info_ptr->sig_bit.alpha); -- *maxvalP = (1l << info_ptr->sig_bit.alpha) - 1; -+ sig_bit->alpha); -+ *maxvalP = (1l << sig_bit->alpha) - 1; - } - break; - -@@ -732,22 +785,28 @@ - - - static bool --imageHasColor(png_info * const info_ptr) { -+imageHasColor(png_structp const png_ptr, png_info * const info_ptr) { - - bool retval; -- -- if (info_ptr->color_type == PNG_COLOR_TYPE_GRAY || -- info_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) -+ png_byte color_type; -+ png_colorp palette; -+ int num_palette; -+ -+ color_type = png_get_color_type(png_ptr, info_ptr); -+ if (color_type == PNG_COLOR_TYPE_GRAY || -+ color_type == PNG_COLOR_TYPE_GRAY_ALPHA) - - retval = FALSE; -- else if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) { -+ else if (color_type == PNG_COLOR_TYPE_PALETTE && -+ png_get_PLTE(png_ptr, info_ptr, -+ &palette, &num_palette) & PNG_INFO_PLTE) { - bool foundColor; - unsigned int i; - - for (i = 0, foundColor = FALSE; -- i < info_ptr->num_palette && !foundColor; -+ i < num_palette && !foundColor; - ++i) { -- if (iscolor(info_ptr->palette[i])) -+ if (iscolor(palette[i])) - foundColor = TRUE; - } - retval = foundColor; -@@ -760,14 +819,15 @@ - - - static void --determineOutputType(png_info * const info_ptr, -+determineOutputType(png_structp const png_ptr, -+ png_info * const info_ptr, - enum alpha_handling const alphaHandling, - pngcolor const bgColor, - xelval const maxval, - int * const pnmTypeP) { - - if (alphaHandling != ALPHA_ONLY && -- (imageHasColor(info_ptr) || !isGrayscale(bgColor))) -+ (imageHasColor(png_ptr, info_ptr) || !isGrayscale(bgColor))) - *pnmTypeP = PPM_TYPE; - else { - if (maxval > 1) -@@ -780,7 +840,8 @@ - - - static void --getBackgroundColor(png_info * const info_ptr, -+getBackgroundColor(png_structp const png_ptr, -+ png_info * const info_ptr, - const char * const requestedColor, - float const totalgamma, - xelval const maxval, -@@ -791,6 +852,8 @@ - Otherwise, if the PNG specifies a background color, that's the one. - And otherwise, it's white. - -----------------------------------------------------------------------------*/ -+ png_color_16p background; -+ - if (requestedColor) { - /* Background was specified from the command-line; we always - use that. I chose to do no gamma-correction in this case; -@@ -802,27 +865,32 @@ - bgColorP->g = PPM_GETG(backcolor); - bgColorP->b = PPM_GETB(backcolor); - -- } else if (info_ptr->valid & PNG_INFO_bKGD) { -+ } else if (png_get_bKGD(png_ptr, info_ptr, &background) & PNG_INFO_bKGD) { - /* didn't manage to get libpng to work (bugs?) concerning background - processing, therefore we do our own. - */ -- switch (info_ptr->color_type) { -+ switch (png_get_color_type(png_ptr, info_ptr)) { - case PNG_COLOR_TYPE_GRAY: - case PNG_COLOR_TYPE_GRAY_ALPHA: - bgColorP->r = bgColorP->g = bgColorP->b = -- gamma_correct(info_ptr->background.gray, totalgamma); -+ gamma_correct(background->gray, totalgamma); - break; - case PNG_COLOR_TYPE_PALETTE: { -- png_color const rawBgcolor = -- info_ptr->palette[info_ptr->background.index]; -- bgColorP->r = gamma_correct(rawBgcolor.red, totalgamma); -- bgColorP->g = gamma_correct(rawBgcolor.green, totalgamma); -- bgColorP->b = gamma_correct(rawBgcolor.blue, totalgamma); -+ png_colorp palette; -+ int num_palette; -+ -+ if (png_get_PLTE(png_ptr, info_ptr, -+ &palette, &num_palette) & PNG_INFO_PLTE) { -+ png_color const rawBgcolor = palette[background->index]; -+ bgColorP->r = gamma_correct(rawBgcolor.red, totalgamma); -+ bgColorP->g = gamma_correct(rawBgcolor.green, totalgamma); -+ bgColorP->b = gamma_correct(rawBgcolor.blue, totalgamma); -+ } - } - break; - case PNG_COLOR_TYPE_RGB: - case PNG_COLOR_TYPE_RGB_ALPHA: { -- png_color_16 const rawBgcolor = info_ptr->background; -+ png_color_16 const rawBgcolor = *background; - - bgColorP->r = gamma_correct(rawBgcolor.red, totalgamma); - bgColorP->g = gamma_correct(rawBgcolor.green, totalgamma); -@@ -841,6 +909,7 @@ - writePnm(FILE * const ofP, - xelval const maxval, - int const pnm_type, -+ png_structp const png_ptr, - png_info * const info_ptr, - png_byte ** const png_image, - pngcolor const bgColor, -@@ -858,6 +927,7 @@ - -----------------------------------------------------------------------------*/ - xel * xelrow; - unsigned int row; -+ png_uint_32 width, height; - - if (verbose) - pm_message ("writing a %s file (maxval=%u)", -@@ -867,27 +937,35 @@ - "UNKNOWN!", - maxval); - -- xelrow = pnm_allocrow(info_ptr->width); -+ xelrow = pnm_allocrow(png_get_image_width(png_ptr, info_ptr)); - -- pnm_writepnminit(stdout, info_ptr->width, info_ptr->height, maxval, -- pnm_type, FALSE); -+ width = png_get_image_width(png_ptr, info_ptr); -+ height = png_get_image_height(png_ptr, info_ptr); - -- for (row = 0; row < info_ptr->height; ++row) { -+ pnm_writepnminit(stdout, width, height, maxval, pnm_type, FALSE); -+ -+ for (row = 0; row < height; ++row) { - png_byte * png_pixelP; - int col; - - png_pixelP = &png_image[row][0]; /* initial value */ -- for (col = 0; col < info_ptr->width; ++col) { -- switch (info_ptr->color_type) { -+ for (col = 0; col < width; ++col) { -+ switch (png_get_color_type(png_ptr, info_ptr)) { - case PNG_COLOR_TYPE_GRAY: { - pngcolor fgColor; -+ png_color_16p trans_color; -+ - fgColor.r = fgColor.g = fgColor.b = get_png_val(png_pixelP); -- setXel(&xelrow[col], fgColor, bgColor, alpha_handling, -- ((info_ptr->valid & PNG_INFO_tRNS) && -- (fgColor.r == -- gamma_correct(info_ptr->trans_values.gray, -- totalgamma))) ? -- 0 : maxval); -+ -+ if (png_get_tRNS(png_ptr, info_ptr, -+ NULL, NULL, &trans_color) & PNG_INFO_tRNS && -+ (fgColor.r == gamma_correct(trans_color->gray, -+ totalgamma))) { -+ setXel(&xelrow[col], fgColor, bgColor, alpha_handling, 0); -+ } else { -+ setXel(&xelrow[col], fgColor, bgColor, alpha_handling, -+ maxval); -+ } - } - break; - -@@ -902,19 +980,31 @@ - break; - - case PNG_COLOR_TYPE_PALETTE: { -- png_uint_16 const index = get_png_val(png_pixelP); -- png_color const paletteColor = info_ptr->palette[index]; -- -- pngcolor fgColor; -- -- fgColor.r = paletteColor.red; -- fgColor.g = paletteColor.green; -- fgColor.b = paletteColor.blue; -- -- setXel(&xelrow[col], fgColor, bgColor, alpha_handling, -- (info_ptr->valid & PNG_INFO_tRNS) && -- index < info_ptr->num_trans ? -- info_ptr->trans[index] : maxval); -+ png_uint_16 const index = get_png_val(png_pixelP); -+ png_colorp palette; -+ int num_palette; -+ -+ if (png_get_PLTE(png_ptr, info_ptr, -+ &palette, &num_palette) & PNG_INFO_PLTE) { -+ png_color const paletteColor = palette[index]; -+ pngcolor fgColor; -+ png_bytep trans_alpha; -+ int num_trans; -+ -+ fgColor.r = paletteColor.red; -+ fgColor.g = paletteColor.green; -+ fgColor.b = paletteColor.blue; -+ -+ if (png_get_tRNS(png_ptr, info_ptr, -+ &trans_alpha, -+ &num_trans, NULL) & PNG_INFO_tRNS) { -+ setXel(&xelrow[col], fgColor, bgColor, alpha_handling, -+ index < num_trans ? trans_alpha[index] : maxval); -+ } else { -+ setXel(&xelrow[col], fgColor, bgColor, alpha_handling, -+ maxval); -+ } -+ } - } - break; - -@@ -925,8 +1015,8 @@ - fgColor.g = get_png_val(png_pixelP); - fgColor.b = get_png_val(png_pixelP); - setXel(&xelrow[col], fgColor, bgColor, alpha_handling, -- isTransparentColor(fgColor, info_ptr, totalgamma) ? -- 0 : maxval); -+ isTransparentColor(fgColor, png_ptr, info_ptr, -+ totalgamma) ? 0 : maxval); - } - break; - -@@ -943,10 +1033,10 @@ - break; - - default: -- pm_error ("unknown PNG color type: %d", info_ptr->color_type); -+ pm_error ("unknown PNG color type: %d", png_get_color_type(png_ptr, info_ptr)); - } - } -- pnm_writepnmrow(ofP, xelrow, info_ptr->width, maxval, pnm_type, FALSE); -+ pnm_writepnmrow(ofP, xelrow, width, maxval, pnm_type, FALSE); - } - pnm_freerow (xelrow); - } -@@ -967,6 +1057,7 @@ - int pnm_type; - pngcolor bgColor; - float totalgamma; -+ int res_x, res_y, unit_type; - - *errorlevelP = 0; - -@@ -989,28 +1080,28 @@ - png_set_sig_bytes (png_ptr, SIG_CHECK_SIZE); - png_read_info (png_ptr, info_ptr); - -- MALLOCARRAY(png_image, info_ptr->height); -+ MALLOCARRAY(png_image, png_get_image_height(png_ptr, info_ptr)); - if (png_image == NULL) { - png_destroy_read_struct (&png_ptr, &info_ptr, (png_infopp)NULL); - pm_closer (ifp); - pm_error ("couldn't allocate space for image"); - } - -- if (info_ptr->bit_depth == 16) -- linesize = 2 * info_ptr->width; -+ if (png_get_bit_depth(png_ptr, info_ptr) == 16) -+ linesize = 2 * png_get_image_width(png_ptr, info_ptr); - else -- linesize = info_ptr->width; -+ linesize = png_get_image_width(png_ptr, info_ptr); - -- if (info_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) -+ if (png_get_color_type(png_ptr, info_ptr) == PNG_COLOR_TYPE_GRAY_ALPHA) - linesize *= 2; - else -- if (info_ptr->color_type == PNG_COLOR_TYPE_RGB) -+ if (png_get_color_type(png_ptr, info_ptr) == PNG_COLOR_TYPE_RGB) - linesize *= 3; - else -- if (info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA) -+ if (png_get_color_type(png_ptr, info_ptr) == PNG_COLOR_TYPE_RGB_ALPHA) - linesize *= 4; - -- for (y = 0 ; y < info_ptr->height ; y++) { -+ for (y = 0 ; y < png_get_image_height(png_ptr, info_ptr) ; y++) { - png_image[y] = malloc (linesize); - if (png_image[y] == NULL) { - for (x = 0 ; x < y ; x++) -@@ -1022,7 +1113,7 @@ - } - } - -- if (info_ptr->bit_depth < 8) -+ if (png_get_bit_depth(png_ptr, info_ptr) < 8) - png_set_packing (png_ptr); - - setupGammaCorrection(png_ptr, info_ptr, cmdline.gamma, &totalgamma); -@@ -1030,8 +1121,8 @@ - setupSignificantBits(png_ptr, info_ptr, cmdline.alpha, - &maxval, errorlevelP); - -- getBackgroundColor(info_ptr, cmdline.background, totalgamma, maxval, -- &bgColor); -+ getBackgroundColor(png_ptr, info_ptr, cmdline.background, totalgamma, -+ maxval, &bgColor); - - png_read_image (png_ptr, png_image); - png_read_end (png_ptr, info_ptr); -@@ -1041,16 +1132,17 @@ - completes. That's because it comes from chunks that are at the - end of the stream. - */ -- dump_png_info(info_ptr); -+ dump_png_info(png_ptr, info_ptr); - - if (mtime) -- show_time (info_ptr); -+ show_time (png_ptr, info_ptr); - if (tfp) -- save_text (info_ptr, tfp); -+ save_text (png_ptr, info_ptr, tfp); - -- if (info_ptr->valid & PNG_INFO_pHYs) { -+ if (png_get_pHYs(png_ptr, info_ptr, -+ &res_x, &res_y, &unit_type) & PNG_INFO_pHYs) { - float r; -- r = (float)info_ptr->x_pixels_per_unit / info_ptr->y_pixels_per_unit; -+ r = (float)res_x / res_y; - if (r != 1.0) { - pm_message ("warning - non-square pixels; " - "to fix do a 'pamscale -%cscale %g'", -@@ -1060,13 +1152,13 @@ - } - } - -- determineOutputType(info_ptr, cmdline.alpha, bgColor, maxval, &pnm_type); -+ determineOutputType(png_ptr, info_ptr, cmdline.alpha, bgColor, maxval, &pnm_type); - -- writePnm(stdout, maxval, pnm_type, info_ptr, png_image, bgColor, -+ writePnm(stdout, maxval, pnm_type, png_ptr, info_ptr, png_image, bgColor, - cmdline.alpha, totalgamma); - - fflush(stdout); -- for (y = 0 ; y < info_ptr->height ; y++) -+ for (y = 0 ; y < png_get_image_height(png_ptr, info_ptr) ; y++) - free (png_image[y]); - free (png_image); - png_destroy_read_struct (&png_ptr, &info_ptr, (png_infopp)NULL); diff --git a/graphics/netpbm/patches/patch-ah b/graphics/netpbm/patches/patch-ah deleted file mode 100644 index 41dbd34bf04..00000000000 --- a/graphics/netpbm/patches/patch-ah +++ /dev/null @@ -1,23 +0,0 @@ -$NetBSD: patch-ah,v 1.11 2010/07/13 06:08:23 adam Exp $ - ---- converter/other/cameratopam/camera.c.orig 2006-08-19 03:12:28.000000000 +0000 -+++ converter/other/cameratopam/camera.c -@@ -2,6 +2,7 @@ - /* Make sure strcasecmp is in string.h */ - #define _XOPEN_SOURCE - /* Make sure putenv is in stdlib.h */ -+#define __EXTENSIONS__ - - #include - #include -@@ -24,6 +25,10 @@ - - #include "camera.h" - -+#ifdef __sun -+#define setenv(x, y, z) putenv(x"="y) -+#endif -+ - #if HAVE_INT64 - typedef int64_t INT64; - static bool const have64BitArithmetic = true; diff --git a/graphics/netpbm/patches/patch-converter_other_pngtopnm.c b/graphics/netpbm/patches/patch-converter_other_pngtopnm.c new file mode 100644 index 00000000000..de8127fb2ce --- /dev/null +++ b/graphics/netpbm/patches/patch-converter_other_pngtopnm.c @@ -0,0 +1,898 @@ +$NetBSD: patch-converter_other_pngtopnm.c,v 1.1 2014/08/21 20:58:23 wiz Exp $ + +Fix build with png-1.5 and newer. + +--- converter/other/pngtopnm.c.orig 2011-11-25 00:15:46.000000000 +0000 ++++ converter/other/pngtopnm.c +@@ -44,12 +44,6 @@ + #include "nstring.h" + #include "shhopt.h" + +-#if PNG_LIBPNG_VER >= 10400 +-#error Your PNG library () is incompatible with this Netpbm source code. +-#error You need either an older PNG library (older than 1.4) +-#error newer Netpbm source code (at least 10.48) +-#endif +- + typedef struct _jmpbuf_wrapper { + jmp_buf jmpbuf; + } jmpbuf_wrapper; +@@ -187,7 +181,7 @@ parseCommandLine(int arg + + + +-#define get_png_val(p) _get_png_val (&(p), info_ptr->bit_depth) ++#define get_png_val(p) _get_png_val (&(p), png_get_bit_depth(png_ptr, info_ptr)) + + static png_uint_16 + _get_png_val (png_byte ** const pp, +@@ -266,33 +260,39 @@ png_color c; + } + + #ifdef __STDC__ +-static void save_text (png_info *info_ptr, FILE *tfp) ++static void save_text (png_structp png_ptr, png_info *info_ptr, FILE *tfp) + #else +-static void save_text (info_ptr, tfp) ++static void save_text (png_ptr, info_ptr, tfp) ++png_structp png_ptr; + png_info *info_ptr; + FILE *tfp; + #endif + { + int i, j, k; ++ png_textp text_ptr; ++ int num_text; ++ ++ if (png_get_text(png_ptr, info_ptr, &text_ptr, &num_text) == 0) ++ return; + +- for (i = 0 ; i < info_ptr->num_text ; i++) { ++ for (i = 0 ; i < num_text ; i++) { + j = 0; +- while (info_ptr->text[i].key[j] != '\0' && info_ptr->text[i].key[j] != ' ') ++ while (text_ptr[i].key[j] != '\0' && text_ptr[i].key[j] != ' ') + j++; +- if (info_ptr->text[i].key[j] != ' ') { +- fprintf (tfp, "%s", info_ptr->text[i].key); +- for (j = strlen (info_ptr->text[i].key) ; j < 15 ; j++) ++ if (text_ptr[i].key[j] != ' ') { ++ fprintf (tfp, "%s", text_ptr[i].key); ++ for (j = strlen (text_ptr[i].key) ; j < 15 ; j++) + putc (' ', tfp); + } else { +- fprintf (tfp, "\"%s\"", info_ptr->text[i].key); +- for (j = strlen (info_ptr->text[i].key) ; j < 13 ; j++) ++ fprintf (tfp, "\"%s\"", text_ptr[i].key); ++ for (j = strlen (text_ptr[i].key) ; j < 13 ; j++) + putc (' ', tfp); + } + putc (' ', tfp); /* at least one space between key and text */ + +- for (j = 0 ; j < info_ptr->text[i].text_length ; j++) { +- putc (info_ptr->text[i].text[j], tfp); +- if (info_ptr->text[i].text[j] == '\n') ++ for (j = 0 ; j < text_ptr[i].text_length ; j++) { ++ putc (text_ptr[i].text[j], tfp); ++ if (text_ptr[i].text[j] == '\n') + for (k = 0 ; k < 16 ; k++) + putc ((int)' ', tfp); + } +@@ -301,9 +301,10 @@ FILE *tfp; + } + + #ifdef __STDC__ +-static void show_time (png_info *info_ptr) ++static void show_time (png_structp png_ptr, png_info *info_ptr) + #else +-static void show_time (info_ptr) ++static void show_time (png_ptr, info_ptr) ++png_structp png_ptr; + png_info *info_ptr; + #endif + { +@@ -311,19 +312,20 @@ png_info *info_ptr; + "", "January", "February", "March", "April", "May", "June", + "July", "August", "September", "October", "November", "December" + }; ++ png_timep mod_time; + +- if (info_ptr->valid & PNG_INFO_tIME) { +- if (info_ptr->mod_time.month < 1 || +- info_ptr->mod_time.month >= ARRAY_SIZE(month)) { ++ if (png_get_tIME(png_ptr, info_ptr, &mod_time) & PNG_INFO_tIME) { ++ if (mod_time->month < 1 || ++ mod_time->month >= ARRAY_SIZE(month)) { + pm_message("tIME chunk in PNG input is invalid; " + "modification time of image is unknown. " + "The month value, which should be in the range " +- "1-12, is %u", info_ptr->mod_time.month); ++ "1-12, is %u", mod_time->month); + } else + pm_message ("modification time: %02d %s %d %02d:%02d:%02d", +- info_ptr->mod_time.day, month[info_ptr->mod_time.month], +- info_ptr->mod_time.year, info_ptr->mod_time.hour, +- info_ptr->mod_time.minute, info_ptr->mod_time.second); ++ mod_time->day, month[mod_time->month], ++ mod_time->year, mod_time->hour, ++ mod_time->minute, mod_time->second); + } + } + +@@ -360,12 +362,28 @@ png_const_charp msg; + + + static void +-dump_png_info(png_info *info_ptr) { ++dump_png_info(png_structp png_ptr, png_info *info_ptr) { + + const char *type_string; + const char *filter_string; ++ png_color_16p background; ++ int num_trans; ++ double gamma; ++ png_color_8p sig_bit; ++ png_colorp palette; ++ int num_palette; ++ png_uint_16p hist; ++ int res_x, res_y, unit_type; ++ png_int_32 offset_x, offset_y; ++ png_timep mod_time; ++ png_charp purpose; ++ png_int_32 X0, X1; ++ int type, nparams; ++ png_charp units; ++ png_charpp params; ++ int file_srgb_intent; + +- switch (info_ptr->color_type) { ++ switch (png_get_color_type(png_ptr, info_ptr)) { + case PNG_COLOR_TYPE_GRAY: + type_string = "gray"; + break; +@@ -387,90 +405,101 @@ dump_png_info(png_info *info_ptr) { + break; + } + +- switch (info_ptr->filter_type) { ++ switch (png_get_filter_type(png_ptr, info_ptr)) { + case PNG_FILTER_TYPE_BASE: + asprintfN(&filter_string, "base filter"); + break; + default: + asprintfN(&filter_string, "unknown filter type %d", +- info_ptr->filter_type); ++ png_get_filter_type(png_ptr, info_ptr)); + } + +- pm_message("reading a %ldw x %ldh image, %d bit%s", +- info_ptr->width, info_ptr->height, +- info_ptr->bit_depth, info_ptr->bit_depth > 1 ? "s" : ""); ++ pm_message("reading a %uw x %uh image, %d bit%s", ++ png_get_image_width(png_ptr, info_ptr), ++ png_get_image_height(png_ptr, info_ptr), ++ png_get_bit_depth(png_ptr, info_ptr), ++ png_get_bit_depth(png_ptr, info_ptr) > 1 ? "s" : ""); + pm_message("%s, %s, %s", + type_string, +- info_ptr->interlace_type ? ++ png_get_interlace_type(png_ptr, info_ptr) ? + "Adam7 interlaced" : "not interlaced", + filter_string); +- pm_message("background {index, gray, red, green, blue} = " +- "{%d, %d, %d, %d, %d}", +- info_ptr->background.index, +- info_ptr->background.gray, +- info_ptr->background.red, +- info_ptr->background.green, +- info_ptr->background.blue); ++ ++ if (png_get_bKGD(png_ptr, info_ptr, &background) & PNG_INFO_bKGD) { ++ pm_message("background {index, gray, red, green, blue} = " ++ "{%d, %d, %d, %d, %d}", ++ background->index, ++ background->gray, ++ background->red, ++ background->green, ++ background->blue); ++ } + + strfree(filter_string); + +- if (info_ptr->valid & PNG_INFO_tRNS) ++ if (png_get_tRNS(png_ptr, info_ptr, ++ NULL, &num_trans, NULL) & PNG_INFO_tRNS) + pm_message("tRNS chunk (transparency): %u entries", +- info_ptr->num_trans); ++ num_trans); + else + pm_message("tRNS chunk (transparency): not present"); + +- if (info_ptr->valid & PNG_INFO_gAMA) +- pm_message("gAMA chunk (image gamma): gamma = %4.2f", info_ptr->gamma); ++ if (png_get_gAMA(png_ptr, info_ptr, &gamma) & PNG_INFO_gAMA) ++ pm_message("gAMA chunk (image gamma): gamma = %4.2f", gamma); + else + pm_message("gAMA chunk (image gamma): not present"); + +- if (info_ptr->valid & PNG_INFO_sBIT) ++ if (png_get_sBIT(png_ptr, info_ptr, &sig_bit) & PNG_INFO_sBIT) + pm_message("sBIT chunk: present"); + else + pm_message("sBIT chunk: not present"); + +- if (info_ptr->valid & PNG_INFO_cHRM) ++ if (png_get_cHRM(png_ptr, info_ptr, ++ NULL, NULL, NULL, NULL, ++ NULL, NULL, NULL, NULL) & PNG_INFO_cHRM) + pm_message("cHRM chunk: present"); + else + pm_message("cHRM chunk: not present"); + +- if (info_ptr->valid & PNG_INFO_PLTE) +- pm_message("PLTE chunk: %d entries", info_ptr->num_palette); ++ if (png_get_PLTE(png_ptr, info_ptr, &palette, &num_palette) & PNG_INFO_PLTE) ++ pm_message("PLTE chunk: %d entries", num_palette); + else + pm_message("PLTE chunk: not present"); + +- if (info_ptr->valid & PNG_INFO_bKGD) ++ if (png_get_bKGD(png_ptr, info_ptr, &background) & PNG_INFO_bKGD) + pm_message("bKGD chunk: present"); + else + pm_message("bKGD chunk: not present"); + +- if (info_ptr->valid & PNG_INFO_hIST) ++ if (png_get_hIST(png_ptr, info_ptr, &hist) & PNG_INFO_hIST) + pm_message("hIST chunk: present"); + else + pm_message("hIST chunk: not present"); + +- if (info_ptr->valid & PNG_INFO_pHYs) ++ if (png_get_pHYs(png_ptr, info_ptr, ++ &res_x, &res_y, &unit_type) & PNG_INFO_pHYs) + pm_message("pHYs chunk: present"); + else + pm_message("pHYs chunk: not present"); + +- if (info_ptr->valid & PNG_INFO_oFFs) ++ if (png_get_oFFs(png_ptr, info_ptr, ++ &offset_x, &offset_y, &unit_type) & PNG_INFO_oFFs) + pm_message("oFFs chunk: present"); + else + pm_message("oFFs chunk: not present"); + +- if (info_ptr->valid & PNG_INFO_tIME) ++ if (png_get_tIME(png_ptr, info_ptr, &mod_time) & PNG_INFO_tIME) + pm_message("tIME chunk: present"); + else + pm_message("tIME chunk: not present"); + +- if (info_ptr->valid & PNG_INFO_pCAL) ++ if (png_get_pCAL(png_ptr, info_ptr, &purpose, &X0, &X1, ++ &type, &nparams, &units, ¶ms) & PNG_INFO_pCAL) + pm_message("pCAL chunk: present"); + else + pm_message("pCAL chunk: not present"); + +- if (info_ptr->valid & PNG_INFO_sRGB) ++ if (png_get_sRGB(png_ptr, info_ptr, &file_srgb_intent) & PNG_INFO_sRGB) + pm_message("sRGB chunk: present"); + else + pm_message("sRGB chunk: not present"); +@@ -479,19 +508,19 @@ dump_png_info(png_info *info_ptr) { + + + static bool +-isTransparentColor(pngcolor const color, +- png_info * const info_ptr, +- double const totalgamma) { ++isTransparentColor(pngcolor const color, ++ png_structp const png_ptr, ++ png_info * const info_ptr, ++ double const totalgamma) { + /*---------------------------------------------------------------------------- + Return TRUE iff pixels of color 'color' are supposed to be transparent + everywhere they occur. Assume it's an RGB image. + -----------------------------------------------------------------------------*/ + bool retval; ++ png_color_16p transColorP; + +- if (info_ptr->valid & PNG_INFO_tRNS) { +- const png_color_16 * const transColorP = &info_ptr->trans_values; +- +- ++ if (png_get_tRNS(png_ptr, info_ptr, ++ NULL, NULL, &transColorP) & PNG_INFO_tRNS) { + /* There seems to be a problem here: you can't compare real + numbers for equality. Also, I'm not sure the gamma + corrected/uncorrected color spaces are right here. +@@ -537,9 +566,11 @@ setupGammaCorrection(png_struct * const + if (displaygamma == -1.0) + *totalgammaP = -1.0; + else { ++ double fileGamma; + float imageGamma; +- if (info_ptr->valid & PNG_INFO_gAMA) +- imageGamma = info_ptr->gamma; ++ ++ if (png_get_gAMA(png_ptr, info_ptr, &fileGamma) & PNG_INFO_gAMA) ++ imageGamma = fileGamma; + else { + if (verbose) + pm_message("PNG doesn't specify image gamma. Assuming 1.0"); +@@ -555,10 +586,14 @@ setupGammaCorrection(png_struct * const + } else { + png_set_gamma(png_ptr, displaygamma, imageGamma); + *totalgammaP = imageGamma * displaygamma; ++#ifdef NOT_SUPPORTED_ANYMORE ++ /* The API doesn't clearing PNG_INFO_sBIT. */ ++ + /* in case of gamma-corrections, sBIT's as in the + PNG-file are not valid anymore + */ + info_ptr->valid &= ~PNG_INFO_sBIT; ++#endif + if (verbose) + pm_message("image gamma is %4.2f, " + "converted for display gamma of %4.2f", +@@ -570,20 +605,24 @@ setupGammaCorrection(png_struct * const + + + static bool +-paletteHasPartialTransparency(png_info * const info_ptr) { ++paletteHasPartialTransparency(png_structp png_ptr, png_info * const info_ptr) { + + bool retval; + +- if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) { +- if (info_ptr->valid & PNG_INFO_tRNS) { ++ if (png_get_color_type(png_ptr, info_ptr) == PNG_COLOR_TYPE_PALETTE) { ++ png_bytep trans_alpha; ++ int num_trans; ++ ++ if (png_get_tRNS(png_ptr, info_ptr, ++ &trans_alpha, &num_trans, NULL) & PNG_INFO_tRNS) { + bool foundGray; + unsigned int i; + + for (i = 0, foundGray = FALSE; +- i < info_ptr->num_trans && !foundGray; ++ i < num_trans && !foundGray; + ++i) { +- if (info_ptr->trans[i] != 0 && +- info_ptr->trans[i] != maxval) { ++ if (trans_alpha[i] != 0 && ++ trans_alpha[i] != maxval) { + foundGray = TRUE; + } + } +@@ -611,14 +650,16 @@ setupSignificantBits(png_struct * + + Return the result as *maxvalP. + -----------------------------------------------------------------------------*/ ++ png_color_8p sig_bit; ++ + /* Initial assumption of maxval */ +- if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) { ++ if (png_get_color_type(png_ptr, info_ptr) == PNG_COLOR_TYPE_PALETTE) { + if (alpha == ALPHA_ONLY) { +- if (info_ptr->color_type == PNG_COLOR_TYPE_GRAY || +- info_ptr->color_type == PNG_COLOR_TYPE_RGB) ++ if (png_get_color_type(png_ptr, info_ptr) == PNG_COLOR_TYPE_GRAY || ++ png_get_color_type(png_ptr, info_ptr) == PNG_COLOR_TYPE_RGB) + /* The alpha mask will be all opaque, so maxval 1 is plenty */ + *maxvalP = 1; +- else if (paletteHasPartialTransparency(info_ptr)) ++ else if (paletteHasPartialTransparency(png_ptr, info_ptr)) + /* Use same maxval as PNG transparency palette for simplicity*/ + *maxvalP = 255; + else +@@ -628,7 +669,7 @@ setupSignificantBits(png_struct * + /* Use same maxval as PNG palette for simplicity */ + *maxvalP = 255; + } else { +- *maxvalP = (1l << info_ptr->bit_depth) - 1; ++ *maxvalP = (1l << png_get_bit_depth(png_ptr, info_ptr)) - 1; + } + + /* sBIT handling is very tricky. If we are extracting only the +@@ -641,20 +682,26 @@ setupSignificantBits(png_struct * + is used + */ + +- if (info_ptr->valid & PNG_INFO_sBIT) { ++ if (png_get_sBIT(png_ptr, info_ptr, &sig_bit) & PNG_INFO_sBIT) { ++ png_byte color_type; ++ png_bytep trans_alpha; ++ int num_trans; ++ ++ color_type = png_get_color_type(png_ptr, info_ptr); + switch (alpha) { + case ALPHA_MIX: +- if (info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA || +- info_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) ++ if (color_type == PNG_COLOR_TYPE_RGB_ALPHA || ++ color_type == PNG_COLOR_TYPE_GRAY_ALPHA) + break; +- if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE && +- (info_ptr->valid & PNG_INFO_tRNS)) { ++ if (color_type == PNG_COLOR_TYPE_PALETTE && ++ png_get_tRNS(png_ptr, info_ptr, ++ &trans_alpha, &num_trans, NULL) & PNG_INFO_tRNS) { + + bool trans_mix; + unsigned int i; + trans_mix = TRUE; +- for (i = 0; i < info_ptr->num_trans; ++i) +- if (info_ptr->trans[i] != 0 && info_ptr->trans[i] != 255) { ++ for (i = 0; i < num_trans; ++i) ++ if (trans_alpha[i] != 0 && trans_alpha[i] != 255) { + trans_mix = FALSE; + break; + } +@@ -665,70 +712,76 @@ setupSignificantBits(png_struct * + /* else fall though to normal case */ + + case ALPHA_NONE: +- if ((info_ptr->color_type == PNG_COLOR_TYPE_PALETTE || +- info_ptr->color_type == PNG_COLOR_TYPE_RGB || +- info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA) && +- (info_ptr->sig_bit.red != info_ptr->sig_bit.green || +- info_ptr->sig_bit.red != info_ptr->sig_bit.blue) && ++ if ((color_type == PNG_COLOR_TYPE_PALETTE || ++ color_type == PNG_COLOR_TYPE_RGB || ++ color_type == PNG_COLOR_TYPE_RGB_ALPHA) && ++ (sig_bit->red != sig_bit->green || ++ sig_bit->red != sig_bit->blue) && + alpha == ALPHA_NONE) { + pm_message("This program cannot handle " + "different bit depths for color channels"); + pm_message("writing file with %d bit resolution", +- info_ptr->bit_depth); ++ png_get_bit_depth(png_ptr, info_ptr)); + *errorlevelP = PNMTOPNG_WARNING_LEVEL; + } else { +- if ((info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) && +- (info_ptr->sig_bit.red < 255)) { ++ png_colorp palette; ++ int num_palette; ++ ++ if ((color_type == PNG_COLOR_TYPE_PALETTE) && ++ (sig_bit->red < 255) && ++ png_get_PLTE(png_ptr, info_ptr, ++ &palette, &num_palette) & PNG_INFO_PLTE) { + unsigned int i; +- for (i = 0; i < info_ptr->num_palette; ++i) { +- info_ptr->palette[i].red >>= +- (8 - info_ptr->sig_bit.red); +- info_ptr->palette[i].green >>= +- (8 - info_ptr->sig_bit.green); +- info_ptr->palette[i].blue >>= +- (8 - info_ptr->sig_bit.blue); ++ ++ for (i = 0; i < num_palette; ++i) { ++ palette[i].red >>= ++ (8 - sig_bit->red); ++ palette[i].green >>= ++ (8 - sig_bit->green); ++ palette[i].blue >>= ++ (8 - sig_bit->blue); + } +- *maxvalP = (1l << info_ptr->sig_bit.red) - 1; ++ *maxvalP = (1l << sig_bit->red) - 1; + if (verbose) + pm_message ("image has fewer significant bits, " + "writing file with %d bits per channel", +- info_ptr->sig_bit.red); ++ sig_bit->red); + } else +- if ((info_ptr->color_type == PNG_COLOR_TYPE_RGB || +- info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA) && +- (info_ptr->sig_bit.red < info_ptr->bit_depth)) { +- png_set_shift (png_ptr, &(info_ptr->sig_bit)); +- *maxvalP = (1l << info_ptr->sig_bit.red) - 1; ++ if ((color_type == PNG_COLOR_TYPE_RGB || ++ color_type == PNG_COLOR_TYPE_RGB_ALPHA) && ++ (sig_bit->red < png_get_bit_depth(png_ptr, info_ptr))) { ++ png_set_shift (png_ptr, sig_bit); ++ *maxvalP = (1l << sig_bit->red) - 1; + if (verbose) + pm_message("image has fewer significant bits, " + "writing file with %d " + "bits per channel", +- info_ptr->sig_bit.red); ++ sig_bit->red); + } else +- if ((info_ptr->color_type == PNG_COLOR_TYPE_GRAY || +- info_ptr->color_type == ++ if ((color_type == PNG_COLOR_TYPE_GRAY || ++ color_type == + PNG_COLOR_TYPE_GRAY_ALPHA) && +- (info_ptr->sig_bit.gray < info_ptr->bit_depth)) { +- png_set_shift (png_ptr, &(info_ptr->sig_bit)); +- *maxvalP = (1l << info_ptr->sig_bit.gray) - 1; ++ (sig_bit->gray < png_get_bit_depth(png_ptr, info_ptr))) { ++ png_set_shift (png_ptr, sig_bit); ++ *maxvalP = (1l << sig_bit->gray) - 1; + if (verbose) + pm_message("image has fewer significant bits, " + "writing file with %d bits", +- info_ptr->sig_bit.gray); ++ sig_bit->gray); + } + } + break; + + case ALPHA_ONLY: +- if ((info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA || +- info_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) && +- (info_ptr->sig_bit.gray < info_ptr->bit_depth)) { +- png_set_shift (png_ptr, &(info_ptr->sig_bit)); ++ if ((color_type == PNG_COLOR_TYPE_RGB_ALPHA || ++ color_type == PNG_COLOR_TYPE_GRAY_ALPHA) && ++ (sig_bit->gray < png_get_bit_depth(png_ptr, info_ptr))) { ++ png_set_shift (png_ptr, sig_bit); + if (verbose) + pm_message ("image has fewer significant bits, " + "writing file with %d bits", +- info_ptr->sig_bit.alpha); +- *maxvalP = (1l << info_ptr->sig_bit.alpha) - 1; ++ sig_bit->alpha); ++ *maxvalP = (1l << sig_bit->alpha) - 1; + } + break; + +@@ -739,22 +792,28 @@ setupSignificantBits(png_struct * + + + static bool +-imageHasColor(png_info * const info_ptr) { ++imageHasColor(png_structp const png_ptr, png_info * const info_ptr) { + + bool retval; +- +- if (info_ptr->color_type == PNG_COLOR_TYPE_GRAY || +- info_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) ++ png_byte color_type; ++ png_colorp palette; ++ int num_palette; ++ ++ color_type = png_get_color_type(png_ptr, info_ptr); ++ if (color_type == PNG_COLOR_TYPE_GRAY || ++ color_type == PNG_COLOR_TYPE_GRAY_ALPHA) + + retval = FALSE; +- else if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) { ++ else if (color_type == PNG_COLOR_TYPE_PALETTE && ++ png_get_PLTE(png_ptr, info_ptr, ++ &palette, &num_palette) & PNG_INFO_PLTE) { + bool foundColor; + unsigned int i; + + for (i = 0, foundColor = FALSE; +- i < info_ptr->num_palette && !foundColor; ++ i < num_palette && !foundColor; + ++i) { +- if (iscolor(info_ptr->palette[i])) ++ if (iscolor(palette[i])) + foundColor = TRUE; + } + retval = foundColor; +@@ -767,14 +826,15 @@ imageHasColor(png_info * const info_ptr) + + + static void +-determineOutputType(png_info * const info_ptr, ++determineOutputType(png_structp const png_ptr, ++ png_info * const info_ptr, + enum alpha_handling const alphaHandling, + pngcolor const bgColor, + xelval const maxval, + int * const pnmTypeP) { + + if (alphaHandling != ALPHA_ONLY && +- (imageHasColor(info_ptr) || !isGrayscale(bgColor))) ++ (imageHasColor(png_ptr, info_ptr) || !isGrayscale(bgColor))) + *pnmTypeP = PPM_TYPE; + else { + if (maxval > 1) +@@ -787,7 +847,8 @@ determineOutputType(png_info * + + + static void +-getBackgroundColor(png_info * const info_ptr, ++getBackgroundColor(png_structp const png_ptr, ++ png_info * const info_ptr, + const char * const requestedColor, + float const totalgamma, + xelval const maxval, +@@ -798,6 +859,8 @@ getBackgroundColor(png_info * con + Otherwise, if the PNG specifies a background color, that's the one. + And otherwise, it's white. + -----------------------------------------------------------------------------*/ ++ png_color_16p background; ++ + if (requestedColor) { + /* Background was specified from the command-line; we always + use that. I chose to do no gamma-correction in this case; +@@ -809,27 +872,32 @@ getBackgroundColor(png_info * con + bgColorP->g = PPM_GETG(backcolor); + bgColorP->b = PPM_GETB(backcolor); + +- } else if (info_ptr->valid & PNG_INFO_bKGD) { ++ } else if (png_get_bKGD(png_ptr, info_ptr, &background) & PNG_INFO_bKGD) { + /* didn't manage to get libpng to work (bugs?) concerning background + processing, therefore we do our own. + */ +- switch (info_ptr->color_type) { ++ switch (png_get_color_type(png_ptr, info_ptr)) { + case PNG_COLOR_TYPE_GRAY: + case PNG_COLOR_TYPE_GRAY_ALPHA: + bgColorP->r = bgColorP->g = bgColorP->b = +- gamma_correct(info_ptr->background.gray, totalgamma); ++ gamma_correct(background->gray, totalgamma); + break; + case PNG_COLOR_TYPE_PALETTE: { +- png_color const rawBgcolor = +- info_ptr->palette[info_ptr->background.index]; +- bgColorP->r = gamma_correct(rawBgcolor.red, totalgamma); +- bgColorP->g = gamma_correct(rawBgcolor.green, totalgamma); +- bgColorP->b = gamma_correct(rawBgcolor.blue, totalgamma); ++ png_colorp palette; ++ int num_palette; ++ ++ if (png_get_PLTE(png_ptr, info_ptr, ++ &palette, &num_palette) & PNG_INFO_PLTE) { ++ png_color const rawBgcolor = palette[background->index]; ++ bgColorP->r = gamma_correct(rawBgcolor.red, totalgamma); ++ bgColorP->g = gamma_correct(rawBgcolor.green, totalgamma); ++ bgColorP->b = gamma_correct(rawBgcolor.blue, totalgamma); ++ } + } + break; + case PNG_COLOR_TYPE_RGB: + case PNG_COLOR_TYPE_RGB_ALPHA: { +- png_color_16 const rawBgcolor = info_ptr->background; ++ png_color_16 const rawBgcolor = *background; + + bgColorP->r = gamma_correct(rawBgcolor.red, totalgamma); + bgColorP->g = gamma_correct(rawBgcolor.green, totalgamma); +@@ -848,6 +916,7 @@ static void + writePnm(FILE * const ofP, + xelval const maxval, + int const pnm_type, ++ png_structp const png_ptr, + png_info * const info_ptr, + png_byte ** const png_image, + pngcolor const bgColor, +@@ -865,6 +934,7 @@ writePnm(FILE * const ofP, + -----------------------------------------------------------------------------*/ + xel * xelrow; + unsigned int row; ++ png_uint_32 width, height; + + if (verbose) + pm_message ("writing a %s file (maxval=%u)", +@@ -874,27 +944,35 @@ writePnm(FILE * const ofP, + "UNKNOWN!", + maxval); + +- xelrow = pnm_allocrow(info_ptr->width); ++ xelrow = pnm_allocrow(png_get_image_width(png_ptr, info_ptr)); + +- pnm_writepnminit(stdout, info_ptr->width, info_ptr->height, maxval, +- pnm_type, FALSE); ++ width = png_get_image_width(png_ptr, info_ptr); ++ height = png_get_image_height(png_ptr, info_ptr); + +- for (row = 0; row < info_ptr->height; ++row) { ++ pnm_writepnminit(stdout, width, height, maxval, pnm_type, FALSE); ++ ++ for (row = 0; row < height; ++row) { + png_byte * png_pixelP; + int col; + + png_pixelP = &png_image[row][0]; /* initial value */ +- for (col = 0; col < info_ptr->width; ++col) { +- switch (info_ptr->color_type) { ++ for (col = 0; col < width; ++col) { ++ switch (png_get_color_type(png_ptr, info_ptr)) { + case PNG_COLOR_TYPE_GRAY: { + pngcolor fgColor; ++ png_color_16p trans_color; ++ + fgColor.r = fgColor.g = fgColor.b = get_png_val(png_pixelP); +- setXel(&xelrow[col], fgColor, bgColor, alpha_handling, +- ((info_ptr->valid & PNG_INFO_tRNS) && +- (fgColor.r == +- gamma_correct(info_ptr->trans_values.gray, +- totalgamma))) ? +- 0 : maxval); ++ ++ if (png_get_tRNS(png_ptr, info_ptr, ++ NULL, NULL, &trans_color) & PNG_INFO_tRNS && ++ (fgColor.r == gamma_correct(trans_color->gray, ++ totalgamma))) { ++ setXel(&xelrow[col], fgColor, bgColor, alpha_handling, 0); ++ } else { ++ setXel(&xelrow[col], fgColor, bgColor, alpha_handling, ++ maxval); ++ } + } + break; + +@@ -909,19 +987,31 @@ writePnm(FILE * const ofP, + break; + + case PNG_COLOR_TYPE_PALETTE: { +- png_uint_16 const index = get_png_val(png_pixelP); +- png_color const paletteColor = info_ptr->palette[index]; +- +- pngcolor fgColor; +- +- fgColor.r = paletteColor.red; +- fgColor.g = paletteColor.green; +- fgColor.b = paletteColor.blue; +- +- setXel(&xelrow[col], fgColor, bgColor, alpha_handling, +- (info_ptr->valid & PNG_INFO_tRNS) && +- index < info_ptr->num_trans ? +- info_ptr->trans[index] : maxval); ++ png_uint_16 const index = get_png_val(png_pixelP); ++ png_colorp palette; ++ int num_palette; ++ ++ if (png_get_PLTE(png_ptr, info_ptr, ++ &palette, &num_palette) & PNG_INFO_PLTE) { ++ png_color const paletteColor = palette[index]; ++ pngcolor fgColor; ++ png_bytep trans_alpha; ++ int num_trans; ++ ++ fgColor.r = paletteColor.red; ++ fgColor.g = paletteColor.green; ++ fgColor.b = paletteColor.blue; ++ ++ if (png_get_tRNS(png_ptr, info_ptr, ++ &trans_alpha, ++ &num_trans, NULL) & PNG_INFO_tRNS) { ++ setXel(&xelrow[col], fgColor, bgColor, alpha_handling, ++ index < num_trans ? trans_alpha[index] : maxval); ++ } else { ++ setXel(&xelrow[col], fgColor, bgColor, alpha_handling, ++ maxval); ++ } ++ } + } + break; + +@@ -932,8 +1022,8 @@ writePnm(FILE * const ofP, + fgColor.g = get_png_val(png_pixelP); + fgColor.b = get_png_val(png_pixelP); + setXel(&xelrow[col], fgColor, bgColor, alpha_handling, +- isTransparentColor(fgColor, info_ptr, totalgamma) ? +- 0 : maxval); ++ isTransparentColor(fgColor, png_ptr, info_ptr, ++ totalgamma) ? 0 : maxval); + } + break; + +@@ -950,10 +1040,10 @@ writePnm(FILE * const ofP, + break; + + default: +- pm_error ("unknown PNG color type: %d", info_ptr->color_type); ++ pm_error ("unknown PNG color type: %d", png_get_color_type(png_ptr, info_ptr)); + } + } +- pnm_writepnmrow(ofP, xelrow, info_ptr->width, maxval, pnm_type, FALSE); ++ pnm_writepnmrow(ofP, xelrow, width, maxval, pnm_type, FALSE); + } + pnm_freerow (xelrow); + } +@@ -974,6 +1064,7 @@ convertpng(FILE * const ifp, + int pnm_type; + pngcolor bgColor; + float totalgamma; ++ int res_x, res_y, unit_type; + + *errorlevelP = 0; + +@@ -996,28 +1087,28 @@ convertpng(FILE * const ifp, + png_set_sig_bytes (png_ptr, SIG_CHECK_SIZE); + png_read_info (png_ptr, info_ptr); + +- MALLOCARRAY(png_image, info_ptr->height); ++ MALLOCARRAY(png_image, png_get_image_height(png_ptr, info_ptr)); + if (png_image == NULL) { + png_destroy_read_struct (&png_ptr, &info_ptr, (png_infopp)NULL); + pm_closer (ifp); + pm_error ("couldn't allocate space for image"); + } + +- if (info_ptr->bit_depth == 16) +- linesize = 2 * info_ptr->width; ++ if (png_get_bit_depth(png_ptr, info_ptr) == 16) ++ linesize = 2 * png_get_image_width(png_ptr, info_ptr); + else +- linesize = info_ptr->width; ++ linesize = png_get_image_width(png_ptr, info_ptr); + +- if (info_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) ++ if (png_get_color_type(png_ptr, info_ptr) == PNG_COLOR_TYPE_GRAY_ALPHA) + linesize *= 2; + else +- if (info_ptr->color_type == PNG_COLOR_TYPE_RGB) ++ if (png_get_color_type(png_ptr, info_ptr) == PNG_COLOR_TYPE_RGB) + linesize *= 3; + else +- if (info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA) ++ if (png_get_color_type(png_ptr, info_ptr) == PNG_COLOR_TYPE_RGB_ALPHA) + linesize *= 4; + +- for (y = 0 ; y < info_ptr->height ; y++) { ++ for (y = 0 ; y < png_get_image_height(png_ptr, info_ptr) ; y++) { + png_image[y] = malloc (linesize); + if (png_image[y] == NULL) { + for (x = 0 ; x < y ; x++) +@@ -1029,7 +1120,7 @@ convertpng(FILE * const ifp, + } + } + +- if (info_ptr->bit_depth < 8) ++ if (png_get_bit_depth(png_ptr, info_ptr) < 8) + png_set_packing (png_ptr); + + setupGammaCorrection(png_ptr, info_ptr, cmdline.gamma, &totalgamma); +@@ -1037,8 +1128,8 @@ convertpng(FILE * const ifp, + setupSignificantBits(png_ptr, info_ptr, cmdline.alpha, + &maxval, errorlevelP); + +- getBackgroundColor(info_ptr, cmdline.background, totalgamma, maxval, +- &bgColor); ++ getBackgroundColor(png_ptr, info_ptr, cmdline.background, totalgamma, ++ maxval, &bgColor); + + png_read_image (png_ptr, png_image); + png_read_end (png_ptr, info_ptr); +@@ -1048,16 +1139,17 @@ convertpng(FILE * const ifp, + completes. That's because it comes from chunks that are at the + end of the stream. + */ +- dump_png_info(info_ptr); ++ dump_png_info(png_ptr, info_ptr); + + if (mtime) +- show_time (info_ptr); ++ show_time (png_ptr, info_ptr); + if (tfp) +- save_text (info_ptr, tfp); ++ save_text (png_ptr, info_ptr, tfp); + +- if (info_ptr->valid & PNG_INFO_pHYs) { ++ if (png_get_pHYs(png_ptr, info_ptr, ++ &res_x, &res_y, &unit_type) & PNG_INFO_pHYs) { + float r; +- r = (float)info_ptr->x_pixels_per_unit / info_ptr->y_pixels_per_unit; ++ r = (float)res_x / res_y; + if (r != 1.0) { + pm_message ("warning - non-square pixels; " + "to fix do a 'pamscale -%cscale %g'", +@@ -1067,13 +1159,13 @@ convertpng(FILE * const ifp, + } + } + +- determineOutputType(info_ptr, cmdline.alpha, bgColor, maxval, &pnm_type); ++ determineOutputType(png_ptr, info_ptr, cmdline.alpha, bgColor, maxval, &pnm_type); + +- writePnm(stdout, maxval, pnm_type, info_ptr, png_image, bgColor, ++ writePnm(stdout, maxval, pnm_type, png_ptr, info_ptr, png_image, bgColor, + cmdline.alpha, totalgamma); + + fflush(stdout); +- for (y = 0 ; y < info_ptr->height ; y++) ++ for (y = 0 ; y < png_get_image_height(png_ptr, info_ptr) ; y++) + free (png_image[y]); + free (png_image); + png_destroy_read_struct (&png_ptr, &info_ptr, (png_infopp)NULL); diff --git a/graphics/netpbm/patches/patch-dc b/graphics/netpbm/patches/patch-dc index a45a1cb99c9..82b4ec41fbd 100644 --- a/graphics/netpbm/patches/patch-dc +++ b/graphics/netpbm/patches/patch-dc @@ -1,7 +1,7 @@ -$NetBSD: patch-dc,v 1.1 2006/11/03 07:45:19 rillig Exp $ +$NetBSD: patch-dc,v 1.2 2014/08/21 20:58:23 wiz Exp $ ---- converter/other/cameratopam/camera.c.orig Tue Oct 31 09:49:45 2006 -+++ converter/other/cameratopam/camera.c Tue Oct 31 10:55:38 2006 +--- converter/other/cameratopam/camera.c.orig 2006-08-19 03:12:28.000000000 +0000 ++++ converter/other/cameratopam/camera.c @@ -1,7 +1,11 @@ #define _BSD_SOURCE /* Make sure strcasecmp is in string.h */ @@ -11,6 +11,6 @@ $NetBSD: patch-dc,v 1.1 2006/11/03 07:45:19 rillig Exp $ #define _XOPEN_SOURCE /* Make sure putenv is in stdlib.h */ +#endif /* __osf__ */ - #define __EXTENSIONS__ #include + #include diff --git a/graphics/netpbm/patches/patch-eb b/graphics/netpbm/patches/patch-eb deleted file mode 100644 index 0cdb2fe278f..00000000000 --- a/graphics/netpbm/patches/patch-eb +++ /dev/null @@ -1,147 +0,0 @@ -$NetBSD: patch-eb,v 1.2 2010/07/13 06:08:23 adam Exp $ - ---- converter/ppm/xpmtoppm.c.orig 2009-12-29 20:46:34.000000000 +0000 -+++ converter/ppm/xpmtoppm.c -@@ -121,7 +121,7 @@ static bool backup; - - - static void --getline(char * const line, -+get_line(char * const line, - size_t const size, - FILE * const stream) { - /*---------------------------------------------------------------------------- -@@ -139,7 +139,7 @@ getline(char * const line, - Exit program if the line doesn't fit in the buffer. - -----------------------------------------------------------------------------*/ - if (size > sizeof(lastInputLine)) -- pm_error("INTERNAL ERROR: getline() received 'size' parameter " -+ pm_error("INTERNAL ERROR: get_line() received 'size' parameter " - "which is out of bounds"); - - if (backup) { -@@ -355,7 +355,7 @@ readXpm3Header(FILE * const stream, int - int * const transparentP) { - /*---------------------------------------------------------------------------- - Read the header of the XPM file on stream 'stream'. Assume the -- getline() stream is presently positioned to the beginning of the -+ get_line() stream is presently positioned to the beginning of the - file and it is a Version 3 XPM file. Leave the stream positioned - after the header. - -@@ -386,25 +386,25 @@ readXpm3Header(FILE * const stream, int - *widthP = *heightP = *ncolorsP = *chars_per_pixelP = -1; - - /* Read the XPM signature comment */ -- getline(line, sizeof(line), stream); -+ get_line(line, sizeof(line), stream); - if (strncmp(line, xpm3_signature, strlen(xpm3_signature)) != 0) - pm_error("Apparent XPM 3 file does not start with '/* XPM */'. " - "First line is '%s'", xpm3_signature); - - /* Read the assignment line */ -- getline(line, sizeof(line), stream); -+ get_line(line, sizeof(line), stream); - if (strncmp(line, "static char", 11) != 0) - pm_error("Cannot find data structure declaration. Expected a " - "line starting with 'static char', but found the line " - "'%s'.", line); - - /* Read the hints line */ -- getline(line, sizeof(line), stream); -+ get_line(line, sizeof(line), stream); - /* skip the comment line if any */ - if (!strncmp(line, "/*", 2)) { - while (!strstr(line, "*/")) -- getline(line, sizeof(line), stream); -- getline(line, sizeof(line), stream); -+ get_line(line, sizeof(line), stream); -+ get_line(line, sizeof(line), stream); - } - if (sscanf(line, "\"%d %d %d %d\",", widthP, heightP, - ncolorsP, chars_per_pixelP) != 4) -@@ -438,10 +438,10 @@ readXpm3Header(FILE * const stream, int - *transparentP = -1; /* initial value */ - - for (seqNum = 0; seqNum < *ncolorsP; seqNum++) { -- getline(line, sizeof(line), stream); -+ get_line(line, sizeof(line), stream); - /* skip the comment line if any */ - if (!strncmp(line, "/*", 2)) -- getline(line, sizeof(line), stream); -+ get_line(line, sizeof(line), stream); - - interpretXpm3ColorTableLine(line, seqNum, *chars_per_pixelP, - *colorsP, *ptabP, transparentP); -@@ -456,7 +456,7 @@ readXpm1Header(FILE * const stream, int - pixel ** const colorsP, int ** const ptabP) { - /*---------------------------------------------------------------------------- - Read the header of the XPM file on stream 'stream'. Assume the -- getline() stream is presently positioned to the beginning of the -+ get_line() stream is presently positioned to the beginning of the - file and it is a Version 1 XPM file. Leave the stream positioned - after the header. - -@@ -476,7 +476,7 @@ readXpm1Header(FILE * const stream, int - /* Read the initial defines. */ - processedStaticChar = FALSE; - while (!processedStaticChar) { -- getline(line, sizeof(line), stream); -+ get_line(line, sizeof(line), stream); - - if (sscanf(line, "#define %s %d", str1, &v) == 2) { - char *t1; -@@ -524,7 +524,7 @@ readXpm1Header(FILE * const stream, int - /* If there's a monochrome color table, skip it. */ - if (!strncmp(t1, "mono", 4)) { - for (;;) { -- getline(line, sizeof(line), stream); -+ get_line(line, sizeof(line), stream); - if (!strncmp(line, "static char", 11)) - break; - } -@@ -547,7 +547,7 @@ readXpm1Header(FILE * const stream, int - - /* Read color table. */ - for (i = 0; i < *ncolorsP; ++i) { -- getline(line, sizeof(line), stream); -+ get_line(line, sizeof(line), stream); - - if ((t1 = strchr(line, '"')) == NULL) - pm_error("D error scanning color table"); -@@ -583,7 +583,7 @@ readXpm1Header(FILE * const stream, int - "static char ..."). - */ - for (;;) { -- getline(line, sizeof(line), stream); -+ get_line(line, sizeof(line), stream); - if (strncmp(line, "static char", 11) == 0) - break; - } -@@ -687,7 +687,7 @@ ReadXPMFile(FILE * const stream, int * c - backup = FALSE; - - /* Read the header line */ -- getline(line, sizeof(line), stream); -+ get_line(line, sizeof(line), stream); - backup = TRUE; /* back up so next read reads this line again */ - - rc = sscanf(line, "/* %s */", str1); -@@ -707,7 +707,7 @@ ReadXPMFile(FILE * const stream, int * c - pm_error("Could not get %d bytes of memory for image", totalpixels); - cursor = *dataP; - maxcursor = *dataP + totalpixels - 1; -- getline(line, sizeof(line), stream); -+ get_line(line, sizeof(line), stream); - /* read next line (first line may not always start with comment) */ - while (cursor <= maxcursor) { - if (strncmp(line, "/*", 2) == 0) { -@@ -717,7 +717,7 @@ ReadXPMFile(FILE * const stream, int * c - ncolors, ptab, &cursor, maxcursor); - } - if (cursor <= maxcursor) -- getline(line, sizeof(line), stream); -+ get_line(line, sizeof(line), stream); - } - if (ptab) free(ptab); - } -- cgit v1.2.3