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. QImage Rotation and Translation
Forum Updated to NodeBB v4.3 + New Features

QImage Rotation and Translation

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 16.6k 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.
  • E Offline
    E Offline
    endhck
    wrote on last edited by
    #1

    Hi, I have a grayscale image. There is a rectangular area in the image, but it must be rotated by 0.25 degrees.
    I used the following code:

    @
    QTransform myTransform;
    myTransform.rotate(-0.2);
    myTransform.translate(-5, -5); // Now I want to read the rectangular area only, so I try to translate the upperleft point.
    MyImage = myImage.transformed(myTransform);
    @

    In this code, rotation is okay, but translation is not, there is no change. I wonder why?
    And also, the upperleft coordinates of the rectangular area was 241, 212; what is the new upper coordinates after rotation?

    Thanks

    1 Reply Last reply
    0
    • V Offline
      V Offline
      VitorAMJ
      wrote on last edited by
      #2

      Hi, your transformation might not be working as you want because of the results of such transformations applied to a image using QTransform and QImage::transformed.
      According to the documentation:
      @QImage QImage::transformed( const QTransform &matrix , Qt::TransformationModemode=Qt::FastTransformation
      const@

      "Returns a copy of the image that is transformed using the given transformation matrix and transformation mode.

      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.

      Unlike the other overload, this function can be used to perform perspective transformations on images."

      Also, to know the resulting vector position, multiply the rotation matrix and vector position (linear algebra). The info about the QTransform matrix is in the documentation. They show other things that might guide you to what you want (see "here":http://developer.qt.nokia.com/doc/qt-4.7/qtransform.html )

      1 Reply Last reply
      0
      • V Offline
        V Offline
        VitorAMJ
        wrote on last edited by
        #3

        If you did not solve your problem and need some help, feel free :-)
        Regards,

        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