diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2007-07-31 02:11:27 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2007-07-31 02:11:27 +0000 |
commit | fa6d051ef01d06c7f15f12a7498f8e4991005c49 (patch) | |
tree | 7ea926f1fe6391cb5fc8e9b97f47b3cf9dd84e58 /converter | |
parent | fa0872c4482b20c963bd9c1793d117940de2ea8e (diff) | |
download | netpbm-mirror-fa6d051ef01d06c7f15f12a7498f8e4991005c49.tar.gz netpbm-mirror-fa6d051ef01d06c7f15f12a7498f8e4991005c49.tar.xz netpbm-mirror-fa6d051ef01d06c7f15f12a7498f8e4991005c49.zip |
Do 12 bits per sample if user says -psfilter
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@369 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'converter')
-rw-r--r-- | converter/other/pnmtops.c | 61 |
1 files changed, 39 insertions, 22 deletions
diff --git a/converter/other/pnmtops.c b/converter/other/pnmtops.c index 5c86a2ab..0348a870 100644 --- a/converter/other/pnmtops.c +++ b/converter/other/pnmtops.c @@ -955,8 +955,32 @@ putEnd(bool const showpage, static void +warnUserAboutReducedDepth(unsigned int const bitsGot, + unsigned int const bitsWanted, + unsigned int const postscriptLevel, + bool const psFilter) { + + if (bitsGot < bitsWanted) { + pm_message("Postscript will have %u bits of color resolution, " + "though the input has %u bits.", + bitsGot, bitsWanted); + + if (postscriptLevel < 2) + pm_message("Postscript level %u has a maximum depth of 8 bits. " + "You could get up to 12 with -level=2 and -psfilter.", + postscriptLevel); + + if (postscriptLevel >= 2 && !psFilter) + pm_message("You can get up to 12 bits with -psfilter"); + } +} + + + +static void computeDepth(xelval const inputMaxval, unsigned int const postscriptLevel, + bool const psFilter, unsigned int * const bitspersampleP, unsigned int * const psMaxvalP) { /*---------------------------------------------------------------------------- @@ -972,30 +996,22 @@ computeDepth(xelval const inputMaxval, *bitspersampleP = 2; else if (bitsRequiredByMaxval <= 4) *bitspersampleP = 4; - else - *bitspersampleP = 8; - - /* There is supposedly a 12 bits per pixel Postscript format, but - what? We produce a raster that is composed of bytes, each - coded as a pair of hexadecimal characters and representing 8, - 4, 2, or 1 pixels. We also have the RLE format, where some of - those bytes are run lengths. - */ - - if (*bitspersampleP < bitsRequiredByMaxval) { - if (bitsRequiredByMaxval <= 12 && postscriptLevel >= 2) - pm_message("Maxval of input requires %u bit samples for full " - "resolution, and Postscript level %u is capable " - "of representing that many, but this program " - "doesn't know how. So we are using %u", - bitsRequiredByMaxval, postscriptLevel, *bitspersampleP); + else { + /* Post script level 2 defines a format with 12 bits per sample, + but I don't know the details of that format (both RLE and + non-RLE variations) and existing native raster generation code + simply can't handle bps > 8. But the built-in filters know + how to do 12 bps. + */ + if (postscriptLevel >= 2 && psFilter) + *bitspersampleP = 12; else - pm_message("Maxval of input requires %u bit samples for full " - "resolution, but we are using the Postscript level %u " - "maximum of %u", - bitsRequiredByMaxval, postscriptLevel, *bitspersampleP); + *bitspersampleP = 8; } + warnUserAboutReducedDepth(*bitspersampleP, bitsRequiredByMaxval, + postscriptLevel, psFilter); + *psMaxvalP = pm_bitstomaxval(*bitspersampleP); if (verbose) @@ -1183,7 +1199,8 @@ convertPage(FILE * const ifP, if (color) pm_message("generating color Postscript program."); - computeDepth(inpam.maxval, postscriptLevel, &bitspersample, &psMaxval); + computeDepth(inpam.maxval, postscriptLevel, psFilter, + &bitspersample, &psMaxval); { unsigned int const realBitsPerLine = inpam.width * bitspersample; unsigned int const paddedBitsPerLine = ((realBitsPerLine + 7) / 8) * 8; |