diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2007-09-09 17:59:48 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2007-09-09 17:59:48 +0000 |
commit | bb90be5f15cee8dcf80962ab482b7f07707332cd (patch) | |
tree | 73a81a85bf885353b5be48d2289963a2b13f26ba /lib/libpbm2.c | |
parent | cc4dde06897248afb92f5c037d40a5f239554ffb (diff) | |
download | netpbm-mirror-bb90be5f15cee8dcf80962ab482b7f07707332cd.tar.gz netpbm-mirror-bb90be5f15cee8dcf80962ab482b7f07707332cd.tar.xz netpbm-mirror-bb90be5f15cee8dcf80962ab482b7f07707332cd.zip |
Make pbm_readpbminit() and pgm_readpgminit() recognize other Netpbm formats and issue special error message
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@410 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 ) |