diff options
Diffstat (limited to 'converter')
-rw-r--r-- | converter/other/pnmtorle.c | 6 | ||||
-rw-r--r-- | converter/other/rletopnm.c | 24 | ||||
-rw-r--r-- | converter/pbm/pbmtolps.c | 12 |
3 files changed, 26 insertions, 16 deletions
diff --git a/converter/other/pnmtorle.c b/converter/other/pnmtorle.c index 67838297..1882fe5d 100644 --- a/converter/other/pnmtorle.c +++ b/converter/other/pnmtorle.c @@ -133,12 +133,14 @@ write_rle_data(void) { MALLOCARRAY(xelrow, width); MALLOCARRAY(scanlines, height); - RLE_CHECK_ALLOC(hdr.cmd, scanlines, "scanline pointers"); + if (!scanlines) + pm_error("Failed to allocate memory for %u scanline pointers", height); for (scan = 0; scan < height; ++scan) { int rc; rc = rle_row_alloc(&hdr, &scanlines[scan]); - RLE_CHECK_ALLOC(hdr.cmd, rc >= 0, "pixel memory"); + if (rc < 0) + pm_error("Failed to allocate memory for a scanline"); } /* Loop through the pnm files image window, read data and flip vertically. */ diff --git a/converter/other/rletopnm.c b/converter/other/rletopnm.c index 73ab2659..97f271dc 100644 --- a/converter/other/rletopnm.c +++ b/converter/other/rletopnm.c @@ -274,11 +274,15 @@ writePpmRaster(FILE * const imageoutFileP, alpharow = pgm_allocrow(width); MALLOCARRAY(scanlines, height); - RLE_CHECK_ALLOC( hdr.cmd, scanlines, "scanline pointers" ); + if (!scanlines) + pm_error("Failed to allocate memory for %u scanline pointers", height); - for ( scan = 0; scan < height; scan++ ) - RLE_CHECK_ALLOC( hdr.cmd, (rle_row_alloc(&hdr, &scanlines[scan]) >= 0), - "pixel memory" ); + for (scan = 0; scan < height; ++scan) { + int rc; + rc = rle_row_alloc(&hdr, &scanlines[scan]); + if (rc < 0) + pm_error("Failed to allocate memory for a scanline"); + } /* * Loop through those scan lines. */ @@ -375,11 +379,15 @@ writePgmRaster(FILE * const imageoutFileP, alpharow = pgm_allocrow(width); MALLOCARRAY(scanlines, height); - RLE_CHECK_ALLOC( hdr.cmd, scanlines, "scanline pointers" ); + if (!scanlines) + pm_error("Failed to allocate memory for %u scanline pointers", height); - for (scan = 0; scan < height; ++scan) - RLE_CHECK_ALLOC(hdr.cmd, (rle_row_alloc(&hdr, &scanlines[scan]) >= 0), - "pixel memory" ); + for (scan = 0; scan < height; ++scan) { + int rc; + rc = rle_row_alloc(&hdr, &scanlines[scan]); + if (rc < 0) + pm_error("Failed to allocate memory for a scanline"); + } /* * Loop through those scan lines. */ diff --git a/converter/pbm/pbmtolps.c b/converter/pbm/pbmtolps.c index 968ec921..d974fcb2 100644 --- a/converter/pbm/pbmtolps.c +++ b/converter/pbm/pbmtolps.c @@ -182,8 +182,8 @@ doRaster(FILE * const ifP, static void -pbmtolps(FILE * const ifP, - FILE * const ofP, +pbmtolps(FILE * const ifP, + FILE * const ofP, struct CmdlineInfo const cmdline) { const char * const psName = @@ -192,13 +192,13 @@ pbmtolps(FILE * const ifP, int rows; int cols; int format; - float scRows; - float scCols; + float scRows, scCols; + /* Dimensions of the printed image in points */ pbm_readpbminit(ifP, &cols, &rows, &format); - scRows = (float) rows / cmdline.dpi * 72.0; - scCols = (float) cols / cmdline.dpi * 72.0; + scRows = (float) rows / (cmdline.dpi / 72.0); + scCols = (float) cols / (cmdline.dpi / 72.0); if (cmdline.lineWidthSpec) validateLineWidth(scCols, scRows, cmdline.lineWidth); |