diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2009-08-01 19:25:09 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2009-08-01 19:25:09 +0000 |
commit | ea971e9981f61f7cc0da856e818f090306c3607d (patch) | |
tree | 60b00062f6481971538eded821d661c830c016b9 /converter | |
parent | b66ba744249860527aeeca746addc7738e3f81ea (diff) | |
download | netpbm-mirror-ea971e9981f61f7cc0da856e818f090306c3607d.tar.gz netpbm-mirror-ea971e9981f61f7cc0da856e818f090306c3607d.tar.xz netpbm-mirror-ea971e9981f61f7cc0da856e818f090306c3607d.zip |
Don't refer to trans_values, which isn't in newer libpng
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@962 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'converter')
-rw-r--r-- | converter/other/pngtopnm.c | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/converter/other/pngtopnm.c b/converter/other/pngtopnm.c index 3bbc942f..47e26437 100644 --- a/converter/other/pngtopnm.c +++ b/converter/other/pngtopnm.c @@ -1,6 +1,6 @@ /* ** pngtopnm.c - -** read a Portable Network Graphics file and produce a portable anymap +** read a Portable Network Graphics file and produce a PNM. ** ** Copyright (C) 1995,1998 by Alexander Lehmann <alex@hal.rhein-main.de> ** and Willem van Schaik <willem@schaik.com> @@ -222,6 +222,15 @@ pngx_destroy(struct pngx * const pngxP) { +static bool +pngx_chunkIsPresent(struct pngx * const pngxP, + uint32_t const chunkType) { + + return png_get_valid(pngxP->png_ptr, pngxP->info_ptr, chunkType); +} + + + static void verifyFileIsPng(FILE * const ifP, size_t * const consumedByteCtP) { @@ -598,6 +607,23 @@ dumpPngInfo(struct pngx * const pngxP) { +static const png_color_16 * +transColor(struct pngx * const pngxP) { + + png_bytep trans; + int numTrans; + png_color_16 * transColor; + + assert(chunkIsPresent(PNG_INFO_tRNS)); + + png_get_tRNS(pngxP->png_ptr, pngxP->info_ptr, + &trans, &numTrans, &transColor); + + return transColor; +} + + + static bool isTransparentColor(pngcolor const color, struct pngx * const pngxP, @@ -610,9 +636,8 @@ isTransparentColor(pngcolor const color, -----------------------------------------------------------------------------*/ bool retval; - if (pngxP->info_ptr->valid & PNG_INFO_tRNS) { - const png_color_16 * const transColorP = - &pngxP->info_ptr->trans_values; + if (pngx_chunkIsPresent(PNG_INFO_tRNS)) { + const png_color_16 * const transColorP = transColor(pngxP); /* It seems odd that libpng lets you get gamma-corrected pixel values, but not gamma-corrected transparency or background |