what is the best way to open various kind formats of images with Qt?
-
Hi,
It depends on what you want to do with the image data. You can use isNull to know whether your QImage/QPixmap is correctly loaded.
-
Hi,
It depends on what you want to do with the image data. You can use isNull to know whether your QImage/QPixmap is correctly loaded.
-
If load returns falls, then yes your QImage will be null
-
Difference between classes: http://doc.qt.io/qt-5/qpixmap.html#details
In nutshell
QImage - for access, passing image data across threads, accessing pixel data
QPixmap - display - OGL / Shaders / Rester - usually data resides on Server side (depending on platform etc. it can mean GPU memory if hw acceleration is used)To know if image can be read use: bool QImageReader::canRead() const
Both classes are just containers for data and do not support by themselves file formates. To get a list of supported file formats for i.e. reading use QImageReader::supportedImageFormats() (QImageWriter for writing). To add new file format support one need to write plugin to extend supported formats.
Both classes have isNull() method that can be checked after loading if image data is loaded.
There is also QImageReader class http://doc.qt.io/qt-4.8/qimagereader.html