Skip to content

Commit

Permalink
Housekeeping
Browse files Browse the repository at this point in the history
  • Loading branch information
attah committed Aug 12, 2023
1 parent ca6a9e4 commit 8096a41
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 26 deletions.
5 changes: 0 additions & 5 deletions lib/curlrequester.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@
class CurlRequester
{
public:
enum Role {
IppRequest,
HttpGetRequest
};

~CurlRequester();

CurlRequester(const CurlRequester&) = delete;
Expand Down
30 changes: 15 additions & 15 deletions lib/pdf2printable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
Expand Down Expand Up @@ -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));
}
}
}
}
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion lib/pwg2ppm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 1 addition & 5 deletions utils/ppm2pwg_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 8096a41

Please sign in to comment.