[Lazarus] Alpha blending in GTK2 under Linux

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[Lazarus] Alpha blending in GTK2 under Linux

Free Pascal - Lazarus mailing list
Hello,

I working with alpha blending. On QT it works fine. On GTK2 I get
"Depth: 24" when executing "GetDescriptionFromDevice(0)" (on QT -> 32).
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. Maybe I must to use
"GetDescriptionFromDevice" not from screen? From where then?

There is full "DataDescription" on GTK2:
            Format: ricfRGBA
             Width: 3
            Height: 3
             Depth: 24
          BitOrder: riboBitsInOrder
         ByteOrder: riboLSBFirst
         LineOrder: riloTopToBottom
           LineEnd: rileDWordBoundary
      BitsPerPixel: 32
           RedPrec: 8
          RedShift: 16
         GreenPrec: 8
        GreenShift: 8
          BluePrec: 8
         BlueShift: 0
         AlphaPrec: 0
        AlphaShift: 0
  MaskBitsPerPixel: 1
PaletteColorCount: 0

System Kubuntu 16.10; lazarus 1.9.0; fpc 3.0.0.

P.S. sorry for my bad English.

--
   Valdas Jankūnas
--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Lazarus] Alpha blending in GTK2 under Linux

Free Pascal - Lazarus mailing list


On April 14, 2017 7:35:20 PM GMT+02:00, "Valdas Jankūnas via Lazarus" <[hidden email]> wrote:
>Hello,
>
>I working with alpha blending. On QT it works fine. On GTK2 I get
>"Depth: 24" when executing "GetDescriptionFromDevice(0)" (on QT -> 32).
>
>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
--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Lazarus] Alpha blending in GTK2 under Linux

Free Pascal - Lazarus mailing list
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
[hidden email]
http://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Lazarus] Alpha blending in GTK2 under Linux

Free Pascal - Lazarus mailing list
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 <[hidden email]> wrote:
<a href="tel:2017.04.14%2022" value="+12017041422" target="_blank">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
[hidden email]
http://lists.lazarus-ide.org/listinfo/lazarus


--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Lazarus] Alpha blending in GTK2 under Linux

Free Pascal - Lazarus mailing list
On Sun, 16 Apr 2017 02:53:00 +0300
Kostas Michalopoulos via Lazarus <[hidden email]> wrote:

>[...]
> 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

You can do it with IFDEFs.

> due to unforeseen bugs and with GTK2 being obsoleted in favor
> of GTK3 i am not sure if it is worth the effort.

A strong point. IMO you should better spend your time on improving the
LCL Gtk3 interface.

Mattias
--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Lazarus] Alpha blending in GTK2 under Linux

Free Pascal - Lazarus mailing list
Still has Graphics32 and AGG library?

On Mon, Apr 17, 2017 at 7:53 PM, Mattias Gaertner via Lazarus <[hidden email]> wrote:
On Sun, 16 Apr 2017 02:53:00 +0300
Kostas Michalopoulos via Lazarus <[hidden email]> wrote:

>[...]
> 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

You can do it with IFDEFs.

> due to unforeseen bugs and with GTK2 being obsoleted in favor
> of GTK3 i am not sure if it is worth the effort.

A strong point. IMO you should better spend your time on improving the
LCL Gtk3 interface.

Mattias
--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus-ide.org/listinfo/lazarus


--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Lazarus] Alpha blending in GTK2 under Linux

Free Pascal - Lazarus mailing list
And, I think Lazarus more make / stable on win32 than linux, what you do on linux majorly doing command program / services

On Thu, Apr 20, 2017 at 2:01 PM, Joao Kho <[hidden email]> wrote:
Still has Graphics32 and AGG library?

On Mon, Apr 17, 2017 at 7:53 PM, Mattias Gaertner via Lazarus <[hidden email]> wrote:
On Sun, 16 Apr 2017 02:53:00 +0300
Kostas Michalopoulos via Lazarus <[hidden email]> wrote:

>[...]
> 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

You can do it with IFDEFs.

> due to unforeseen bugs and with GTK2 being obsoleted in favor
> of GTK3 i am not sure if it is worth the effort.

A strong point. IMO you should better spend your time on improving the
LCL Gtk3 interface.

Mattias
--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus-ide.org/listinfo/lazarus



--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus-ide.org/listinfo/lazarus
Loading...