It seems very strange that Qt doesn’t support multi-image TIFFs. The only explanation I can find for this is that multi-imaged non-animated files do not fit for the Qt image framework. From that framework point of view the graphic file may contain several images only if it is intended to display animation. TIFF files may contain several images which are not used for animation (consequent display). Well, here it is the plug-in that allows you to read multi-imaged TIFFs just like any other graphics format supported by Qt.
Build the project (you will need some libtiff.so version and its headers on your PATH). find an executable file libqmitiff.so.x.x (you need the file itself, not a link to it). Rename the file to libqmitiff.so. Now put this file into plugins/imageformats directory of the Qt distribution you built it with.
It may happen so that you now have two TIFF plugins: the default Qt plugin (something called like libqtiff.so) and the multi-image TIFF reader plugin. You can use both of them even in the same program. For example if you want to write files in the TIFF format (the capabilitu the multi-image plugin currently lacks). The rule is simple. When you write in your code something like
QImageReader ir("tfile.tiff");
or
QPixmap pix("tfile.tiff", "TIFF");
the program will load and use the default Qt polugin. In order to use the multi-image plugin you have to write something like
QPixmap pix("tfile.tiff", "MITIFF");
Note that if you want to use the multi-image plugin you cannot omit the format specification («MITIFF» in this case) like you could when using the default plugin. In fact this second argument you pass to QImageReader or QPixmap specifies not the image file format but rather which plugin should be used to handle the image file. So you may have several plugins for the same file format.
I have worked with it under Linux and MinGW. It shouldn’t be difficult to compile it under Visual Studio as well I suppose.
Here is a little FAQ:
Q: Can I use the qmitiff plugin to read single-imaged TIFFs?
A: Yes you can.
Q: Can I use the plugin to read files in other TIFF-related formats?
A: Since the plugin is based on libtiff, it will read anything the libtiff can read.
Q: Why does my program sometimes complains about bad magic numbers but still reads the file all right?
A: I don’t know. This message comes from libtiff. I’m not an expert in the TIFF format. It is enough for me that the file and its parameters (e.g. size) can be read correctly. Contact libtiff developers if you want to know more about this issue.
Q: How can I know how many images there are within a tiff file?
A: Call the QImageReader’s imageCount () method.
Q: How can I read the particular image within an open file?
A: Use the QImageReader’s jumpToImage() method. If you specify the right image number ([0.. imageCount ()-1], that image becomes the current image for all the subsequent operation.
Q: What are the additional options available when using the qmitiff plugin with QImageReader?
A: If you need to read only a fragment of the original image the QImageReader’s setClipRect() method can increase the loading speed and conserve some memory.