[Qt-interest] Saving monochrome image

Alessandro Portale Alessandro.Portale at trolltech.com
Sat Aug 15 22:24:04 CEST 2009


I am afraid that in Qt 4.5, the tiff output will not produce what you 
are looking for. It will always write an Rgb image.

Qt 4.6 will support monochrome image saving. See the commit:
http://qt.gitorious.org/qt/qt/commit/2dc47ad36f235ba053a329179be4ed87d0b4d484

If I read the code correctly, it will use CCITT RLE compression for 
monochrome images.

If you need monocrome tiff saving before Qt 4.6 comes out, you may need 
to use libtiff directly, or easier: Use FreeImage. Since you can get the 
image data -see "QImage::bits()"- from your QImage, it is not so hard to 
make those extra libs interoperate with your Qt app.

Alessandro

M. Bashir Al-Noimi schrieb:
> Hi All,
> 
> I want to save a QImage object in monochrome format (1 Bit Back and 
> White) so I'm using the following code for that:
> 
>     QImage result("RGB.tif", QImage::Format_RGB32);
>     QBitmap::fromImage(result, Qt::MonoOnly).save("BW.tif");
> 
> 
> but the resultant format of the image is RGB!!!
> 
> How I can save QImage object in monochrome format ?
> 
> -----
> Best Regards
> Muhammad Bashir Al-Noimi
> My Blog: http://mbnoimi.net/
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest




More information about the Qt-interest-old mailing list