Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to handle images in a proper way by rendering from QPdfDocument
Forum Updated to NodeBB v4.3 + New Features

How to handle images in a proper way by rendering from QPdfDocument

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 383 Views
  • 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.
  • A Offline
    A Offline
    awerber
    wrote on last edited by
    #1

    Dear all,

    I want to extract an image from a PDF document. The PDF document page is the following:

    42bf7953-49d5-4106-ba75-035b932b32dc-grafik.png

    using the QPdfDocument class I rendered an image using

    QPdfDocument pdf;
    pdf.load("test.pdf");
    const int n = 0;
    QImage qimg = pdf.render(n,pdf.pageSize(n).toSize());
    qimg = qimg.convertToFormat(QImage::Format_RGB888);

    The rendered image looks like:

    0a59206b-ffa4-497d-b98c-adce729acf08-grafik.png

    Extracting the image's alpha channel by using

    QImage alpha = qimg.convertToFormat(QImage::Format_Alpha8);
    alpha.invertPixels(QImage::InvertRgba);

    I get:

    392b1a2d-d93a-4396-a32c-25f67c69d46c-grafik.png

    As mentioned in an earlier post I just want to render an image of the PDF page that looks the same as the pdf page itsself, no fancy stuff. I guess I somehow have to combine or convert the upper both images. I'd be grateful if someone has an idea of how to get things done.

    Cheers

    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