Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2017-04

Alpha blending in GTK2 under Linux

7 messages · 5 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Valdas Jankūnas

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

Reply by email

Marc Weustink
to Valdas Jankūnas
"Valdas Jankūnas wrote 9 lines
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

Reply by email

Valdas Jankūnas
to Marc Weustink

2017.04.14 22:02, Marc Weustink via Lazarus rašė:

Show quoted text 8 lines
> 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

Reply by email

Kostas Michalopoulos
to Valdas Jankūnas

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 <

Show quoted text 31 lines
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 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>

Reply by email

Mattias Gaertner
to Kostas Michalopoulos

On Sun, 16 Apr 2017 02:53:00 +0300

Kostas Michalopoulos 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

Reply by email

Joao Kho
to Mattias Gaertner

Still has Graphics32 and AGG library?

On Mon, Apr 17, 2017 at 7:53 PM, Mattias Gaertner via Lazarus <

Show quoted text 25 lines
wrote: On Sun, 16 Apr 2017 02:53:00 +0300 Kostas Michalopoulos via Lazarus 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 http://lists.lazarus-ide.org/listinfo/lazarus

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20170420/a5bf0f02/attachment.html>

Reply by email

Joao Kho
to Joao Kho

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

Joao Kho wrote 31 lines
Still has Graphics32 and AGG library? On Mon, Apr 17, 2017 at 7:53 PM, Mattias Gaertner via Lazarus < > wrote: > On Sun, 16 Apr 2017 02:53:00 +0300 > Kostas Michalopoulos via Lazarus 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 > > http://lists.lazarus-ide.org/listinfo/lazarus >

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20170420/8a57df70/attachment.html>

Reply by email