Recent

Author Topic: TImage colors incorrect  (Read 3315 times)

Jonny

  • Jr. Member
  • **
  • Posts: 92
Re: TImage colors incorrect
« Reply #15 on: January 15, 2025, 04:59:58 pm »
Quote from: lainz
drop a TBCButton for example and change the color of normal state In the object inspector..

Using Lazarus to test BGRAControls/TBCButton (I usually code in a text editor), I see that colours are inverted in the object inspector.

Please see the attachment screenshot.

Now I am really, really confused. Any ideas at all? Why would everything else on my system be fine except for Lazarus and and executables created with it - both GTK2 and QT5? Should I be looking at dependencies - if so then which ones?


jamie

  • Hero Member
  • *****
  • Posts: 6798
Re: TImage colors incorrect
« Reply #16 on: January 15, 2025, 07:25:28 pm »
Hmm looks like a confusion between big and little endian
The only true wisdom is knowing you know nothing

dsiders

  • Hero Member
  • *****
  • Posts: 1337
Re: TImage colors incorrect
« Reply #17 on: January 15, 2025, 08:36:36 pm »
Hmm looks like a confusion between big and little endian

I'd be interested in the results when the metadarkstyle hacks are installed.

[Edit]
I meant: not installed.
« Last Edit: January 15, 2025, 10:47:23 pm by dsiders »
Preview the next Lazarus documentation release at: https://dsiders.gitlab.io/lazdocsnext

wp

  • Hero Member
  • *****
  • Posts: 12579
Re: TImage colors incorrect
« Reply #18 on: January 15, 2025, 08:45:54 pm »
Did you try to switch to another desktop theme?

Jonny

  • Jr. Member
  • **
  • Posts: 92
Re: TImage colors incorrect
« Reply #19 on: January 15, 2025, 08:51:56 pm »
Did you try to switch to another desktop theme?

Yes, changed theme, new user account, reset xfce4, updated graphics driver. Next step, reinstall OS, but not for a few days at least, so still open to suggestions.

Khrys

  • Full Member
  • ***
  • Posts: 147
Re: TImage colors incorrect
« Reply #20 on: January 16, 2025, 07:15:03 am »
Would you mind uploading  .bmp  bitmaps of both images (the old version without  TBGRABitmap)?

Code: Pascal  [Select][+][-]
  1. aImage.Picture.Bitmap.SaveToFile('timage.bmp');
  2. aBitmap.SaveToFile('tbitmap.bmp');

I can't speak for Linux-based graphics stacks, but at least on Windows the bitmap (or rather DIB - device independent bitmap, as they call it) should contain all the information the OS needs to properly render it (as far as I know). Thus it should be possible to check whether the issue lies with Lazarus or the OS - if it's a Lazarus problem, the bitmap data itself will be inconsistent (e.g. pixel format in header doesn't match pixel data).

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2622
Re: TImage colors incorrect
« Reply #21 on: January 16, 2025, 09:17:34 am »
If your lazarus show also the swapped colors, then there is something wrong with the internal (in lazarus) detection of the RGB components (as you can see in the rawimage description. Since both QT and GTK suffer from this, are you running Wayland or Xorg as display server ?

Using Lazarus to test BGRAControls/TBCButton (I usually code in a text editor), I see that colours are inverted in the object inspector.

Please see the attachment screenshot.

Now I am really, really confused. Any ideas at all? Why would everything else on my system be fine except for Lazarus and and executables created with it - both GTK2 and QT5? Should I be looking at dependencies - if so then which ones?
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

Thaddy

  • Hero Member
  • *****
  • Posts: 16520
  • Kallstadt seems a good place to evict Trump to.
Re: TImage colors incorrect
« Reply #22 on: January 16, 2025, 09:26:22 am »
Why not mention that BGRAControls already implies reverse order from RGBA?
But I am sure they don't want the Trumps back...

Jonny

  • Jr. Member
  • **
  • Posts: 92
Re: TImage colors incorrect
« Reply #23 on: January 17, 2025, 02:25:31 am »
Would you mind uploading  .bmp  bitmaps of both images (the old version without  TBGRABitmap)?

Code: Pascal  [Select][+][-]
  1. var
  2.   aImage: TImage;
  3. procedure TfrmMain.btnDrawClick(Sender: TObject);
  4. var
  5.    aBitmap: TBitmap;
  6. begin
  7.   aImage := TImage.Create(frmMain);
  8.   aImage.Parent := frmMain;
  9.   aImage.Width := 500;
  10.   aImage.Height := 500;
  11.   aBitmap := TBitmap.Create;
  12.   aBitmap.PixelFormat := pf32bit;
  13.   aBitmap.Width := 500;
  14.   aBitmap.Height := 500;
  15.   aBitmap.Canvas.Brush.Color := clRed;
  16.   aBitmap.Canvas.FillRect(0,0,500,500);
  17.   aBitmap.Canvas.Brush.Color := clBlue;
  18.   aBitmap.Canvas.FillRect(150,150,350,350);
  19.   aImage.Picture.Bitmap.Assign(aBitmap);
  20.   aImage.Picture.Bitmap.SaveToFile('/tmp/timage.bmp');
  21.   aBitmap.SaveToFile('/tmp/tbitmap.bmp');
  22. end;
  23.  

Drawn to screen = incorrect, export to bitmaps = correct.

Attached as zip archive due to attachment files size limits.

Jonny

  • Jr. Member
  • **
  • Posts: 92
Re: TImage colors incorrect
« Reply #24 on: January 17, 2025, 02:28:03 am »
Quote from: Marc
are you running Wayland or Xorg as display server ?

Code: [Select]
$ echo $XDG_SESSION_TYPE
x11

lainz

  • Hero Member
  • *****
  • Posts: 4685
  • Web, Desktop & Android developer
    • https://lainz.github.io/
Re: TImage colors incorrect
« Reply #25 on: January 17, 2025, 03:32:52 am »
Why not mention that BGRAControls already implies reverse order from RGBA?

It's just the name. It follows the OS specific way of handling rgba or bgra.

But that bug is in another level.

Edit : for example the order of the pixels should be reversed in some OS when using the webp.dll (I know because I coded the dll usage, then it was improved by circular).
« Last Edit: January 17, 2025, 03:37:48 am by lainz »

Mr.Madguy

  • Hero Member
  • *****
  • Posts: 864
Re: TImage colors incorrect
« Reply #26 on: January 17, 2025, 07:50:52 am »
Are you sure other colors in your system are correct? I had such problems with Android-x86 and VESA driver. Colors were wrong, if 32bit video mode wasn't chosen explicitly via vga= kernel parameter. But it had taken some time for me to notice, that I had wrong colors. Orange instead of blue for example.
Is it healthy for project not to have regular stable releases?
Just for fun: Code::Blocks, GCC 13 and DOS - is it possible?

Jonny

  • Jr. Member
  • **
  • Posts: 92
Re: TImage colors incorrect
« Reply #27 on: January 17, 2025, 01:10:45 pm »
Quote from: Mr.Madguy
Are you sure other colors in your system are correct?

Yes. See screenshot. Shows colour bars image in firefox web browser, colour boxes in lazpaint and my compiled app. In lazpaint you can see that the colour picker has selected red correctly.

wp

  • Hero Member
  • *****
  • Posts: 12579
Re: TImage colors incorrect
« Reply #28 on: January 17, 2025, 05:02:45 pm »
What happens when you draw on the form's Canvas directly, using its OnPaint event?
Code: Pascal  [Select][+][-]
  1. procedure TForm1.FormPaint(Sender: TObject);
  2. begin
  3.   Canvas.Brush.Color := clRed;
  4.   Canvas.FillRect(0,0,500,500);
  5.   Canvas.Brush.Color := clBlue;
  6.   Canvas.FillRect(150,150,350,350);
  7. end;
     

Jonny

  • Jr. Member
  • **
  • Posts: 92
Re: TImage colors incorrect
« Reply #29 on: January 18, 2025, 12:39:25 am »
Quote from: wp
What happens when you draw on the form's Canvas directly, using its OnPaint event?

Still no change...

 

TinyPortal © 2005-2018