= Modifying a standard Qt image plugin = I created a Qt image format plugin to write CCITT-compressed TIFF files by stripping out everything that wasn't needed from the standard TIFF plugin in Qt. Here's a recipe for those of you interested in doing the same thing: 1. Locate the src/plugins/imageformats/tiff directory in the Qt source package. 2. Copy it, creating a new directory called tiff_ccitt for the modifications. Make the following modifications to files in that directory. 3. Apply the [[attachment:tiff_ccitt.patches|set of patches]] to the files in that directory, typically by entering the directory at the command line and typing {{{patch < tiff_ccitt.patches }}} Now, you should be able to build the plugin by typing the following commands: {{{qmake make make install }}} Note that, on some GNU/Linux systems, you might need to run `qmake-qt4` instead of `qmake` and that you may need root privileges to invoke `make install`. With the plugin installed, you should be able to write TIFF images using the `tiff_ccitt_group4` format. The following code can be used as a test: {{{#!/usr/bin/env python import sys from PyQt4.QtGui import * app = QApplication([]) image = QImage(200, 200, QImage.Format_Mono) image.fill(qRgb(255,255,255)) painter = QPainter() painter.begin(image) painter.setPen(QColor(0,0,0)) painter.drawRect(20,20,160,160) painter.end() writer = QImageWriter() if not writer.setFormat("tiff_ccitt_group4"): sys.stderr.write("Failed to set the format for the plugin.\n") sys.exit(1) writer.setFileName("temp-sq.tif") writer.write(image) }}}