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. Mirroring a Pixmap Item around an axis
Forum Updated to NodeBB v4.3 + New Features

Mirroring a Pixmap Item around an axis

Scheduled Pinned Locked Moved Unsolved General and Desktop
qgraphicspixmaptransformrotationc++qt5
12 Posts 2 Posters 3.1k Views 2 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.
  • G Offline
    G Offline
    Giuseppe97
    wrote on 22 Mar 2020, 20:06 last edited by Giuseppe97
    #3

    @SGaist Hi. That method applies to a QImage and in my case I have tried to apply it to the pixmap (returned by pixmap() )of the item but there is such an item because a QImage is a Qpixmape but not viceversa. Am I right?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 22 Mar 2020, 20:08 last edited by
      #4

      I am not sure I am following you because your transformed call is also applied directly to your QImage.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      G 1 Reply Last reply 22 Mar 2020, 20:13
      1
      • S SGaist
        22 Mar 2020, 20:08

        I am not sure I am following you because your transformed call is also applied directly to your QImage.

        G Offline
        G Offline
        Giuseppe97
        wrote on 22 Mar 2020, 20:13 last edited by Giuseppe97
        #5

        @SGaist In this line of code

        mario->setPixmap(mario->pixmap().transformed(QTransform().scale(-1, 1)));
        

        where is QImage? I haven't understood where I should apply the mirrored method

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 22 Mar 2020, 20:19 last edited by
          #6

          My bad ! I mixed both classes.

          What I had in mind was to apply the mirroring or the original QImage and then load it in the item,

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          G 1 Reply Last reply 22 Mar 2020, 20:24
          0
          • S SGaist
            22 Mar 2020, 20:19

            My bad ! I mixed both classes.

            What I had in mind was to apply the mirroring or the original QImage and then load it in the item,

            G Offline
            G Offline
            Giuseppe97
            wrote on 22 Mar 2020, 20:24 last edited by
            #7

            @SGaist Do you have any other idea? I can't figure out by myself and I was hoping someone with more experience than me would have had some hints.

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 22 Mar 2020, 20:26 last edited by
              #8

              Well, why not use the setTransform method if your item directly ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              G 1 Reply Last reply 22 Mar 2020, 20:31
              1
              • S SGaist
                22 Mar 2020, 20:26

                Well, why not use the setTransform method if your item directly ?

                G Offline
                G Offline
                Giuseppe97
                wrote on 22 Mar 2020, 20:31 last edited by Giuseppe97
                #9

                @SGaist ok so something like this

                mario->setPixmap(mario->pixmap().transformed(setTransform()));
                

                and how can I achieve the mirroring towards that green axis?

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on 22 Mar 2020, 21:52 last edited by
                  #10

                  No, I suggested to transform the item not it's content hence the link I provided to the QGraphicsItem::setTransform method.

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  G 1 Reply Last reply 22 Mar 2020, 22:56
                  1
                  • S SGaist
                    22 Mar 2020, 21:52

                    No, I suggested to transform the item not it's content hence the link I provided to the QGraphicsItem::setTransform method.

                    G Offline
                    G Offline
                    Giuseppe97
                    wrote on 22 Mar 2020, 22:56 last edited by Giuseppe97
                    #11

                    @SGaist OK , now I am following you. So according to you in order to mirror mario ,through setTransform method, I should do
                    something like:

                    mario->setTransform()
                    

                    and I should chain two consecutive transformations (e.g TRANSLATE + SCALE(-1,1) ) by passing an opportune matrix to the setTransform method. Am I right?

                    If so, could you show me through a small piece of code how to chain a translation plus a scale operation?

                    1 Reply Last reply
                    0
                    • S Offline
                      S Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on 23 Mar 2020, 22:23 last edited by
                      #12

                      Did you already read the Graphics View Overview in Qt's documentation ?

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      1

                      12/12

                      23 Mar 2020, 22:23

                      • Login

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