I am creating QGraphicsPixmapItems
by loading images from files.
bool PixMapItem::loadItemFromFile(const QString &filename)
{
QPixmap p;
if(!p.load(filename))
return false;
setPixmap(p);
#ifdef NOT_QT_4
m_itemSize = p.size()/p.devicePixelRatio();
#else
m_itemSize = p.size();
#endif
return true;
}
caller:
item->loadItemFromFile(filename);
item->adjustForMaxSize(maxSize);
I would like to know how the memory used by the item depends on the image file size.
1) Type of image - will the encoding of the Pixmap stored in the item be minimal, or always 32 bit, or is there any way to set it ?
2) Assuming the item is resized immediately after load to match a specific size (see above), would the actual image size affect the item memory size ? Would memory size be better if I scale the pixmap instead of the item itself ?
Let me try to answer it, maybe it help you :
Note that the pixel data in a pixmap is internal and is managed by the underlying window system.
QPixmap is design for painting performance on screen, if you want better handle IO (formating image, decrease the color, etc) use QImage. You also able to render QImage to screen using the painter but it will be slower compare to QPixmap.