diff --git a/lib/curlrequester.h b/lib/curlrequester.h index 02be03b..b28802a 100644 --- a/lib/curlrequester.h +++ b/lib/curlrequester.h @@ -14,11 +14,6 @@ class CurlRequester { public: - enum Role { - IppRequest, - HttpGetRequest - }; - ~CurlRequester(); CurlRequester(const CurlRequester&) = delete; diff --git a/lib/pdf2printable.cpp b/lib/pdf2printable.cpp index d980b61..fd4c261 100644 --- a/lib/pdf2printable.cpp +++ b/lib/pdf2printable.cpp @@ -168,13 +168,12 @@ int pdf_to_printable(std::string inFile, WriteFun writeFun, const PrintParameter bool rotate = false; poppler_page_get_size(page, &pageWidth, &pageHeight); - fixup_scale(xScale, yScale, xOffset, yOffset, rotate, - pageWidth, pageHeight, params); + fixup_scale(xScale, yScale, xOffset, yOffset, rotate, pageWidth, pageHeight, params); cairo_translate(cairo, xOffset, yOffset); cairo_scale(cairo, xScale, yScale); - if (rotate) + if(rotate) { // Rotate to portrait cairo_matrix_t matrix; cairo_matrix_init(&matrix, 0, -1, 1, 0, 0, pageHeight); @@ -185,7 +184,7 @@ int pdf_to_printable(std::string inFile, WriteFun writeFun, const PrintParameter } status = cairo_status(cairo); - if (status) + if(status) { std::cerr << "cairo error: " << cairo_status_to_string(status) << std::endl; return 1; @@ -247,19 +246,22 @@ void copy_raster_buffer(Bytestream& bmpBts, uint32_t* data, const PrintParameter for(size_t col=0; col < paperSizeWInPixels; col++) { // Do Floyd-Steinberg dithering to keep grayscales readable in 1-bit pixel = RGB32_GRAY(data[line*paperSizeWInPixels+col]) + nextDebt; - newpixel = pixel < 127 ? 0 : 255; + newpixel = pixel < 128 ? 0 : 255; debt = pixel - newpixel; nextDebt = debtArray[col+2] + SIXTEENTHS(7, debt); debtArray[col] += SIXTEENTHS(3, debt); debtArray[col+1] += SIXTEENTHS(5, debt); debtArray[col+2] = SIXTEENTHS(1, debt); - if(newpixel == 0 && black) + if(newpixel == 0) { - tmp[line*paperSizeWInBytes+col/8] |= (0x80 >> (col % 8)); - } - else if(newpixel == 0) - { - tmp[line*paperSizeWInBytes+col/8] &= ~(0x80 >> (col % 8)); + if(black) + { + tmp[line*paperSizeWInBytes+col/8] |= (0x80 >> (col % 8)); + } + else + { + tmp[line*paperSizeWInBytes+col/8] &= ~(0x80 >> (col % 8)); + } } } } @@ -313,10 +315,8 @@ void fixup_scale(double& xScale, double& yScale, double& xOffset, double& yOffse bool raster = params.format == PrintParameters::PWG || params.format == PrintParameters::URF; - size_t hOut = raster ? tmp.getPaperSizeHInPixels() - : tmp.getPaperSizeHInPoints(); - size_t wOut = raster ? tmp.getPaperSizeWInPixels() - : tmp.getPaperSizeWInPoints(); + size_t hOut = raster ? tmp.getPaperSizeHInPixels() : tmp.getPaperSizeHInPoints(); + size_t wOut = raster ? tmp.getPaperSizeWInPixels() : tmp.getPaperSizeWInPoints(); double scale = round2(std::min(wOut/wIn, hOut/hIn)); xOffset = roundf((wOut-(wIn*scale))/2); yOffset = roundf((hOut-(hIn*scale))/2); diff --git a/lib/pwg2ppm.cpp b/lib/pwg2ppm.cpp index 9245b6b..668bc59 100644 --- a/lib/pwg2ppm.cpp +++ b/lib/pwg2ppm.cpp @@ -28,7 +28,7 @@ void raster_to_bmp(Bytestream& outBts, Bytestream& file, line << white; } } - else if (count < 128) + else if(count < 128) { // repeats size_t repeats = count+1; Bytestream tmp; diff --git a/utils/ppm2pwg_main.cpp b/utils/ppm2pwg_main.cpp index 0fe32e4..5b16339 100644 --- a/utils/ppm2pwg_main.cpp +++ b/utils/ppm2pwg_main.cpp @@ -28,11 +28,7 @@ inline void ignore_comments(std::istream* in) } } -#ifndef PPM2PWG_MAIN - #define PPM2PWG_MAIN main -#endif - -int PPM2PWG_MAIN(int argc, char** argv) +int main(int argc, char** argv) { PrintParameters params; params.paperSizeUnits = PrintParameters::Pixels;