PDA

View Full Version : can you save 8 bpp grayscale bitmaps?



eric
16th November 2007, 20:31
I know it's possible to save pixmaps like this:

myPixmap.save("image.bmp", 0, -1);

but the resulting file is 24 bpp rgb image.

Is it also possible to make 8 bpp grayscale images this way?

Valheru
17th November 2007, 20:58
I needed to get a 1 bpp grayscale the other day for OCR purposes, but I never could get Qt to do this :o

e8johan
17th November 2007, 22:42
You will have to create an image plug-in that lets you do this: http://doc.trolltech.com/qq/qq17-imageio.html

jpn
18th November 2007, 11:00
I guess you could abuse QIcon to produce a grayscaled image:


QIcon icon;
QPixmap pixmap("test.png");
icon.addPixmap(pixmap);
QImage image = icon.pixmap(pixmap.size(), QIcon::Disabled).toImage();
image = image.convertToFormat(QImage::Format_Indexed8);