PDA

View Full Version : Printing Screenshot -> poor quality



MarcSchubert
12th May 2007, 11:45
Hello,

i am trying to print a screenshot, but the print has a poor quality. is there a way to scale and print an image in high quality.



void Window::printScreenshot()
{
imageLabel->setPixmap(QPixmap::grabWindow(QApplication::deskto p()->winId()));

Q_ASSERT(imageLabel->pixmap());
QPrintDialog dialog(&printer, 0);
if (dialog.exec()) {
QPainter painter(&printer);
QRect rect = painter.viewport();
QSize size = imageLabel->pixmap()->size();
size.scale(rect.size(), Qt::KeepAspectRatio);
imageLabel->resize(size.width(), size.height());
painter.setViewport(rect.x(), rect.y(), size.width(), size.height());
painter.setWindow(imageLabel->pixmap()->rect());
painter.drawPixmap(0, 0, *imageLabel->pixmap());
}
}


Kind regards

Marc Schubert

PS: excuse my english

Uwe
12th May 2007, 12:37
See QPrinter::setResolution.

Uwe

MarcSchubert
14th May 2007, 11:48
thank you .. it works