我在尝试使图像的一部分在Qt中透明时遇到了问题。这是我的代码:

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));

但是我仍然看到图片,但是上面有黑色的矩形。不透明。

有人能帮我吗?

最佳答案

图像格式可能不是支持透明度的一种。

我会在加载后尝试添加以下代码:
myImage = myImage.convertToFormat(QImage::Format_ARGB32);

关于c++ - 使像素在QImage中透明,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/9210585/

10-11 04:02