PDA

View Full Version : Image 32 bit depth to 8 bit depth



^NyAw^
1st September 2008, 11:27
Hi,

I'm taking an image from scanner using TWAIN and I use the "QPixmap::fromWinHBITMAP(HBITMAP)" method to convert the scanned image to a QPixmap. The HBITMAP info tells me that the image is 8 bit depth but when converting to QPixmap it returns me 32 bit depth.

Any one knows how to convert this QPixmap 32 bit depth to 8 bit depth? The image is scanned on 8 bit depth gray.
Thanks,

wysota
1st September 2008, 21:00
Convert it to image using QPixmap::toImage() and then use QImage::convertToFormat() to convert it to QImage::Format_Indexed8. Then you might need to adjust the palette.

^NyAw^
2nd September 2008, 10:35
Thanks,

I have used another way. I created the image with Width and Height and Indexed palette, then I just copied the image buffer to the QImage buffer. Now I only just have to invert the copy process because the Bitmaps are stored inverted by line.

Thanks,