From 7913a6c306e17477fda9a41d47557fc1bc27c4dd Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Mon, 30 Nov 2020 20:46:26 +0100 Subject: [PATCH] Improve grayscale handling --- src/convertworker.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/convertworker.cpp b/src/convertworker.cpp index d544537..0573feb 100644 --- a/src/convertworker.cpp +++ b/src/convertworker.cpp @@ -219,7 +219,7 @@ void ConvertWorker::convertPdf(QNetworkRequest request, QString filename, QTempo QProcess* pdftoppm = new QProcess(this); pdftoppm->setProgram("pdftoppm"); QStringList Pdf2PpmArgs = {"-rx", QString::number(HwResX), "-ry", QString::number(HwResY)}; - if(Colors != 3) + if(Colors == 1) { Pdf2PpmArgs.append("-gray"); } @@ -410,7 +410,9 @@ void ConvertWorker::convertImage(QNetworkRequest request, QString filename, QTem qDebug() << "All connected"; ppm2pwg->start(); - outImage.save(ppm2pwg, Colors == 1 ? "pgm" : "ppm"); + bool gray = Colors == 0 ? inImage.allGray() : Colors == 1; + + outImage.save(ppm2pwg, gray ? "pgm" : "ppm"); qDebug() << "Starting";