mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
b241b7c06a
commit
fc84f8868d
2 changed files with 18 additions and 1 deletions
|
@ -108,7 +108,9 @@ void PrintLayout::printSixDives() const
|
||||||
QTransform transform;
|
QTransform transform;
|
||||||
transform.rotate(270);
|
transform.rotate(270);
|
||||||
pm = QPixmap(pm.transformed(transform));
|
pm = QPixmap(pm.transformed(transform));
|
||||||
painter.drawPixmap(0, 0, pm);
|
if (!printOptions->color_selected)
|
||||||
|
pm = convertPixmapToGrayscale(pm);
|
||||||
|
painter.drawPixmap(0, 0, pm);
|
||||||
}
|
}
|
||||||
painter.end();
|
painter.end();
|
||||||
profile->setPrintMode(false);
|
profile->setPrintMode(false);
|
||||||
|
@ -244,3 +246,17 @@ QString PrintLayout::insertTableDataCol(QString data) const
|
||||||
{
|
{
|
||||||
return "<td>" + data + "</td>";
|
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);
|
||||||
|
}
|
||||||
|
|
|
@ -34,6 +34,7 @@ private:
|
||||||
QString insertTableHeadingCol(int) const;
|
QString insertTableHeadingCol(int) const;
|
||||||
QString insertTableDataRow(struct dive *) const;
|
QString insertTableDataRow(struct dive *) const;
|
||||||
QString insertTableDataCol(QString) const;
|
QString insertTableDataCol(QString) const;
|
||||||
|
QPixmap convertPixmapToGrayscale(QPixmap) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Reference in a new issue