diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2014-11-22 18:41:45 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2014-11-22 18:41:45 +0000 |
commit | f3316d36985ad16f1d82aea44eddc311cb739d6d (patch) | |
tree | 82f3a6c450ec8394baa9b588962d4497e7a704a4 /converter/pgm | |
parent | 09bcfca6b8a98a40a1895ae8a66dd3fc1344a966 (diff) | |
download | netpbm-mirror-f3316d36985ad16f1d82aea44eddc311cb739d6d.tar.gz netpbm-mirror-f3316d36985ad16f1d82aea44eddc311cb739d6d.tar.xz netpbm-mirror-f3316d36985ad16f1d82aea44eddc311cb739d6d.zip |
Fix %g for platform without vasprintf (but scores of %f still exist)
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@2320 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'converter/pgm')
-rw-r--r-- | converter/pgm/fstopgm.c | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/converter/pgm/fstopgm.c b/converter/pgm/fstopgm.c index 8a9ed721..1f574604 100644 --- a/converter/pgm/fstopgm.c +++ b/converter/pgm/fstopgm.c @@ -42,6 +42,29 @@ gethexit(FILE * const ifP) { +static void +warnNonsquarePixels(unsigned int const cols, + unsigned int const xcols, + unsigned int const rows, + unsigned int const xrows) { + + const char * const baseMsg = "warning, non-square pixels"; + + if (pm_have_float_format()) { + float const rowratio = (float) xrows / (float) rows; + float const colratio = (float) xcols / (float) cols; + + pm_message("%s; to fix do a 'pamscale -%cscale %g'", + baseMsg, + rowratio > colratio ? 'y' : 'x', + rowratio > colratio ? + rowratio / colratio : colratio / rowratio); + } else + pm_message("%s", baseMsg); +} + + + int main(int argc, const char ** argv) { @@ -110,15 +133,8 @@ main(int argc, const char ** argv) { if (maxval > PGM_OVERALLMAXVAL) pm_error("depth %d is too large. Our maximum is %d", maxval, PGM_OVERALLMAXVAL); - if (xcols != 0 && xrows != 0 && (xcols != cols || xrows != rows)) { - float const rowratio = (float) xrows / (float) rows; - float const colratio = (float) xcols / (float) cols; - - pm_message( - "warning, non-square pixels; to fix do a 'pamscale -%cscale %g'", - rowratio > colratio ? 'y' : 'x', - rowratio > colratio ? rowratio / colratio : colratio / rowratio ); - } + if (xcols != 0 && xrows != 0 && (xcols != cols || xrows != rows)) + warnNonsquarePixels(cols, xcols, rows, xrows); /* Read the hex bits. */ grays = pgm_allocarray(cols, rows); |