summaryrefslogtreecommitdiff
path: root/user/skanlite/png-review-129988.patch
diff options
context:
space:
mode:
authorA. Wilcox <AWilcox@Wilcox-Tech.com>2018-03-13 18:05:29 -0500
committerA. Wilcox <AWilcox@Wilcox-Tech.com>2018-03-13 18:05:29 -0500
commit123fe63dd7b20f2350d03da5d3136f5863cb77d9 (patch)
treed67cbbee50467975106b15a6b3d1d76428773a39 /user/skanlite/png-review-129988.patch
parent7957cc543533f0332882f45de1fe2bfbb17f9c81 (diff)
downloadpackages-123fe63dd7b20f2350d03da5d3136f5863cb77d9.tar.gz
packages-123fe63dd7b20f2350d03da5d3136f5863cb77d9.tar.bz2
packages-123fe63dd7b20f2350d03da5d3136f5863cb77d9.tar.xz
packages-123fe63dd7b20f2350d03da5d3136f5863cb77d9.zip
user/skanlite: new package
Diffstat (limited to 'user/skanlite/png-review-129988.patch')
-rw-r--r--user/skanlite/png-review-129988.patch99
1 files changed, 99 insertions, 0 deletions
diff --git a/user/skanlite/png-review-129988.patch b/user/skanlite/png-review-129988.patch
new file mode 100644
index 000000000..05697078c
--- /dev/null
+++ b/user/skanlite/png-review-129988.patch
@@ -0,0 +1,99 @@
+From 9f1e7b3596b114ef23834810f661307ef49a38de Mon Sep 17 00:00:00 2001
+From: Alexander Trufanov <trufanovan@gmail.com>
+Date: Wed, 8 Mar 2017 17:11:25 +0300
+Subject: fix DPI info in 16-bit PNG
+
+REVIEW:129988
+
+Skanlite tries to save 16bit PNG files on its own in its KSaneImageSaver class because KSaneWidget (part of libksane) uses QImage to save files and QImage doesn't support 16bit images. Related warning in [libksane](https://github.com/KDE/libksane/blob/master/src/ksanewidget.h#L118)
+
+But Skanlite doesn't add most of optional PNG headers to the exported png file. In particulary it misses pHYs (Physical Pixel Dimensions) info. Without it ScanTailor app can't detect scan's dpi and forces user to choose it manually while png file importing. [Related issue in scantailor](https://github.com/scantailor/scantailor/issues/250)
+I've fixed this by adding pHYs to 16bit png based on KSaneWidget::currentDPI() as KSaneWidget [do it itself](https://github.com/KDE/libksane/blob/master/src/ksanewidget.cpp#L627)
+---
+ src/KSaneImageSaver.cpp | 11 ++++++++---
+ src/KSaneImageSaver.h | 4 ++--
+ src/skanlite.cpp | 2 +-
+ 3 files changed, 11 insertions(+), 6 deletions(-)
+
+diff --git a/src/KSaneImageSaver.cpp b/src/KSaneImageSaver.cpp
+index aaffed2..49123a1 100644
+--- a/src/KSaneImageSaver.cpp
++++ b/src/KSaneImageSaver.cpp
+@@ -46,6 +46,7 @@ struct KSaneImageSaver::Private {
+ int m_width;
+ int m_height;
+ int m_format;
++ int m_dpi;
+ ImageType m_type;
+
+ bool savePng();
+@@ -64,7 +65,7 @@ KSaneImageSaver::~KSaneImageSaver()
+ delete d;
+ }
+
+-bool KSaneImageSaver::savePng(const QString &name, const QByteArray &data, int width, int height, int format)
++bool KSaneImageSaver::savePng(const QString &name, const QByteArray &data, int width, int height, int format, int dpi)
+ {
+ if (!d->m_runMutex.tryLock()) {
+ return false;
+@@ -75,15 +76,16 @@ bool KSaneImageSaver::savePng(const QString &name, const QByteArray &data, int w
+ d->m_width = width;
+ d->m_height = height;
+ d->m_format = format;
++ d->m_dpi = dpi;
+ d->m_type = Private::ImageTypePNG;
+
+ start();
+ return true;
+ }
+
+-bool KSaneImageSaver::savePngSync(const QString &name, const QByteArray &data, int width, int height, int format)
++bool KSaneImageSaver::savePngSync(const QString &name, const QByteArray &data, int width, int height, int format, int dpi)
+ {
+- if (!savePng(name, data, width, height, format)) {
++ if (!savePng(name, data, width, height, format, dpi)) {
+ qDebug() << "fail";
+ return false;
+ }
+@@ -192,6 +194,9 @@ bool KSaneImageSaver::Private::savePng()
+
+ png_set_sBIT(png_ptr, info_ptr, &sig_bit);
+
++ png_uint_32 dpm = m_dpi * (1000.0 / 25.4);
++ png_set_pHYs(png_ptr, info_ptr, dpm, dpm, 1);
++
+ /* Optionally write comments into the image */
+ // text_ptr[0].key = "Title";
+ // text_ptr[0].text = "Mona Lisa";
+diff --git a/src/KSaneImageSaver.h b/src/KSaneImageSaver.h
+index 0ee23ac..96cc763 100644
+--- a/src/KSaneImageSaver.h
++++ b/src/KSaneImageSaver.h
+@@ -37,9 +37,9 @@ public:
+ KSaneImageSaver(QObject *parent = 0);
+ ~KSaneImageSaver();
+
+- bool savePng(const QString &name, const QByteArray &data, int width, int height, int format);
++ bool savePng(const QString &name, const QByteArray &data, int width, int height, int format, int dpi);
+
+- bool savePngSync(const QString &name, const QByteArray &data, int width, int height, int format);
++ bool savePngSync(const QString &name, const QByteArray &data, int width, int height, int format, int dpi);
+
+ bool saveTiff(const QString &name, const QByteArray &data, int width, int height, int format);
+
+diff --git a/src/skanlite.cpp b/src/skanlite.cpp
+index 1f1541c..7a671a2 100644
+--- a/src/skanlite.cpp
++++ b/src/skanlite.cpp
+@@ -498,7 +498,7 @@ void Skanlite::saveImage()
+ (m_format == KSaneIface::KSaneWidget::FormatGrayScale16))
+ {
+ KSaneImageSaver saver;
+- if (saver.savePngSync(localName, m_data, m_width, m_height, m_format)) {
++ if (saver.savePngSync(localName, m_data, m_width, m_height, m_format, m_ksanew->currentDPI())) {
+ m_showImgDialog->close(); // closing the window if it is closed should not be a problem.
+ }
+ else {
+--
+cgit v0.11.2
+