diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2007-09-26 20:20:52 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2007-09-26 20:20:52 +0000 |
commit | 2087fc45bd38ac1dd3b90789c5bfb94f2dbbad94 (patch) | |
tree | b062862164ab41e78b5efc436330db65cb2887f9 /lib/libpbm2.c | |
parent | 68256547a054109f09c55e2e913df2dfdd2144ff (diff) | |
download | netpbm-mirror-2087fc45bd38ac1dd3b90789c5bfb94f2dbbad94.tar.gz netpbm-mirror-2087fc45bd38ac1dd3b90789c5bfb94f2dbbad94.tar.xz netpbm-mirror-2087fc45bd38ac1dd3b90789c5bfb94f2dbbad94.zip |
Rebase 'advanced' to 10.40.00
git-svn-id: http://svn.code.sf.net/p/netpbm/code/advanced@416 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'lib/libpbm2.c')
-rw-r--r-- | lib/libpbm2.c | 50 |
1 files changed, 34 insertions, 16 deletions
diff --git a/lib/libpbm2.c b/lib/libpbm2.c index d04328ef..19ca93b3 100644 --- a/lib/libpbm2.c +++ b/lib/libpbm2.c @@ -13,6 +13,7 @@ #include "pbm.h" #include "libpbm.h" #include "fileio.h" +#include "pam.h" static bit getbit (FILE * const file) { @@ -54,25 +55,42 @@ pbm_readpbminitrest( file, colsP, rowsP ) pm_error("Number of columns in header is too large."); } -void -pbm_readpbminit( file, colsP, rowsP, formatP ) - FILE* file; - int* colsP; - int* rowsP; - int* formatP; - { - /* Check magic number. */ - *formatP = pm_readmagicnumber( file ); - switch ( PBM_FORMAT_TYPE(*formatP) ) - { - case PBM_TYPE: - pbm_readpbminitrest( file, colsP, rowsP ); - break; + +void +pbm_readpbminit(FILE * const ifP, + int * const colsP, + int * const rowsP, + int * const formatP) { + + *formatP = pm_readmagicnumber(ifP); + + switch (PAM_FORMAT_TYPE(*formatP)) { + case PBM_TYPE: + pbm_readpbminitrest(ifP, colsP, rowsP); + break; + + case PGM_TYPE: + pm_error("The input file is a PGM, not a PBM. You may want to " + "convert it to PBM with 'pamditherbw | pamtopnm' or " + "'pamthreshold | pamtopnm'"); + + case PPM_TYPE: + pm_error("The input file is a PPM, not a PBM. You may want to " + "convert it to PBM with 'ppmtopgm', 'pamditherbw', and " + "'pamtopnm'"); + + case PAM_TYPE: + pm_error("The input file is a PAM, not a PBM. " + "If it is a black and white image, you can convert it " + "to PBM with 'pamtopnm'"); + break; default: - pm_error( "bad magic number - not a pbm file" ); - } + pm_error("bad magic number - not a Netpbm file"); } +} + + void pbm_readpbmrow( file, bitrow, cols, format ) |