diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2011-09-25 18:51:44 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2011-09-25 18:51:44 +0000 |
commit | 7923b359409c0a156ccaaa0789dbe949959f695f (patch) | |
tree | 4a02299d9bba9eb5933409ffef61837c99032e4e /converter | |
parent | 2c56eee205115a1bae88c6598dea64d867dd28b5 (diff) | |
download | netpbm-mirror-7923b359409c0a156ccaaa0789dbe949959f695f.tar.gz netpbm-mirror-7923b359409c0a156ccaaa0789dbe949959f695f.tar.xz netpbm-mirror-7923b359409c0a156ccaaa0789dbe949959f695f.zip |
Release 10.35.82
git-svn-id: http://svn.code.sf.net/p/netpbm/code/super_stable@1575 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'converter')
-rw-r--r-- | converter/other/pnmtopng.c | 67 | ||||
-rw-r--r-- | converter/other/pnmtops.c | 2 |
2 files changed, 44 insertions, 25 deletions
diff --git a/converter/other/pnmtopng.c b/converter/other/pnmtopng.c index 065f5195..92c38a2a 100644 --- a/converter/other/pnmtopng.c +++ b/converter/other/pnmtopng.c @@ -959,17 +959,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 @@ -990,19 +990,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)); - for (row = 0 ; row < rows && !foundTransparentPixel ; ++row) { - int col; - pnm_readpnmrow(ifp, xelrow, cols, maxval, format); + foundTransparentPixel = false; /* initial assumption */ + pm_seek2(ifP, &rasterPos, sizeof(rasterPos)); + for (row = 0; row < rows && !foundTransparentPixel; ++row) { + unsigned int col; + pnm_readpnmrow(ifP, xelrow, cols, maxval, format); for (col = 0; col < cols && !foundTransparentPixel; ++col) { if (alphaMask[row][col] == 0) { foundTransparentPixel = TRUE; @@ -1010,20 +1029,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/converter/other/pnmtops.c b/converter/other/pnmtops.c index eb9cbf6f..d2280557 100644 --- a/converter/other/pnmtops.c +++ b/converter/other/pnmtops.c @@ -645,7 +645,7 @@ computeImagePosition(int const dpiX, if (verbose) pm_message("Image will be %3.2f points wide by %3.2f points high, " "left edge %3.2f points from left edge of page, " - "bottom edge %3.2f points from top of page; " + "bottom edge %3.2f points from bottom of page; " "%sturned to landscape orientation", *scolsP, *srowsP, *llxP, *llyP, *turnedP ? "" : "NOT "); } |