mirror of
https://github.com/subsurface/subsurface.git
synced 2024-12-01 06:30:26 +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,6 +108,8 @@ void PrintLayout::printSixDives() const
|
|||
QTransform transform;
|
||||
transform.rotate(270);
|
||||
pm = QPixmap(pm.transformed(transform));
|
||||
if (!printOptions->color_selected)
|
||||
pm = convertPixmapToGrayscale(pm);
|
||||
painter.drawPixmap(0, 0, pm);
|
||||
}
|
||||
painter.end();
|
||||
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ private:
|
|||
QString insertTableHeadingCol(int) const;
|
||||
QString insertTableDataRow(struct dive *) const;
|
||||
QString insertTableDataCol(QString) const;
|
||||
QPixmap convertPixmapToGrayscale(QPixmap) const;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue