PDA

View Full Version : Save Qt tiff files in 1 bit not 32 bit



jeffpogo
19th June 2009, 22:07
Anyone know how to save a black and white tiff file in "2 colors" not "millions of colors"?

Qt saves them as 32 bit but I only need 1 bit (QImage::Format_Mono)

Or does Qt have another format that can save black and with images in the smallest size possible?

Thank you, Jeff.

wysota
20th June 2009, 02:30
Mono is one bit (2 colours), not two (4 colours)... Storing one bit images as tiff and expecting them to be small is a dead man's wish. Use PNG instead, it offers a decent compression and is loseless format just like tiff.

jeffpogo
20th June 2009, 02:49
I wish I could use png but our "old" imaging system only works with tiff files.

The tiff files on our imaging system are about 1/2 to 1/3 the size of the qt tiff lzw compressed files.

I might pull the tiff plugin source and create a local 1 bit write function.

Thank you for the idea.

Jeff.

wysota
20th June 2009, 10:25
If tiff supports a 1bit image format (I don't know if it does, tiff is mostly used for photos, not mono bitmaps) then saving it as such should have worked.

SimonSchmeisser
20th June 2009, 10:52
Tiff is a sort of meta-fileformat, it can support any colorspace, any compression and custumn meta tags. So you could have a scanner that likes outputting images with 1 bit for black-white and 13bits for shades of purple ... all compressed with let's say the rar-algorithm.

So working with tiff really is no fun. Qt4 works with 32bit ARGB internally and as far as I know cannot be told to work with other stuff. blowing up 1bit image data to 32bit looks like a waste of space. So if you need fast processing of lot's of images, you might be faster with your own implementation.