[Gambas-user] Image over image - transparence
Benoit Minisini
gambas at ...1...
Fri Jan 16 20:33:12 CET 2004
On Friday 16 January 2004 18:32, Rob wrote:
> On Friday 16 January 2004 11:15, _root wrote:
> > FANTASTIC !
> > I think that this is a great tip!
>
> Hmm, I think you're right. So....
>
> http://www.binara.com/gambas-wiki/bin/view/Gambas/HowDoIDoTransparency
>
> > Thank you !!!
>
> Glad to help.
>
> Rob
>
There is a big problem with transparency on X-Window, and so on Qt.
1) The Picture Gambas object is actually two differents Qt objects: QPixmap or
QImage.
2) A QImage is stored in application memory. It is 24 bits-depth with 8-bits
alpha channel, like any image on Gimp.
3) A QPixmap is stored in the X-Window server, has 24 bits-depth too (in fact,
it depends on the display depth, but only one problem at once), and has no
transparency ! To simulate it, Qt adds to the QPixmap a QBitmap (a black &
white pixmap) that masks the QPixmap. It is an alpha channel with only 1 bit,
and not 8 bits as a QImage.
4) The Draw class can't draw on a QImage: only on a QPixmap !
5) When you draw on QPixmap, the mask is NOT updated !
6) So you see the problems: no equivalence between a Picture that is a QImage
and a Picture that is a QPixmap.
7) Gambas automatically converts Picture/QPixmap from and to Picture/QImage so
that this is transparent to the user. Alas, because of the previous points,
you may lose some information when going from QImage to QPixmap !
8) Gambas automatically refresh the mask when you draw on a QPixmap: but this
refresh is based on a QT method that may fail sometimes !
So, what can I do ?
As X-Window won't have 24 bits pixmaps with full alpha channel before the
Keith Packard's project ends, I think I will split the Picture class.
I will rename the Image control, and keep the Image name for the class that
represents the QImage object. The Picture class will represent the QPixmap
object only.
This is a huge incompatible change, but I think this is necessary. Having only
one Picture class, like in VB, seems easier for the user. But, in fact, it
hides all the problems, and some programs that manipulate Pictures may be
slow, without any clear reason for the user !
Regards,
--
Benoit Minisini
mailto:gambas at ...1...
More information about the User
mailing list