QPixmap::fromImage() vs QPixmap::toImage()
-
I have to read
.png
(possibly others, but maybe only these) files from disk. I will need aQPixmap
from that (forQGraphicsPixmapItem
) for use in the application. But I (the end user) will also potentially be manipulating the image in code so I want to keep them around asQImage
s (from which I will produce a newQPixmap
) as well.When reading the file initially, does it make any difference whether I do:
QPixmap::load(); QPixmap::toImage();
versus
QImage::load(); QPixmap::fromImage();
? I know little about images. Is either direction (a) slower than the other or (b) loses some information in the original
.png
file? -
I have to read
.png
(possibly others, but maybe only these) files from disk. I will need aQPixmap
from that (forQGraphicsPixmapItem
) for use in the application. But I (the end user) will also potentially be manipulating the image in code so I want to keep them around asQImage
s (from which I will produce a newQPixmap
) as well.When reading the file initially, does it make any difference whether I do:
QPixmap::load(); QPixmap::toImage();
versus
QImage::load(); QPixmap::fromImage();
? I know little about images. Is either direction (a) slower than the other or (b) loses some information in the original
.png
file?An image from a file/buffer is read by QImageReader, therefore into a QImage. Then you can convert it to a QPixmap. On windows and afair on linux there is no real conversation between QImage and QPixmap needed though.
-
An image from a file/buffer is read by QImageReader, therefore into a QImage. Then you can convert it to a QPixmap. On windows and afair on linux there is no real conversation between QImage and QPixmap needed though.
@Christian-Ehrlicher said in QPixmap::fromImage() vs QPixmap::toImage():
An image from a file/buffer is read by QImageReader, therefore into a QImage.
Perfect, thanks!
-
J JonB has marked this topic as solved on