summaryrefslogtreecommitdiffstats
path: root/qt-ui/printlayout.cpp
diff options
context:
space:
mode:
authorGravatar Lubomir I. Ivanov <neolit123@gmail.com>2013-07-13 16:12:32 +0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-07-18 12:00:12 -0700
commitfc84f8868d6cad30f6e250b3115c1ce1f574e1b5 (patch)
treec69e1f4eb1f212bd86aba3bf3e0879c1c3a32b87 /qt-ui/printlayout.cpp
parentb241b7c06a970578152154313c9c10627882c292 (diff)
downloadsubsurface-fc84f8868d6cad30f6e250b3115c1ce1f574e1b5.tar.gz
Print: add method to convert profile to grayscale
(experimental) Add the method PrintLayout::convertPixmapToGrayscale() to convert a rendered profile pixmap to grayscale. It will probably be faster to have ProfileGraphicsView render in grayscale under certain conditions (and use a specific color table) instead - e.g.: ProfileGraphicsView::setPrintMode(bool printMode, bool useGrayScale); Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Diffstat (limited to 'qt-ui/printlayout.cpp')
-rw-r--r--qt-ui/printlayout.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/qt-ui/printlayout.cpp b/qt-ui/printlayout.cpp
index 935a4cc91..0ef37d5a3 100644
--- a/qt-ui/printlayout.cpp
+++ b/qt-ui/printlayout.cpp
@@ -108,7 +108,9 @@ void PrintLayout::printSixDives() const
QTransform transform;
transform.rotate(270);
pm = QPixmap(pm.transformed(transform));
- painter.drawPixmap(0, 0, pm);
+ if (!printOptions->color_selected)
+ pm = convertPixmapToGrayscale(pm);
+ painter.drawPixmap(0, 0, pm);
}
painter.end();
profile->setPrintMode(false);
@@ -244,3 +246,17 @@ QString PrintLayout::insertTableDataCol(QString data) const
{
return "<td>" + data + "</td>";
}
+
+// experimental
+QPixmap PrintLayout::convertPixmapToGrayscale(QPixmap pixmap) const
+{
+ QImage image = pixmap.toImage();
+ int gray, width = pixmap.width(), height = pixmap.height();
+ for (int i = 0; i < width; i++) {
+ for (int j = 0; j < height; j++) {
+ gray = qGray(image.pixel(i, j));
+ image.setPixel(i, j, qRgb(gray, gray, gray));
+ }
+ }
+ return pixmap.fromImage(image);
+}