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. Antialiasing for QPixmap scaled in a QGraphicsScene
Qt 6.11 is out! See what's new in the release blog

Antialiasing for QPixmap scaled in a QGraphicsScene

Scheduled Pinned Locked Moved General and Desktop
22 Posts 8 Posters 28.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.
  • J Offline
    J Offline
    Jassie
    wrote on last edited by
    #13

    Hi,

    Do you mean I should zoom out my image first before I scale the view?

    1 Reply Last reply
    0
    • J Offline
      J Offline
      Jassie
      wrote on last edited by
      #14

      Hi,

      Do you mean I should zoom out my image first before I scale the view?

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #15

        As an example:
        I load my original image with size 1024px. It is displayed in my graphicsview with the same size.
        Now i zoom out 50%. But instead of scaling the graphicsview, simply resize the original image to 512px (with QT or openCV) and reload it into the graphicsview.

        1 Reply Last reply
        0
        • ? Offline
          ? Offline
          A Former User
          wrote on last edited by
          #16

          As an example:
          I load my original image with size 1024px. It is displayed in my graphicsview with the same size.
          Now i zoom out 50%. But instead of scaling the graphicsview, simply resize the original image to 512px (with QT or openCV) and reload it into the graphicsview.

          1 Reply Last reply
          0
          • J Offline
            J Offline
            Jassie
            wrote on last edited by
            #17

            Thank you.But If I scale the image manually everytime I scale the view in wheelevent,it costs so much time. Is there any better way to solve this problem?

            1 Reply Last reply
            0
            • J Offline
              J Offline
              Jassie
              wrote on last edited by
              #18

              Thank you.But If I scale the image manually everytime I scale the view in wheelevent,it costs so much time. Is there any better way to solve this problem?

              1 Reply Last reply
              0
              • E Offline
                E Offline
                euchkatzl
                wrote on last edited by
                #19

                When you want the best result there is no other option as drawing the image in exact the size shown on screen.(in Pixel)

                To archive this you could subclass QGraphicsPixmapItem and override paint.

                There you have to load the pixmap in the correct size (try to map your scene coordinates to pixels).

                To load an Image in an scaled size you could for example use QImageReader :

                http://doc.qt.io/qt-5/qimagereader.html#setScaledSize

                Of course you have to cache the loaded Pixmap yourself.
                When you reach paint event with the same size your code should use the cached pixmap.

                1 Reply Last reply
                0
                • E Offline
                  E Offline
                  euchkatzl
                  wrote on last edited by
                  #20

                  When you want the best result there is no other option as drawing the image in exact the size shown on screen.(in Pixel)

                  To archive this you could subclass QGraphicsPixmapItem and override paint.

                  There you have to load the pixmap in the correct size (try to map your scene coordinates to pixels).

                  To load an Image in an scaled size you could for example use QImageReader :

                  http://doc.qt.io/qt-5/qimagereader.html#setScaledSize

                  Of course you have to cache the loaded Pixmap yourself.
                  When you reach paint event with the same size your code should use the cached pixmap.

                  1 Reply Last reply
                  0
                  • ? Offline
                    ? Offline
                    A Former User
                    wrote on last edited by
                    #21

                    Or simply calculate all possible images for all zoom steps at the start.

                    That means if your zoom values range from 10% to 100% with zoom step +10% simply calculate all 9 images at the start, cache them and load them depending on the zoom value.

                    QPixmap pixmap100, pixmap90, pixmap80, pixmap70 ... (etc)

                    you would have to limit the number of possible zoom values of course to avoid long loading times and huge amount of data.

                    1 Reply Last reply
                    0
                    • ? Offline
                      ? Offline
                      A Former User
                      wrote on last edited by
                      #22

                      Or simply calculate all possible images for all zoom steps at the start.

                      That means if your zoom values range from 10% to 100% with zoom step +10% simply calculate all 9 images at the start, cache them and load them depending on the zoom value.

                      QPixmap pixmap100, pixmap90, pixmap80, pixmap70 ... (etc)

                      you would have to limit the number of possible zoom values of course to avoid long loading times and huge amount of data.

                      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