diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2010-03-04 03:37:13 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2010-03-04 03:37:13 +0000 |
commit | 847cfc7c5d1fa7f4c3a8715da220b4cac06f2621 (patch) | |
tree | 978c8b168c7dc635f87878abee606c7892cbe4fe /converter | |
parent | e5a9a6ded31a543be41f83c764a151dd2243f3e8 (diff) | |
download | netpbm-mirror-847cfc7c5d1fa7f4c3a8715da220b4cac06f2621.tar.gz netpbm-mirror-847cfc7c5d1fa7f4c3a8715da220b4cac06f2621.tar.xz netpbm-mirror-847cfc7c5d1fa7f4c3a8715da220b4cac06f2621.zip |
cleanup
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@1141 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'converter')
-rw-r--r-- | converter/pbm/ybmtopbm.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/converter/pbm/ybmtopbm.c b/converter/pbm/ybmtopbm.c index 5ef29501..98e520f3 100644 --- a/converter/pbm/ybmtopbm.c +++ b/converter/pbm/ybmtopbm.c @@ -19,7 +19,7 @@ static short const ybmMagic = ( ( '!' << 8 ) | '!' ); static int item; -static int bitsperitem, bitshift; +static int bitsInBuffer, bitshift; @@ -50,7 +50,6 @@ getinit(FILE * const ifP, *depthP = 1; *padrightP = ((*colsP + 15) / 16) * 16 - *colsP; - bitsperitem = 0; } @@ -60,16 +59,18 @@ getbit(FILE * const ifP) { bit b; - if (bitsperitem == 0) { + if (bitsInBuffer == 0) { item = getc(ifP) | getc(ifP) << 8; + if (item == EOF) pm_error("EOF / read error"); - bitsperitem = 16; + + bitsInBuffer = 16; bitshift = 0; } b = ((item >> bitshift) & 1 ) ? PBM_BLACK : PBM_WHITE; - --bitsperitem; + --bitsInBuffer; ++bitshift; return b; } @@ -100,6 +101,8 @@ main(int argc, const char * argv[]) { ifP = pm_openr(inputFile); + bitsInBuffer = 0; + getinit(ifP, &cols, &rows, &depth, &padright); if (depth != 1) pm_error("YBM file has depth of %u, must be 1", (unsigned)depth); @@ -109,10 +112,12 @@ main(int argc, const char * argv[]) { bitrow = pbm_allocrow(cols); for (row = 0; row < rows; ++row) { - /* Get data. */ + /* Get raster. */ unsigned int col; + for (col = 0; col < cols; ++col) bitrow[col] = getbit(ifP); + /* Discard line padding */ for (col = 0; col < padright; ++col) getbit(ifP); |