[Lazarus] Alpha blending in GTK2 under Linux

Kostas Michalopoulos badsectoracula at gmail.com
Sun Apr 16 01:53:00 CEST 2017


Lazarus uses GDK instead of Cairo for most graphics stuff in GTK2 and GDK
simply wraps X11 which doesn't support alpha blending. AFAIK GTK2 was using
only GDK for graphics but at some point they switched to Cairo which does
all graphics operations in the CPU and allows for alpha blending in X11.
However Lazarus didn't switch (i suppose for binary compatibility with GTK2
versions that didn't have Cairo).

As a result practically all images from Lazarus to GTK2 had their alpha
channel dropped, including toolbar icons, messages, etc. I submitted a
patch for this a few years ago that handles the most common action -
drawing a bitmap to a widget or another bitmap. This is a special case and
doesn't fix the issue entirely, but at least allows toolbars, buttons,
timages, etc to do alpha blending.

A proper full fix would be to rewrite all GTK2 graphics code to use Cairo
instead of GDK, but that would take a lot of time, can break existing
applications due to unforeseen bugs and with GTK2 being obsoleted in favor
of GTK3 i am not sure if it is worth the effort.

For further details you can check bug 25491 here:

http://mantis.freepascal.org/view.php?id=25491


On Fri, Apr 14, 2017 at 10:23 PM, Valdas Jankūnas via Lazarus <
lazarus at lists.lazarus-ide.org> wrote:

> 2017.04.14 22:02, Marc Weustink via Lazarus rašė:
>
> Why GTK2 "screen" not supports alpha?
>>>  It is strange because if I load PNG with transparency (image with
>>> gradient) into TImage then I clearly can see alpha blending effect on
>>> GTK2 when image is diplayed.
>>>
>>
>> Iirc (its long ago when i implemented it) the alphablending is done by
>> the underlying rawimage implementation
>>
>> Marc
>>
>
> I tried to put 32 bit image in to TImage (on GTK2) and alphablending
> works. Is this means that I can always put an image with 32 bit depth in to
> TImage when "GetDescriptionFromDevice(0)" says "screen" supports "Depth:
> 24"? If not always then how to know when I can?
>
>
> --
>   Valdas Jankūnas
>
> --
> _______________________________________________
> Lazarus mailing list
> Lazarus at lists.lazarus-ide.org
> http://lists.lazarus-ide.org/listinfo/lazarus
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20170416/d0cba81c/attachment.html>


More information about the Lazarus mailing list