From b2804921e6ccfd121da724730e53f0c9f7f8ce85 Mon Sep 17 00:00:00 2001 From: giraffedata Date: Sun, 28 Jan 2024 20:11:30 +0000 Subject: cleanup git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@4838 9d0c8265-081b-0410-96cb-a4ca84ce46f8 --- converter/ppm/ppmtowinicon.c | 49 +++++++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 21 deletions(-) (limited to 'converter') diff --git a/converter/ppm/ppmtowinicon.c b/converter/ppm/ppmtowinicon.c index 0e2751f3..e3c6a5c5 100644 --- a/converter/ppm/ppmtowinicon.c +++ b/converter/ppm/ppmtowinicon.c @@ -272,14 +272,14 @@ fillInRaster1(u1 ** const rowData, for (row = 0; row >= 1; + bitOnMask >>= 1; } } } else { @@ -323,15 +326,15 @@ fillInRaster4(u1 ** const rowData, for (row = 0; row < rows; ++row) { u1 * thisRow; - unsigned int byteOn; - unsigned int nibble; /* high nibble = 1, low nibble = 0; */ + unsigned int byteSeq; + unsigned int nibbleSig; /* high nibble = 1, low nibble = 0; */ MALLOCARRAY_NOFAIL(thisRow, xByteCt); memset(thisRow, 0, xByteCt); rowData[rows - row - 1] = thisRow; - byteOn = 0; /* initial value */ - nibble = 1; /* initial value */ + byteSeq = 0; /* initial value */ + nibbleSig = 1; /* initial value */ if (pa) { unsigned int col; @@ -339,16 +342,18 @@ fillInRaster4(u1 ** const rowData, for (col = 0; col < cols; ++col) { int value; + assert(byteSeq < xByteCt); + value = ppm_lookupcolor(cht, &pa[row][col]); /* init value */ /* Shift it, if we're putting it in the high nibble. */ - if (nibble) + if (nibbleSig == 1) value <<= 4; - thisRow[byteOn] |= value; - if (nibble == 1) - nibble = 0; + thisRow[byteSeq] |= value; + if (nibbleSig == 1) + nibbleSig = 0; else { - nibble = 1; - ++byteOn; + nibbleSig = 1; + ++byteSeq; } } } else { @@ -372,8 +377,10 @@ fillInRaster8(u1 ** const rowData, for (row = 0; row < rows; ++row) { u1 * thisRow; /* malloc'ed */ + assert(cols <= xByteCt); + MALLOCARRAY_NOFAIL(thisRow, xByteCt); - memset (thisRow, 0, xByteCt); + memset(thisRow, 0, xByteCt); rowData[rows - row - 1] = thisRow; if (pa) { unsigned int col; -- cgit 1.4.1