[Qt-interest] If Opacity Less than 1, QImage Not Painted

Josiah Bryan jbryan at productiveconcepts.com
Wed Oct 27 16:31:56 CEST 2010


I've got a really weird problem here:

QImage image((const 
uchar*)byteArray.constData(),size.width(),size.height(),QImage::Format_RGB32);
painter->setOpacity(0.5);
painter->drawImage(rect, image);

This draws NOTHING. Not a white square, nothing - background visible at 
that location. However, if I take out the 'setOpacity' line or set it to 
1.0, then the image draws fine. What in the world could be causing this?

If I call image.convertToFormat(QImage::Format_ARGB32) prior to 
painting, it paints correctly with partial opacity - BUT this adds 
another 5ms latency to the painting - quite unacceptable, really. I need 
to paint it without having to call converToFormat just to get partial 
opacity.

For the record, this is in a QGraphicsItem with a QGLWidget as the 
QGraphicsView viewport - BUT, I've also tested it without the QGLWidget 
viewport, and same problem.

The image data is coming from a V4L2 capture interface using the 
V4L2_PIX_FMT_BGR32 pixel format - this works just fine, the image 
displays correctly. I just can't get it to paint with a partial opacity.

Any ideas, anyone?

Thanks!
-Josiah Bryan




More information about the Qt-interest-old mailing list