简体   繁体   中英

Make a pixel transparent in QImage

I've got a problem with trying to make a part of the image transparent in Qt. This my code:

QImage myImage;
myImage.load("clouds.jpg");
cout << myImage.pixel(1,1) << endl;
for(int i = 0; i < 100; i++)
    for(int y = 0; y < 100; y++)
         myImage.setPixel(i,y,qRgba(0, 0, 0, 0));

But I still see the pictures but with a black rect on it. Not transparent.

Can someone help me?

Probably the image format is not one which supports transparency.

I would try adding this code after loading:

myImage = myImage.convertToFormat(QImage::Format_ARGB32);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM