PDA

View Full Version : image processing



IRON_MAN
18th November 2009, 09:51
hello,

Is any way to thread images? I mean, I have load an image on a button. This image has a red zone that i don't need and I would like to erase that black area and stay with the desired image.

Is any way to turn this area(the red one) transparent?

My code is the following one:

QPixmap buttonImage("images/down.bmp");
QPixmap button2Image("images/up.bmp");

QIcon Icon;
Icon.addPixmap ( buttonImage, QIcon::Normal, QIcon::Off );
Icon.addPixmap ( button2Image, QIcon::Normal, QIcon::On );

QPushButton *Button = new QPushButton(&widget1);
Button->setIcon(Icon);
Button->setIconSize(QSize(120,80));
Button->setCheckable(true);
Button->setGeometry(0,0,100,78);
Button->move(295,320);


thanks in advance!!

scascio
18th November 2009, 11:22
I think you need to use QPixmap::setMask
Then the question is : how to compute it from your loaded image from pixel value, knowing that pixel manipulation is done in a QImage?
But since your file is hard coded, you mask may be hard coded too.

drhex
18th November 2009, 11:49
Can't you load the image into an image editor and paint transparency over the red area?

IRON_MAN
18th November 2009, 12:54
no I can't, because the image has to be checkable.

scascio
18th November 2009, 13:37
Did you try QPixmap::createMaskFromColor ?