Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt WebKit
  4. Getting a higher quality image from QWebPage
Forum Updated to NodeBB v4.3 + New Features

Getting a higher quality image from QWebPage

Scheduled Pinned Locked Moved Qt WebKit
1 Posts 1 Posters 666 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    khookguy
    wrote on last edited by
    #1

    I'm creating an image capture utility to allow uses to download snapshots of the charts and graphs that our web application generates. I've used the "Framecapture":http://qt-project.org/doc/qt-5.0/qtwebkitexamples/webkitwidgets-framecapture.html example application as a starting point.

    It works well, but the image quality is too low for our needs. I need to be able to created higher resolution images.

    My understanding from reading the "QWebPage documentation":http://qt-project.org/doc/qt-5.1/qtwebkit/qwebpage.html#details is that I need to increase the pixel density ratio in the Viewports Attributes.

    Unfortunately, I cannot figure out how to do that. Seems like I might need to do something with the X11 server that QWebPage talks to to get the Viewports Attributes, but I'm not a real expert in any of this stuff, so am having a hard time figuring it out.

    Could somebody please give me some pointers?

    The code that I'm using is basically like this:

    @QWebPage m_page;
    m_page.mainFrame()->load(url);
    m_page.mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff);
    m_page.mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff);
    m_page.setViewportSize(1200,800);
    QImage image(m_page.mainFrame()->contentsSize(), QImage::Format_ARGB32_Premultiplied);
    image.fill(Qt::transparent);
    QPainter painter(&image);
    painter.setRenderHint(QPainter::Antialiasing, true);
    painter.setRenderHint(QPainter::TextAntialiasing, true);
    painter.setRenderHint(QPainter::SmoothPixmapTransform, true);
    m_page.mainFrame()->documentElement().render(&painter);
    painter.end();
    image.save(fileName);@

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved