Hi,

I started writing an image format plugin about 12 months ago for Qt 4.
I never quite managed to get the thing working though.
I now need to consolidate the issue and get things working for an upcoming project though.
So I found the TiffIO plugin from the Artis website.
The only problem with that library is the latest version won't compile and I haven't yet received feedback from the author.
Given that I also plan to get a few plugins going for other image formats, I figured that I'd just finally get the nearly finished Tiff one going.

So, I used the jpeg 2000 one as a base, I used this one because I tested it and it compiled and ran without any problems.
My output path from VS is $(QTDIR)/plugins/imageformats and I know the file is being picked up because when I select a tiff file from my test gui application the dll's are locked and I can't delete them. I understand though that this doesn't mean it was recognised as a valid plugin.

So here's the class headers I've implemented:
Qt Code:
  1. #ifndef QTTIFFIMAGEHANDLER_H
  2. #define QTTIFFIMAGEHANDLER_H
  3.  
  4. #include <QtGui/QImageIOHandler>
  5. #include <QtCore/QIODevice>
  6.  
  7.  
  8. class QtTiffImageHandler : public QImageIOHandler
  9. {
  10. public:
  11. QtTiffImageHandler(QIODevice *device);
  12. virtual ~QtTiffImageHandler();
  13.  
  14. static bool canRead(QIODevice *iod, QByteArray *subType);
  15. bool canRead() const;
  16.  
  17. bool read(QImage *image);
  18. bool write(const QImage &image);
  19.  
  20. QVariant option(ImageOption option) const;
  21. void setOption(ImageOption option, const QVariant &value);
  22. bool supportsOption(ImageOption option) const;
  23.  
  24. QByteArray name() const;
  25.  
  26.  
  27. private:
  28. int writeQuality;
  29. QByteArray subType;
  30.  
  31. QByteArray parameters;
  32.  
  33. };
  34.  
  35. #endif // QTTIFFIMAGEHANDLER_H
To copy to clipboard, switch view to plain text mode 

Qt Code:
  1. #ifndef QTTIFFIMAGEPLUGIN_H
  2. #define QTTIFFIMAGEPLUGIN_H
  3.  
  4. #include <QtGui/QImageIOPlugin>
  5.  
  6. class QtTiffImagePlugin : public QImageIOPlugin
  7. {
  8. public:
  9.  
  10. QImageIOHandler* create(QIODevice *device, const QByteArray &format = QByteArray()) const;
  11. Capabilities capabilities(QIODevice *device, const QByteArray &format) const;
  12. QStringList keys() const;
  13.  
  14. };
  15.  
  16. #endif // QTTIFFIMAGEPLUGIN_H
To copy to clipboard, switch view to plain text mode 
The last line of my QtTiffImagePlugin cpp file is
Qt Code:
  1. Q_EXPORT_PLUGIN( QtTiffImagePlugin );
To copy to clipboard, switch view to plain text mode 

My test app has a QLabel and I set it's pixmap to a new QImage object:
Qt Code:
  1. QString imageFilename = QFileDialog::getOpenFileName(
  2. this,
  3. "Choose a file",
  4. "D:/My Documents/Projects/Qt/QtTiffImageFormat/Debug",
  5. "Images (*.png *.tif *.jpg *.jp2)");
  6.  
  7. if (!imageFilename.isEmpty())
  8. {
  9. QImage image(imageFilename);
  10. if (image.isNull())
  11. {
  12. QMessageBox::information(this, tr("Image Viewer"), tr("Can't load '%1' mate.").arg(imageFilename));
  13. return;
  14. }
  15. ui.lblImage->setPixmap(QPixmap::fromImage(image));
  16.  
  17.  
  18. }
To copy to clipboard, switch view to plain text mode 

At the beginning of every function I'm opening a new text file and writing a message to it so I can track if any of my plugin's functions are being called, but none of these files are being created so I'm assuming that my plugin simply isn't even being queried for it's formats / capabilites.
Can anyone familiar with this process please let me know if I'm missing some obvious step?
Or even a not so obvious one

Thanks,

Steve York