Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QPainter drawImage seems different with original image
Qt 6.12 LTS is out! See what's new in the release blog

QPainter drawImage seems different with original image

Scheduled Pinned Locked Moved Solved QML and Qt Quick
5 Posts 3 Posters 2.1k 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.
  • W Offline
    W Offline
    webberg
    wrote on last edited by webberg
    #1

    Hello everyone. I implement a class which extend QQuickPaintedItem and rewrite the paint( QPainter * ) to show an image of PDF page. I find the QPainter draw image do not work very well. Here is my drawing code:

    painter->setRenderHint(QPainter::HighQualityAntialiasing, true);
    m_iPDFImage.load("D:\\a.bmp");
    painter->drawImage(m_rTarget, m_iPDFImage);
    

    and the following is a.bmp(part of image):
    0_1472803426354_a.bmp
    but the result of drawImage looks like:
    0_1472803574457_QQ图片20160902160548.png
    here I hardly to see "-" in command "dpkg -i ".
    It cost my one day to try to solve it but fail. So what's the problem? Can anyone give me an advise? thx.

    raven-worxR 1 Reply Last reply
    0
    • W webberg

      Hello everyone. I implement a class which extend QQuickPaintedItem and rewrite the paint( QPainter * ) to show an image of PDF page. I find the QPainter draw image do not work very well. Here is my drawing code:

      painter->setRenderHint(QPainter::HighQualityAntialiasing, true);
      m_iPDFImage.load("D:\\a.bmp");
      painter->drawImage(m_rTarget, m_iPDFImage);
      

      and the following is a.bmp(part of image):
      0_1472803426354_a.bmp
      but the result of drawImage looks like:
      0_1472803574457_QQ图片20160902160548.png
      here I hardly to see "-" in command "dpkg -i ".
      It cost my one day to try to solve it but fail. So what's the problem? Can anyone give me an advise? thx.

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      @webberg
      What is the type of m_rTarget? Is it a rect or a point?
      I assume it's a rect, so the image will be scaled to fit into it.

      If it's a point check if the painter itself is scaling, which means that the item is scaled?

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      W 1 Reply Last reply
      0
      • D Offline
        D Offline
        Devopia53
        wrote on last edited by Devopia53
        #3

        Did you use the painter->setRenderHint(QPainter::SmoothPixmapTransform)?

        W 1 Reply Last reply
        0
        • raven-worxR raven-worx

          @webberg
          What is the type of m_rTarget? Is it a rect or a point?
          I assume it's a rect, so the image will be scaled to fit into it.

          If it's a point check if the painter itself is scaling, which means that the item is scaled?

          W Offline
          W Offline
          webberg
          wrote on last edited by
          #4

          @raven-worx m_rTarget is a QRectF.

          1 Reply Last reply
          0
          • D Devopia53

            Did you use the painter->setRenderHint(QPainter::SmoothPixmapTransform)?

            W Offline
            W Offline
            webberg
            wrote on last edited by
            #5

            @Devopia53 thx! now I can see the "-". I forgot it because I scaled the image using SmoothTransformation and didn't use it in painter again.

            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
            • Unsolved