Add re-encoding of jpegs to baseline profile
This commit is contained in:
parent
bb6fa7926d
commit
ef3b53abdb
7 changed files with 45 additions and 8 deletions
|
@ -26,7 +26,7 @@ INSTALLS += i18n
|
||||||
system(lrelease $$PWD/translations/*.ts)
|
system(lrelease $$PWD/translations/*.ts)
|
||||||
|
|
||||||
CONFIG += sailfishapp
|
CONFIG += sailfishapp
|
||||||
PKGCONFIG += mlite5 libcurl poppler glib-2.0 cairo
|
PKGCONFIG += mlite5 libcurl poppler glib-2.0 cairo libjpeg
|
||||||
LIBS += -lcurl -lglib-2.0 -lgobject-2.0 -ldl
|
LIBS += -lcurl -lglib-2.0 -lgobject-2.0 -ldl
|
||||||
DEFINES += MADNESS=1
|
DEFINES += MADNESS=1
|
||||||
DEFINES += PDF_CREATOR='\\"SeaPrint\ $$VERSION\\"'
|
DEFINES += PDF_CREATOR='\\"SeaPrint\ $$VERSION\\"'
|
||||||
|
@ -42,6 +42,7 @@ SOURCES += src/harbour-seaprint.cpp \
|
||||||
src/mimer.cpp \
|
src/mimer.cpp \
|
||||||
ppm2pwg/ppm2pwg.cpp \
|
ppm2pwg/ppm2pwg.cpp \
|
||||||
ppm2pwg/pdf2printable.cpp \
|
ppm2pwg/pdf2printable.cpp \
|
||||||
|
ppm2pwg/baselinify.cpp \
|
||||||
ppm2pwg/bytestream/bytestream.cpp \
|
ppm2pwg/bytestream/bytestream.cpp \
|
||||||
src/overrider.cpp \
|
src/overrider.cpp \
|
||||||
src/printerworker.cpp \
|
src/printerworker.cpp \
|
||||||
|
@ -88,6 +89,7 @@ HEADERS += \
|
||||||
src/mimer.h \
|
src/mimer.h \
|
||||||
ppm2pwg/ppm2pwg.h \
|
ppm2pwg/ppm2pwg.h \
|
||||||
ppm2pwg/pdf2printable.h \
|
ppm2pwg/pdf2printable.h \
|
||||||
|
ppm2pwg/baselinify.h \
|
||||||
ppm2pwg/madness.h \
|
ppm2pwg/madness.h \
|
||||||
ppm2pwg/PwgPgHdr.h \
|
ppm2pwg/PwgPgHdr.h \
|
||||||
ppm2pwg/PwgPgHdr.codable \
|
ppm2pwg/PwgPgHdr.codable \
|
||||||
|
|
2
ppm2pwg
2
ppm2pwg
|
@ -1 +1 @@
|
||||||
Subproject commit b36a5cf08687b06498e38f5a79bbe80594ab11ca
|
Subproject commit 4844ff3ce2b773ae43585039aae146b6d225e0a6
|
|
@ -19,6 +19,7 @@ BuildRequires: pkgconfig(poppler)
|
||||||
BuildRequires: pkgconfig(poppler-glib)
|
BuildRequires: pkgconfig(poppler-glib)
|
||||||
BuildRequires: pkgconfig(glib-2.0)
|
BuildRequires: pkgconfig(glib-2.0)
|
||||||
BuildRequires: pkgconfig(cairo)
|
BuildRequires: pkgconfig(cairo)
|
||||||
|
BuildRequires: pkgconfig(libjpeg)
|
||||||
|
|
||||||
%description
|
%description
|
||||||
Network printing for Sailfish OS
|
Network printing for Sailfish OS
|
||||||
|
|
|
@ -18,6 +18,7 @@ IppPrinter::IppPrinter() : _worker(this)
|
||||||
connect(this, &IppPrinter::doGetJobs, &_worker, &PrinterWorker::getJobs);
|
connect(this, &IppPrinter::doGetJobs, &_worker, &PrinterWorker::getJobs);
|
||||||
connect(this, &IppPrinter::doCancelJob, &_worker, &PrinterWorker::cancelJob);
|
connect(this, &IppPrinter::doCancelJob, &_worker, &PrinterWorker::cancelJob);
|
||||||
connect(this, &IppPrinter::doJustUpload, &_worker, &PrinterWorker::justUpload);
|
connect(this, &IppPrinter::doJustUpload, &_worker, &PrinterWorker::justUpload);
|
||||||
|
connect(this, &IppPrinter::doFixupJpeg, &_worker, &PrinterWorker::fixupJpeg);
|
||||||
|
|
||||||
connect(this, &IppPrinter::doConvertPdf, &_worker, &PrinterWorker::convertPdf);
|
connect(this, &IppPrinter::doConvertPdf, &_worker, &PrinterWorker::convertPdf);
|
||||||
connect(this, &IppPrinter::doConvertImage, &_worker, &PrinterWorker::convertImage);
|
connect(this, &IppPrinter::doConvertImage, &_worker, &PrinterWorker::convertImage);
|
||||||
|
@ -621,11 +622,16 @@ void IppPrinter::print(QJsonObject jobAttrs, QString filename)
|
||||||
IppMsg job = mk_msg(o, jobAttrs);
|
IppMsg job = mk_msg(o, jobAttrs);
|
||||||
Bytestream contents = job.encode(IppMsg::PrintJob);
|
Bytestream contents = job.encode(IppMsg::PrintJob);
|
||||||
|
|
||||||
// Shouldn't and can't process these formats respectively
|
setBusyMessage(tr("Preparing"));
|
||||||
if((mimeType == documentFormat) && (documentFormat == Mimer::JPEG || documentFormat == Mimer::Postscript))
|
|
||||||
{
|
if((mimeType == documentFormat) && (documentFormat == Mimer::Postscript))
|
||||||
|
{ // Can't process Postscript
|
||||||
emit doJustUpload(filename, contents);
|
emit doJustUpload(filename, contents);
|
||||||
}
|
}
|
||||||
|
else if((mimeType == documentFormat) && (documentFormat == Mimer::JPEG))
|
||||||
|
{ // Just make the jpeg baseline-encoded, don't resize locally
|
||||||
|
emit doFixupJpeg(filename, contents);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(PaperSize == "")
|
if(PaperSize == "")
|
||||||
|
@ -652,8 +658,6 @@ void IppPrinter::print(QJsonObject jobAttrs, QString filename)
|
||||||
Tumble = true;
|
Tumble = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
setBusyMessage(tr("Preparing"));
|
|
||||||
|
|
||||||
if(mimeType == Mimer::PDF)
|
if(mimeType == Mimer::PDF)
|
||||||
{
|
{
|
||||||
emit doConvertPdf(filename, contents, documentFormat, Colors, Quality,
|
emit doConvertPdf(filename, contents, documentFormat, Colors, Quality,
|
||||||
|
|
|
@ -59,6 +59,7 @@ signals:
|
||||||
void doCancelJob(Bytestream msg);
|
void doCancelJob(Bytestream msg);
|
||||||
|
|
||||||
void doJustUpload(QString filename, Bytestream header);
|
void doJustUpload(QString filename, Bytestream header);
|
||||||
|
void doFixupJpeg(QString filename, Bytestream header);
|
||||||
|
|
||||||
void doConvertPdf(QString filename, Bytestream header,
|
void doConvertPdf(QString filename, Bytestream header,
|
||||||
QString targetFormat, quint32 Colors, quint32 Quality, QString PaperSize,
|
QString targetFormat, quint32 Colors, quint32 Quality, QString PaperSize,
|
||||||
|
|
|
@ -11,6 +11,9 @@
|
||||||
#include "ippprinter.h"
|
#include "ippprinter.h"
|
||||||
#include "pdf2printable.h"
|
#include "pdf2printable.h"
|
||||||
#include "ppm2pwg.h"
|
#include "ppm2pwg.h"
|
||||||
|
#include "baselinify.h"
|
||||||
|
#include <fstream>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
#define OK(call) if(!(call)) throw ConvertFailedException()
|
#define OK(call) if(!(call)) throw ConvertFailedException()
|
||||||
|
|
||||||
|
@ -75,6 +78,29 @@ catch(const ConvertFailedException& e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PrinterWorker::fixupJpeg(QString filename, Bytestream header)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
CurlRequester cr(_printer->httpUrl());
|
||||||
|
connect(&cr, &CurlRequester::done, _printer, &IppPrinter::printRequestFinished);
|
||||||
|
|
||||||
|
std::ifstream ifs = std::ifstream(filename.toStdString(), std::ios::in | std::ios::binary);
|
||||||
|
Bytestream InBts(ifs);
|
||||||
|
Bytestream OutBts;
|
||||||
|
|
||||||
|
baselinify(InBts, OutBts);
|
||||||
|
|
||||||
|
emit busyMessage(tr("Printing"));
|
||||||
|
|
||||||
|
OK(cr.write((char*)header.raw(), header.size()));
|
||||||
|
OK(cr.write((char*)OutBts.raw(), OutBts.size()));
|
||||||
|
}
|
||||||
|
catch(const ConvertFailedException& e)
|
||||||
|
{
|
||||||
|
emit failed(e.what() == QString("") ? tr("Upload error") : e.what());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void PrinterWorker::convertPdf(QString filename, Bytestream header,
|
void PrinterWorker::convertPdf(QString filename, Bytestream header,
|
||||||
QString targetFormat, quint32 Colors, quint32 Quality, QString PaperSize,
|
QString targetFormat, quint32 Colors, quint32 Quality, QString PaperSize,
|
||||||
quint32 HwResX, quint32 HwResY, bool TwoSided, bool Tumble,
|
quint32 HwResX, quint32 HwResY, bool TwoSided, bool Tumble,
|
||||||
|
@ -300,12 +326,13 @@ try {
|
||||||
bool verbose = QLoggingCategory::defaultCategory()->isDebugEnabled();
|
bool verbose = QLoggingCategory::defaultCategory()->isDebugEnabled();
|
||||||
|
|
||||||
bmp_to_pwg(inBts, outBts, urf, 1, Colors, Quality, HwResX, HwResY, Width, Height, false, false, PaperSize.toStdString(), false, false, verbose);
|
bmp_to_pwg(inBts, outBts, urf, 1, Colors, Quality, HwResX, HwResY, Width, Height, false, false, PaperSize.toStdString(), false, false, verbose);
|
||||||
emit busyMessage(tr("Printing"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CurlRequester cr(_printer->httpUrl());
|
CurlRequester cr(_printer->httpUrl());
|
||||||
connect(&cr, &CurlRequester::done, _printer, &IppPrinter::printRequestFinished);
|
connect(&cr, &CurlRequester::done, _printer, &IppPrinter::printRequestFinished);
|
||||||
|
|
||||||
|
emit busyMessage(tr("Printing"));
|
||||||
|
|
||||||
OK(cr.write((char*)header.raw(), header.size()));
|
OK(cr.write((char*)header.raw(), header.size()));
|
||||||
OK(cr.write((char*)(outBts.raw()), outBts.size()));
|
OK(cr.write((char*)(outBts.raw()), outBts.size()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,8 @@ public slots:
|
||||||
|
|
||||||
void justUpload(QString filename, Bytestream header);
|
void justUpload(QString filename, Bytestream header);
|
||||||
|
|
||||||
|
void fixupJpeg(QString filename, Bytestream header);
|
||||||
|
|
||||||
void convertPdf(QString filename, Bytestream header,
|
void convertPdf(QString filename, Bytestream header,
|
||||||
QString targetFormat, quint32 Colors, quint32 Quality, QString PaperSize,
|
QString targetFormat, quint32 Colors, quint32 Quality, QString PaperSize,
|
||||||
quint32 HwResX, quint32 HwResY, bool TwoSided, bool Tumble,
|
quint32 HwResX, quint32 HwResY, bool TwoSided, bool Tumble,
|
||||||
|
|
Loading…
Reference in a new issue