Unsolved Maximum Size a Pixmap Can Be scaled() to
-
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.
-
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. -
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.
-
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/
-
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();