[Gambas-user] How do I replace Image transparent background with a white background?

Benoît Minisini gambas at ...1...
Wed Sep 19 01:41:32 CEST 2012


Le 18/09/2012 23:48, RICHARD WALKER a écrit :
> OK Benoît,
> I have rebuilt gambas3-3.1.1, which is the version distributed with
> Mageia 2, with the patch I derived from your modified
> gb.gtk/src/CClipboard.cpp file in revision 5175. It works just fine
> (sort of - see later) and I have registered an appropriate Mageia bug
> (Bug 7522) which will hopefully make this fix available to other
> Gambas users in the Mageia community. No doubt the version of Gambas
> to be released with Mageia 3 will be post revision 5175 (my
> anglo-saxon fingers are crossed; south africans hold thumbs, I
> believe. Is there a standard Euro-gesture?).
>
> Now that I can paste a Gambas-processed image using either qt4 or gtk
> I can see that there is a difference in the way these toolkits support
> the PaintImage method of the Image class. The gb.qt4 way is pretty
> much what the manual says. The gb.gtk method does not implement any
> anti-aliasing and is much less refined looking. Seems I will have to
> go on using the qt4 version for a while longer. Nevertheless, for
> ordinary purposes not involving conversion from transparent to opaque
> backgrounds it should be usable.
>
> The stranger thing is what happens when you substitute DrawImage for
> PaintImage in each toolkit. The raggedness of the gtk PaintImage is
> echoed by the qt4 DrawImage and the smoothness of the qt4 PaintImage
> is rivalled by the smoothness of the gtk DrawImage. Mind-bending
> stuff! If you are as confused as I was then please have a look at the
> attached Lbreoffice doc...
>
> Richard
>

It depends on what you are doing before with the images, and if you use 
Image or Pictures.

Image are (almost) identical between gb.qt4 and gb.gtk, because they are 
stored in the process memory.

But Picture are different, they are stored in the X11 server, which do 
not support alpha channel by default. To have Picture with alpha 
channels, Qt internally use the XRender extension. But GTK+ does 
nothing, it assume you will do everything with images in process memory.

As soon as you convert an Image into a Picture, *and* if you use a 
Picture method, gb.gtk then converts the initial image alpha channel 
into an 1-bit mask (i.e. alpha = 0 or 255 for each pixel). So you get 
the aliased-effect you noticed.

Try to never use Picture, unless at the very last moment (for example 
when assiging a Button picture, or a Form background like in the 
OnScreenDisplay example).

Tell me if you understand what I mean.

Regards,

-- 
Benoît Minisini




More information about the User mailing list