Question about Qt4 and semi-transparent drawings [+ another question]

Sébastien Laoût slaout at linux62.org
Sat Jul 23 16:14:45 BST 2005


> You assumed wrong. Qt 3 does correctly composite two pixmaps with an
> alpha channel if the render extension is present. In Qt 3 we had an
> external alpha which is almost impossible to accelerate in hardware. In
> Qt 4 that changes so at least you should be hitting the most optimized
> PictOpOver case in the render code.

Oh... yes, I understand how it works, now.
I was not getting the "external alpha channel" thing before.
That's clearer now.
Thank you very much.

And I just better understood the fatality of the "external alpha channel".

I'm now wanting to create a transparent image and be able to draw on it.
But everything I'm drawing is not visible because of the fully transparent 
mask.

So, with Qt3, when drawing on a pixmap we should open two painters: one for 
the pixmap, and one for the mask, isn't it?
When drawing eg. a line on the pixmap, we should draw the same line in black 
on the mask, to "remove transparency and allow to show the line".

Or am I wrong?
Is there a way to create a transparent pixmap and directly draw on it?
I don't think so in Qt3, but let's try to ask :-)

The Qt3 QPixmap documentation is speaking about "mask data" and "alpha 
channel".
So I could be wrong: is there a way to transform a mask data to an alpha 
channel?
Or is this alpha-channel only available for 32bpp depth pixmaps (my system 
refuse to create such QPixmap, I don't have XRender and am on a 24bpp 
display) with XRender?

I'm trying to create an image of a QRadioButton.
As the radioButton is round, 
QStyle::drawPrimitive(QStyle::PE_ExclusiveIndicator...) only draw and fill 
the round and leave other pixels inchanged (at least with Plastik style).
I've tryed to make the image transparent and then tell QStyle to draw the 
radioButton but hey... I then understood fully the alpha mask: the resulting 
pixmap is fully transparent.
There exist a QStyle::drawPrimitive(QStyle::PE_ExclusiveIndicatorMask...) but 
it's a full black square!

So, after hours of thinking and trys, I now fill the pixmap with Qt::red and 
then call drawPrimitive() and then create an heuristic mask (which make all 
Qt::red pixels transparent) for it.

That's uggly, and I would want to know if there is a better solution?

And if I well understood, with Qt4 I would have been able to create a fully 
transparent pixmap and call drawPrimitive(QStyle::PE_ExclusiveIndicator...) : 
the resulting image would be visible.




More information about the kde-core-devel mailing list