something like colorimg.togray()
i didn't find in QImage class
thx
something like colorimg.togray()
i didn't find in QImage class
thx
Not that I'm aware of. What you will probably need to do is call bits(), which returns a uchar * to the first bit, and then iterate over them all, applying some rgb->grayscale algorithm to each bit. A quick google search found a few simple algorithms, so it shouldn't be too difficult.
Not sure if there is any direct function...
but you can iterate over the image pixels and use QColor::qGray to convert the rgb into gray scale
Iterating over QImage pixels() and converting with QColor would certainly be easier, but I wonder what the performance would be like. It seems like it would be significantly slower than accessing the bits directly, but I don't know if there's any basis for that. I am interested now. Maybe this weekend I will have a chance to try it out myself.
Bookmarks