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. QTransform::quadToQuad for QImage

QTransform::quadToQuad for QImage

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 1 Posters 512 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.
  • D Offline
    D Offline
    Dimitri Junker
    wrote on last edited by
    #1

    I'll use the terms from: doc.qt.io...

    I seem to have some problem understanding this function. Iwould have expected, that the Points of polygone one end up at the coresponding points of polygone two. Here an extract of my source:
    ```
    QPolygonF quadQ, quadZ;
    quadQ <<mpkt1 <<mpkt2 << mpkt3 << mpkt4;
    int w=2500,h=1800;
    quadZ << QPointF(0,0) << QPointF(w,0) << QPointF(0,h) << QPointF(w,h);
    QTransform q2q;
    QTransform::quadToQuad(quadQ,quadZ,q2q);
    QImage target=source.transformed(q2q);

    The mpkts are QPoints  and are calculated before. They are:
    mpkt1 =(539,208)
    mpkt2 =(2921,196) 
    mpkt3 =(467,2119) 
    mpkt4 =(2966,2135) 
    
    So I would expect to find the part of the source image at (539,208) at the target image at (0,0), but it ends up at about (588,211), the others are where I would expect them relative to this on. So a translation of -588,-211 would solve the problem, but how do I get these parameters. Itried to transform the QPoint mpkt1 with the same transformation, but that gives me (0,0) as I would have expexted.
    Any idea?
    1 Reply Last reply
    0
    • D Offline
      D Offline
      Dimitri Junker
      wrote on last edited by
      #2

      Sometimes asking a question helps understand it So what seem to happen is, that the full source image is mapped to the target, not only the part of inside the polygone one.
      There it is:

      The transformation matrix is internally adjusted to compensate for unwanted translation; i.e. the image produced is the smallest image that contains all the transformed points of the original image. Use the trueMatrix() function to retrieve the actual matrix used for transforming an image.
      

      So now I have to find out how to either deactivate this adjustment or, bycomparing the two matrixes, to find out the added translation

      1 Reply Last reply
      1
      • D Offline
        D Offline
        Dimitri Junker
        wrote on last edited by
        #3

        So that the next one with the same problem finds a solution here.

        I added:

               qDebug() <<QImage::trueMatrix(q2q,source.width(),source.height()).dx();
               qDebug() <<QImage::trueMatrix(q2q,source.width(),source.height()).dy();
               qDebug() <<q2q.dy();
               qDebug() <<q2q.dx();
        
        

        and got
        0.68924
        -582.219
        0.963701
        -208.209

        The difference between these two (dx,dy) should be the added translation. so mpkt1 does not end up at (0,0) but at (0.68924+582.219,0.963701+208.209) =(583,209), which is what I observed.

        1 Reply Last reply
        2

        • Login

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