MarcSchubert
12th May 2007, 10: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
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