3
votes

I am using a QImage of the format _ARGB32. I have to set some of the pixels as transparent and some as opaque. So, I used this line:

Image.setPixel(x,y,QColor(r,g,b,0).rgba());

to set the pixel as transparent. I have even tried this:

Image.setPixel(x,y,qRgba(r,g,b,0));

Still nothing happens.Just after setting it, when i print the pixel again, using:

qDebug() << "Color : " << QColor::fromRgba(Image.pixel(x,y));

I always get the value as 1 for the alpha channel. Even when i save the image, I got not get the transparency. How do I fix it?

1
Can you show us the code where you load the image and set the format?thuga

1 Answers

3
votes

Make sure the image format supports transparency. Maybe first you will need to call

Image = Image.convertToFormat(QImage::Format_ARGB32); // or maybe other format