简体   繁体   English

在QImage中使像素透明

[英]Make a pixel transparent in QImage

I've got a problem with trying to make a part of the image transparent in Qt. 尝试在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);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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