diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2011-08-22 19:17:00 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2011-08-22 19:17:00 +0000 |
commit | 05df19be4b055631d4129adf87c795ec980f571e (patch) | |
tree | 5bc23f1e872063a6dd72e6041013757f588801fd | |
parent | 158664a8d07df34cb1a17825afebdc57dc569a12 (diff) | |
download | netpbm-mirror-05df19be4b055631d4129adf87c795ec980f571e.tar.gz netpbm-mirror-05df19be4b055631d4129adf87c795ec980f571e.tar.xz netpbm-mirror-05df19be4b055631d4129adf87c795ec980f571e.zip |
Release 10.47.30
git-svn-id: http://svn.code.sf.net/p/netpbm/code/stable@1552 9d0c8265-081b-0410-96cb-a4ca84ce46f8
-rw-r--r-- | converter/other/pnmtopng.c | 65 | ||||
-rw-r--r-- | doc/HISTORY | 8 | ||||
-rw-r--r-- | editor/pamcomp.c | 2 | ||||
-rwxr-xr-x | editor/pnmquant | 4 | ||||
-rw-r--r-- | version.mk | 2 |
5 files changed, 54 insertions, 27 deletions
diff --git a/converter/other/pnmtopng.c b/converter/other/pnmtopng.c index 42c8f4ad..ee4be331 100644 --- a/converter/other/pnmtopng.c +++ b/converter/other/pnmtopng.c @@ -961,17 +961,17 @@ tryTransparentColor(FILE * const ifp, static void -analyzeAlpha(FILE * const ifp, - pm_filepos const rasterPos, - int const cols, - int const rows, - xelval const maxval, - int const format, - gray ** const alphaMask, - gray const alphaMaxval, - bool * const allOpaqueP, - bool * const singleColorIsTransP, - pixel * const alphaTranscolorP) { +analyzeAlpha(FILE * const ifP, + pm_filepos const rasterPos, + unsigned int const cols, + unsigned int const rows, + xelval const maxval, + int const format, + gray ** const alphaMask, + gray const alphaMaxval, + bool * const allOpaqueP, + bool * const singleColorIsTransP, + pixel * const alphaTranscolorP) { /*---------------------------------------------------------------------------- Get information about the alpha mask, in combination with the masked image, that Caller can use to choose the most efficient way to @@ -992,19 +992,38 @@ analyzeAlpha(FILE * const ifp, */ pixel transcolor; /* Color of the transparent pixel mentioned above. */ + bool foundNonOpaquePixel; + /* We found a pixel in the image where the alpha mask says it is + not fully opaque. + */ xelrow = pnm_allocrow(cols); { - int row; + unsigned int row; + /* See if the mask says every pixel is opaque. */ + foundNonOpaquePixel = false; /* initial assumption */ + pm_seek2(ifP, &rasterPos, sizeof(rasterPos)); + for (row = 0; row < rows && !foundNonOpaquePixel; ++row) { + unsigned int col; + pnm_readpnmrow(ifP, xelrow, cols, maxval, format); + for (col = 0; col < cols && !foundNonOpaquePixel; ++col) { + if (alphaMask[row][col] != maxval) + foundNonOpaquePixel = true; + } + } + } + + if (foundNonOpaquePixel) { + unsigned int row; /* Find a candidate transparent color -- the color of any pixel in the image that the alpha mask says should be transparent. */ - foundTransparentPixel = FALSE; /* initial assumption */ - pm_seek2(ifp, &rasterPos, sizeof(rasterPos)); + foundTransparentPixel = false; /* initial assumption */ + pm_seek2(ifP, &rasterPos, sizeof(rasterPos)); for (row = 0; row < rows && !foundTransparentPixel; ++row) { - int col; - pnm_readpnmrow(ifp, xelrow, cols, maxval, format); + unsigned int col; + pnm_readpnmrow(ifP, xelrow, cols, maxval, format); for (col = 0; col < cols && !foundTransparentPixel; ++col) { if (alphaMask[row][col] == 0) { foundTransparentPixel = TRUE; @@ -1012,20 +1031,20 @@ analyzeAlpha(FILE * const ifp, } } } - } + } else + foundTransparentPixel = false; pnm_freerow(xelrow); + *allOpaqueP = !foundNonOpaquePixel; + if (foundTransparentPixel) { - *allOpaqueP = FALSE; - tryTransparentColor(ifp, rasterPos, cols, rows, maxval, format, + tryTransparentColor(ifP, rasterPos, cols, rows, maxval, format, alphaMask, alphaMaxval, transcolor, singleColorIsTransP); *alphaTranscolorP = transcolor; - } else { - *allOpaqueP = TRUE; - *singleColorIsTransP = FALSE; - } + } else + *singleColorIsTransP = false; } diff --git a/doc/HISTORY b/doc/HISTORY index b75becaf..d4b012ed 100644 --- a/doc/HISTORY +++ b/doc/HISTORY @@ -4,6 +4,14 @@ Netpbm. CHANGE HISTORY -------------- +11.08.22 BJH Release 10.47.30 + + 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. + 11.07.10 BJH Release 10.47.29 pgmtexture: fix wrong sum variance result. Wrong since the diff --git a/editor/pamcomp.c b/editor/pamcomp.c index e27b8613..e89509cc 100644 --- a/editor/pamcomp.c +++ b/editor/pamcomp.c @@ -638,7 +638,7 @@ main(int argc, const char *argv[]) { PAM_STRUCT_SIZE(allocation_depth)); if (overlayPam.width != alphaPam.width || - overlayPam.height != overlayPam.height) + overlayPam.height != alphaPam.height) pm_error("Opacity map and overlay image are not the same size"); } else alphaFileP = NULL; diff --git a/editor/pnmquant b/editor/pnmquant index 175f6906..5edbe85e 100755 --- a/editor/pnmquant +++ b/editor/pnmquant @@ -149,7 +149,7 @@ sub openSeekableAsStdin($) { tell(INFH); # Avoids bogus "INFH is not referenced" warning } } else { - open(STDIN, "<", $infile) + open(STDIN, "<$infile") or die("Unable to open input file '$infile'. Errno=$ERRNO"); } } @@ -194,7 +194,7 @@ sub makeColormap($$$$$) { push(@options, '-quiet'); } - open(STDOUT, ">", $mapfileSpec); + open(STDOUT, ">$mapfileSpec"); my $maprc = system("pnmcolormap", $ncolors, @options); diff --git a/version.mk b/version.mk index f82f3c9a..cb5ddf26 100644 --- a/version.mk +++ b/version.mk @@ -1,3 +1,3 @@ NETPBM_MAJOR_RELEASE = 10 NETPBM_MINOR_RELEASE = 47 -NETPBM_POINT_RELEASE = 29 +NETPBM_POINT_RELEASE = 30 |