Hi All,

I want to change the alpha value for all pixels which are black on an image and hitting some real hassles with this. The solutions out there do not work for me. I load a jpg then convert the image using QImage::Format_ARGB32

Qt Code:
  1. qDebug() << "OUT IMAGE FORMAT HAS ALPHA CHANNEL " << outImage.hasAlphaChannel();
To copy to clipboard, switch view to plain text mode 

The above shows as true. I then try:

Qt Code:
  1. for (int y = 0; y < outImage.height(); y++) {
  2. for (int x = 0; x < outImage.width(); x++) {
  3. QColor c = outImage.pixel(x, y);
  4. outImage.setPixel(x,y, (uint) qRgba((int) c.red(), (int) c.green(), (int) c.blue(), 0)) ;
  5. }
  6. }
  7. mainIm->setPixmap(QPixmap::fromImage(outImage));
To copy to clipboard, switch view to plain text mode 


With the above nothing happens. If I use:

Qt Code:
  1. outImage.setPixel(x,y, (uint) qRgba(255,255,255,255));
To copy to clipboard, switch view to plain text mode 


I see a perfect solid white square that replaces the image. As expected.

If I use:

Qt Code:
  1. outImage.setPixel(x,y, (uint) qRgba(255,255,255,100));
To copy to clipboard, switch view to plain text mode 


I see the original image with transparent white square at opacity 100;

If I use:

Qt Code:
  1. outImage.setPixel(x,y, (uint) qRgba(0, 0, 0, 0)) ;
To copy to clipboard, switch view to plain text mode 


Nothing happens.

I've tried so many variations based on the solutions here on SO and QT forums my head now hurts so I need to ask for help :-( I was expecting to use in combination with scanline for performance but not too important with respect to speed.

All help appreciated.

Thanks.