Recent

Author Topic: GTK3 distorts colors?  (Read 1556 times)

wschulte

  • New Member
  • *
  • Posts: 39
GTK3 distorts colors?
« on: October 31, 2022, 06:36:32 am »
When using the LoadFromFile method from TPicture I get totally wrong colors when compiling with the GTK3 widget-set. See gtk3.jpg. When compiling for GTK2 is displays normal (gtk2.jpg).
What am I doing wrong ?

Attached the sources in problemsrc.zip.

BTW. also in QT5 the picture displays normal. It is only in GTK3 that the colors get weird.

FPC 3.2.2
Lazarus 2.2.2.0
libgtk-3.so.0.2404.16
Distro: Linux Mint 20.3 Una

bytebites

  • Hero Member
  • *****
  • Posts: 789
Re: GTK3 distorts colors?
« Reply #1 on: October 31, 2022, 07:32:37 am »
widgets_unit.pas" was not found

dseligo

  • Hero Member
  • *****
  • Posts: 1686
Re: GTK3 distorts colors?
« Reply #2 on: October 31, 2022, 07:45:23 am »
It looks like red and blue are mutally changed.

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: GTK3 distorts colors?
« Reply #3 on: October 31, 2022, 12:25:16 pm »

Zoran

  • Hero Member
  • *****
  • Posts: 1988
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: GTK3 distorts colors?
« Reply #4 on: October 31, 2022, 12:44:57 pm »
Swan, ZX Spectrum emulator https://github.com/zoran-vucenovic/swan

Thaddy

  • Hero Member
  • *****
  • Posts: 19275
  • Glad to be alive.
Re: GTK3 distorts colors?
« Reply #5 on: October 31, 2022, 01:01:32 pm »
Indeed, this is not related to FPC or Lazarus.
objects are fine constructs. You can even initialize them with constructors.

wschulte

  • New Member
  • *
  • Posts: 39
Re: GTK3 distorts colors?
« Reply #6 on: November 01, 2022, 06:15:23 am »
widgets_unit.pas" was not found

Sorry,  :( forgot those 2. They are in this attachment.

wschulte

  • New Member
  • *
  • Posts: 39
Re: GTK3 distorts colors?
« Reply #7 on: November 01, 2022, 06:30:41 am »
Indeed, this is not related to FPC or Lazarus.

When searching for my problem, I found indeed another case of swapped channels in GTK4, but it was related to PNG (https://gitlab.gnome.org/GNOME/gtk/-/issues/4616). Somehow I thought it unrelated to my issue, but now .. it looks the same. Though I find it peculiar that I am the first one to stumble over this in Lazarus. So I guess also GTK4 has the same issue.

wschulte

  • New Member
  • *
  • Posts: 39
Re: GTK3 distorts colors?
« Reply #8 on: November 01, 2022, 10:14:10 am »
 :o
Did some further research with the same program as from post #6 and it gets a bit confusing. I tried to load some different graphical formats from the same picture, converted with GIMP to other formats. In GTK2 all pictures display normal, but on GTK3:
  • .jpg gets displayed distorted, probably the blue and red channel are swapped
  • .png either gets displayed distorted as the .jpg or not displayed at all. Looks like it depends on the size of the picture: small ones were displayed, albeit distorted, bigger ones (like my trial pic) didn't get displayed at all without any warning.
  • .ico gets displayed okay !
  • .bmp becomes a totally weird picture on display

I am a complete layman when it comes to graphical formats so I attach the base picture here (poep.jpg), which I used to produce the other formats.

Perhaps important too: when I run the program in with GTK3 it produces a huge amount of output to stdout of what looks like debug messages:
Code: Pascal  [Select][+][-]
  1. Focused
  2. GtkEventResize: Form1:TForm1 Send=0 x=757 y=365 w=200 h=200
  3. other changes state=00015480 mask=00015400
  4. GtkEventResize: Form1:TForm1 Send=1 x=757 y=365 w=200 h=200
  5. GtkEventResize: Form1:TForm1 Send=1 x=757 y=365 w=200 h=200
  6. GtkEventResize: Form1:TForm1 Send=0 x=757 y=365 w=309 h=362
  7. GetStyleWithName creating style widget memo
  8. GtkEventResize: Form1:TForm1 Send=1 x=758 y=365 w=309 h=362
  9. GtkEventResize: Form1:TForm1 Send=1 x=758 y=366 w=309 h=362
  10. GtkEventResize: Form1:TForm1 Send=1 x=758 y=367 w=309 h=362
  11. GtkEventResize: Form1:TForm1 Send=1 x=758 y=368 w=309 h=362
  12. GtkEventResize: Form1:TForm1 Send=1 x=758 y=369 w=309 h=362
  13.  

Do I have the right GTK3 library (3.24.0 in the repository) ? I downloaded it from the standard repository of Mint ...
« Last Edit: November 01, 2022, 10:17:58 am by wschulte »

AmatCoder

  • Jr. Member
  • **
  • Posts: 79
    • My site
Re: GTK3 distorts colors?
« Reply #9 on: November 01, 2022, 11:54:55 am »
When using the LoadFromFile method from TPicture I get totally wrong colors when compiling with the GTK3 widget-set. See gtk3.jpg. When compiling for GTK2 is displays normal (gtk2.jpg).
What am I doing wrong ?

You are doing nothing wrong. Just the LCL-Gtk3 implementation from Lazarus is buggy and/or incomplete.

This confuses you because you are thinking: "...if works with Gtk2 then it should work with Gtk3..."

But they are completely different for drawing:
Gtk2 uses the old GDK drawing API.
Gtk3 uses Cairo.

Edit: A quick example. No support for RGB formats here.
« Last Edit: November 01, 2022, 12:07:17 pm by AmatCoder »

 

TinyPortal © 2005-2018