PDA

View Full Version : which Qt widget is best to be used for displaying image of every format ?



krystosan
29th November 2013, 17:48
As Of now I am using this way to display an image but I want to be able to use QtWidet that can dislay most kinds of image formats like jog,png,tiff,bmp, dpx, exr, cin etc..


self.imageLabel = QtGui.QLabel()
self.imageLabel.setBackgroundRole(QtGui.QPalette.B ase)
self.imageLabel.setSizePolicy(QtGui.QSizePolicy.Ig nored, QtGui.QSizePolicy.Ignored)
self.imageLabel.setScaledContents(True)
self.imageLabel.setPixmap(QtGui.QPixmap.fromImage( image))

anda_skoa
30th November 2013, 00:43
The label can obviously show all images that are available as QPixmap. Since there is a conversion from QImage to QPixmap, it can show all images available as QImage. Which means it can show all images that you have QImage IO plugins for.

Cheers,
_

krystosan
30th November 2013, 05:57
then how do I get dpx, cin and exr plugin to work with QPixmap ?

anda_skoa
30th November 2013, 11:24
QPixmap is not directly involved in image I/O, that is what QImage does.

QImage delegates loading to image I/O plugins. If you can load certain formats but not others then the plugins for those other formats are most likely not installed correctly.
Check the plugin directories: http://qt-project.org/doc/qt-4.8/deployment-plugins.html

Cheers,
_

krystosan
30th November 2013, 11:59
tif images keep giving this error message while being displayed:
TIFFReadDirectory: Warning, foo: invalid TIFF directory; tags are not sorted in ascending order.
for dpx and exr i get
QPixmap::scaled: Pixmap is a null pixmap

anda_skoa
1st December 2013, 09:20
Those sound like loading errors.

The TIFF error suggest that the image data is either corrupt or in a different format than supported by the TIF plugin being used.
The other could indicate that the respective plugins have not been found.

Check QImageReader::supportedImageFormats()

If your formats are not listed, check that the plugins implementing them are available in one of Qt's plugin search paths.

Cheers,
_

krystosan
2nd December 2013, 14:22
I see these are the one that are available

['bmp', 'gif', 'ico', 'jpeg', 'jpg', 'mng', 'pbm', 'pgm', 'png', 'ppm', 'svg', 'svgz', 'tga', 'tif', 'tiff', 'xbm', 'xpm']

anda_skoa
2nd December 2013, 16:06
Since there are two image formats starting with "tif" in that list, have you tried both when loading your tif files? Is there a difference in error?

As for the formats not in the list check that your plugins got installed correctly. See comment #4

Cheers,
_