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. Maximum Size a Pixmap Can Be scaled() to
Qt 6.11 is out! See what's new in the release blog

Maximum Size a Pixmap Can Be scaled() to

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 2 Posters 1.8k 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.
  • B Offline
    B Offline
    brazz
    wrote on last edited by
    #1

    I have a QPixmap pointer which points to a Pixmap drawn from a file in an actionOpen triggered() slot. Using this pointer I would like to scale my Pixmap using scroll bars and then add the pixmap to the scene again. Currently my scaling works however when I approach pixel numbers around 20,000+ the debugger tells me my pixmap is invalid and the graphics view widget displaying my pixmap does not display anything. I can't think of why this is the case considering that my Pixmap is originally drawn to be 30,000+ plus pixels and the graphics view displayed that in my tests (currently the program scales the pixmap down to (5000, 1000) and then the numbers approach 20,000 as the slider values change). I put together a simple button clicked() slot to test exactly what the problem was and the code is displayed below. Manually editing the numbers finds that my Pixmap will display with (6000, 2000) in the scaled() method but (20000, 5000) is invalid. Any Ideas?

    QPixmap pixmapTemp = wavesPixmapOriginal->scaled(20000,5000,
     Qt::ignoreAspectRatio, Qt::SmoothTransformation);
        wavesScene->addPixmap(pixmapTemp);
        ui->PixmapView->setSceneRect(QRectF(0,0, 20000, 5000));
    

    wavesPixmapOriginal points to a static pixmap defined in my actionOpen triggered() slot. It is a private class member of my mainWindow class, defined in mainWindow.h.

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

      Hi! The pixmap directly uses resources supplied by the window system. The maximum size is limited by the graphics driver, graphics card, and the amount of free video memory. If you need to exceed this limit, see if you can use QImage which lives in main memory.

      1 Reply Last reply
      2
      • B Offline
        B Offline
        brazz
        wrote on last edited by
        #3

        But the strange thing is that my pixmap can be much larger than 20,000 pixels. I've tested one that was 60,000 beforehand.

        1 Reply Last reply
        0
        • B Offline
          B Offline
          brazz
          wrote on last edited by
          #4

          after reading this article I somewhat understand why it would be best to use QImage in this scenario. I'm assuming I can convert my Qpixmap to a Qimage though.

          http://blog.qt.io/blog/2009/12/16/qt-graphics-and-performance-an-overview/

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

            After you created your pixmap, check its bit depth. If it returns zero, then the needed resources couldn't be allocated:

                QPixmap pm(60000,10000);
                qDebug() << pm.depth();
               
            
            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