How do I change specific colors in a pixmap? For example, I have a pixmap with white and black pixels, and I want to change all white pixels to blue, but leave the black ones alone. Or maybe change the black to white and the white to blue… [I am searching for a solution in Qt/PyQt, but maybe this is a general question as to how pixmaps are handled/composed.]
Share
You can use
createMaskFromColorto create a bitmap for the white pixels, then usedrawPixmapto overwrite them with another color.Note that
createMaskFromColoris going to convert the pixmap to aQImage, so you should try to use aQImagedirectly, if possible.