Assigning a TBitmap to a TBitmap32 lazarus / 39-Graphics ---------------------------------------------------------------------- niotronic · 2021-05-16 10:38 Hi, I'm using the TImage32, which is part of the graphics32 library and I'm trying to assign a TBitmap to the TImage32.Bitmap, which always results in a totally black screen. On the canvas of the TBitmap32 (=TImage32.Bitmap) however I can draw lines and fill rects without problems. If I assign the TBitmap to a TImage.Bitmap (the standard TImage) the bitmap contained in the original Bitmap is shown correctly. So it's obviously a problem with the TImage32.Bitmap not accepting the standard TBitmap contents ? Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   FImage:=T Image32.Create(self);FImage.Parent:=self;FImage.Align:=alClient;FImage .Scale:=1; FImage.Bitmap.Assign(Bitmap);    //shows up as a black screenFImage.Bitmap.LoadFromFile('/home/arm1/Dokumente/Linux NIO Analyzer  V2-90 - FPC/Graphics/TDIBackground.bmp');    //also shows up as a black screenFImage.Bitmap.Changed; FImage.Bitmap.Clear(cllime);   //this is shown correctlyFImage.Bitmap.Line(0, 0, 150, 150, clblack, TRUE);  //shown correctly   Any ideas, what might cause the TImage32 to show any Bitmap assigned as a black screen ? Best regards KL ---------------------------------------------------------------------- winni · 2021-05-16 11:11 Hi! a) Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i FImage.LoadFromFile('/home/....'); b) There are a lot of examples in Code: Text  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i ct4laz/pl_examples/pl_graphics32/ Winni ---------------------------------------------------------------------- niotronic · 2021-05-16 17:57 Dear Winni, your suggestion a) is unfortunately not applicable for me since I'm loading the image out of a database via a TStream. The same code works pretty fine on DELPHI, but when I compile on Lazarus, the TImage32 always shows a black screen after a calling: FImage.Assign(MyBitmap); When I for test purposes only assign MyBitmap to a standard TImage it correctly shows the contents of MyBitmap, which prooves that MyBitmap contains correct data. On the otherhand I can draw on the TImage32 canvas whatever I want and it shows it correctly. So the problem must be anywhere in the FImage.Assign(myBitmap)  which obviously cannot deal with the data contained in Mybitmap. Just to remember: This is working pretty fine on DELPHI... I'm using Lazarus 1.8.4 and the graphics32 version is 1.9 Any call of FImage.Changed, FImage.ForceFullInvalidate etc. doesn't make it show the contents of MyBitmap... Best regards,  KL ---------------------------------------------------------------------- engkin · 2021-05-16 18:51 The following code works correctly here: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.Button1Click(Sender: TObject);var  FImage: TImage32;  Bitmap: T Bitmap;begin FImage:=TImage32.Create(self); FImage.Parent:=self; FImag e.Align:=alClient; FImage.Scale:=1;  Bitmap := TBitmap.Create; Bitmap. LoadFromFile('c:\Path\To\Some.bmp'); FImage.Bitmap.Assign(Bitmap);    //Works  I am using Win32, Laz2.0.10, GR32 2.0 ---------------------------------------------------------------------- niotronic · 2021-05-20 16:29 I tried now to use the latest version of Lazarus (2.1) and of the graphics32 (V1.9 fixed) but unfortunately there hasn't anything changed. Calling the Assign procedure of TImage32 with a TBitmap as Parameter still results in a black screen - However directly drawing on the Bitmap of the TImage32 works perfectly. I wrote a small test program which shows this problem... The whole project is attached. Attached are also screenshots, one them shows the black screen after pressing "Assign bitmap" - The standard TImage shows the picture correctly, the TImage32 only shows a black screen. The results of clicking on "Draw on TImage32.Bitmap" is shown in the second picture... Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i unit Unit1; {$mode objfpc}{$H+} interface uses  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, GR32_Image,  ExtCtrls; type   { TForm1 }   TForm1 = class(TForm)    Button1: TButton;    Button2: TButton;    Image1: TImage;    Panel1: TPanel;  procedure Button1Click(Sender: TObject);    procedure Button2Click(Sender: TObject);    procedure FormCreate(Sender: TObject);    procedure FormDestroy(Sender: TObject);  private    FImage32: TImage32;  public   end; var  Form1: TForm1; implementation {$R *.lfm} { TForm1 } procedure TForm1.Button1Click(Sender: TObject);var ABitmap: TBitmap;beginABitmap :=TBitmap.create;tryABitmap.LoadFromFile('/home/arm1/Downloads/Floorpl an2.bmp');FImage32.Bitmap.Assign(ABitmap);Image1.Picture.Bitmap.Assign (ABitmap);finally  ABitmap.Free;end; //FImage32.Bitmap.LoadFromFile('/ home/arm1/Downloads/Floorplan2.bmp'); end; procedure TForm1.Button2Click(Sender: TObject);begin  FImage32.Bitmap.Clear(cllime);  FImage32.Bitmap.Line(10, 10, 200, 200, clblack);  FImage32.Bitmap.FillRect(140, 40, 180, 80, clblue);end; procedure TForm1.FormCreate(Sender: TObject);begin FImage 32:=TImage32.Create(self); FImage32.Align:=alClient; FImage32.Parent:= self;end; procedure TForm1.FormDestroy(Sender: TObject);begin  FImage32.Free;end; end. ---------------------------------------------------------------------- niotronic · 2021-05-20 16:40 Sorry - I forgot to say that the black screen only shows up on Linux X86-64 and Lazarus. The same source code works fine on Windows / DELPHI 10.3... ---------------------------------------------------------------------- winni · 2021-05-20 17:09 Hi! Have a look at https://forum.lazarus.freepascal.org/index.php?topic=49913.0 Winni ---------------------------------------------------------------------- niotronic · 2021-05-21 07:46 Dear Winni, the problem discussed at https://forum.lazarus.freepascal.org/index.php?topic=49913.0 is talking about the same problem, but the solutions provided is using a TImage which a TBitmap32 is assigned to. It's not shoing a solutions to the problem with TImage32.bitmap.Assign(Mybitmap). However I need to use a TImage32 and I'm assining a standard TBitmap. I did some more tests: Even if I'm using Timage32.Bitmap.LoadFromFile it's only showing a black screen... ---------------------------------------------------------------------- niotronic · 2021-05-21 10:31 Addendum: It seems to be a problem with the bitmap format. When I manually draw something on the TImage32.Bitmap and save this to a *.BMP file I can later on read and show the contents of this file. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   FImage:=TImage32.Create(self);  FImage.Parent:=self;  FImage.Align:=alClient;  FImage.ScaleMode:=smStretch;  // FImage.Bitmap.Assign(Bitmap);   FImage.Bitmap.SetSize(600, 400);  FImage.Bitmap.Clear(cllime32);  FImage.bitmap.FillRect(10, 10, 60, 60, clblue32);  FImage.Bitmap.Line(20, 50, 40, 180, clyellow32);  FImage.Bitmap.FillRect(120, 120, 160, 160, clgreen32);  FImage.Bitmap.SaveToFile('/home/arm3/Dokumente/Test.bmp', FALSE);   FImage.Bitmap.Clear;  FImage.Bitmap.LoadFromFile('/home/arm3/Dokumente/Test.bmp');  However it obviously swaps the red and blue color channels. Anything that was red before saving to a  *.BMP shows up in blue, anything that was blue shows up in red when it's read from the file... Does the Timage32.Bitmap use a different internal format ? ---------------------------------------------------------------------- winni · 2021-05-21 11:32 Hi! As I told you above for loadFromFile do the same with SaveToFile: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i var fImage : TImage32; .....fImage.LoadFromFile;...fImage.SaveToFile;  If you don't read the answers then you will always ask the same questions. Winni ---------------------------------------------------------------------- niotronic · 2021-05-21 14:20 Dear Winni, I think we are not talking about the same thing. First - the original problem was to Assign a bitmap to Timage32.Bitmap This is working perfectly on WIN32 with DELPHI. When I'm running the same code on X86 Linux with Lazarus its resulting in a black screen. Then started (only to investigate the problem further) with the LoadfromFile and SavetoFile functions: Result: TImage32  does not show a picture when I call TImage32.Bitmap.Loadfrom file - it's always a black screen. When I draw something on the TImage32 and Save it to a file then it can be read and shows correctly when I read it again with LoadFromFile So whats different from any arbitrary *.BMP file compared the *.BMP files which were saved  with the TImage32.SaveToFile procedure ? But I cannot use LoadfromFile since my picture are read from a Database via a TStream object. So the one and only question is: How to assign a TBitmap to the Bitmap32 of a TImage32 and make the Timage32 show the picture On WIN32 / DELPHI - works like a charm On X86 Linux /Lazarus - always shows a black screen Best regards, KL ---------------------------------------------------------------------- lucamar · 2021-05-21 14:46 Note that wherever you can SaveTo-/LoadFromFile, there is normally also a SaveTo-/LoadFromStream (which in fact is where saving to and loading from file is actually done, using a TFileStream) so you can omit all the file shenanigans and use the stream read from the database directly. Though I'm noot sure whether that will work or not, seeing how it's failing with a file. ---------------------------------------------------------------------- winni · 2021-05-21 15:40 Hi! I don't get the reason for assigning TBitmap <--> TBitmap32 TBitmap32 is able to handle Transparency. TBitmap cannot do that. So whatever you do - you loose the transparency. Transparency is one of the jobs TBitmap32 can do in opposite to TBitmap. You cannot assign a cow and hope that it is now a horse. Winni ---------------------------------------------------------------------- niotronic · 2021-05-21 15:59 Dear Winni, I'm loading a standard bitmap file out of the database and I want to use this bitmap as the background in a TImage32. I do not want the background picture to be transparent but all the Timager32.layers which I want to show in front of the Background picture. The problem is that obvisouly the graphics32 library is working as expected on Win32 / DELPHI - I have been using it for years now, but when I started  using it on Linux / Lazarus the TImage32 always shows a black screen - No matter which way I try to load a picture (Assign from a Bitmap, LoadfromFile, Loadfromstream etc. ) it always shows a black screen, and when I manually draw something on the Timage32 (by the use of Fillrect, line arc procedures etc.),  save the Timage32 to a file (TImage32.Bitmap.SavetoFile) and then load it again (TImage32.Bitmap.Loadfromfile) the blue and the red color channels are swapped (a red rectangle before saving show up in blue after Loadfromfile and vice versa) This is definitely not happening on WIN32 / DELPHI. I haven't found out yet in which library it's not implemented correctly on the Lazarus / Linux / graphics32, but I will continue to investigate what's causing this malfunctioning with Lazarus / Linux... ---------------------------------------------------------------------- wp · 2021-05-21 16:09 Can you post a small compilable project along with an image file to demonstrate the issue? It's always better to have some food for the compiler than having to imagine where the issue is. ---------------------------------------------------------------------- engkin · 2021-05-21 16:31 First of all, can you use the latest version of Graphics32 version 2.0? It is possible that, after you use LoadFromFile, the result is black. For instance: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TCustomBitmap32.LoadFromFile(const FileName: string);..    if (LoadFromBMPStream(FileStream, FileStream.Size)) then    begin      Changed;      exit;    end;  LoadFromBMPStream has to return true. Of course in this same procedure it has more code: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i {$ifndef COMPILERRX2_UP}  // Fallback to determing file format based on file type for Delphi 10.1. and older  // See issue #145  P := TPicture.Create;  try    P.LoadFromFile(FileName);    Assign(P);  finally    P.Free;  end;{$endif COMPILERRX2_UP} The logical thing to do is to debug the code. It might be a missing call to "changed": Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   FImage.Bitmap.changed; Or you are using a WS that is not supported or has a bug. Are you using GTK, GTK2, or CustomDrawn? ---------------------------------------------------------------------- niotronic · 2021-05-22 05:47 Please find attached the DELPHI Project ---------------------------------------------------------------------- niotronic · 2021-05-22 05:48 This is the Lazarus Project ---------------------------------------------------------------------- niotronic · 2021-05-22 05:59 Would you like to tell me where to get Version 2.0 ? Github and Sourceforge only offer V1.9.1 fixes ? BR KL ---------------------------------------------------------------------- engkin · 2021-05-22 12:59 Ah, I see. I am using the trunk: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i const  Graphics32Version = '2.0.0 alpha'; Sorry ---------------------------------------------------------------------- wp · 2021-05-22 14:12 Starting with  Windows 10, 64 bit, Laz-trunk/FPC3.2.0 (32 bit): Cloned the GR32 git repository (https://github.com/graphics32/graphics32, master branch). There are two Lazarus packages, a runtime and a designtime package. Compiled the runtime package --> fine. The designtime package is sett up to be installed only (not compiled), thus I rebuilt the IDE --> fails due to "Can't find GR32_Blend used by GR32"; seems to me that this is because the authors put both runtime and designtime units into the same folder... It took me some time until I found a way how to rebuild the IDE again, i forgot the steps. Fortunately your project creates the TImage32 at runtime, and thus installation is not needed. But your package requirements contain a "GR32_L" package, rather than the GR32_Lazarus of the github package. Replaced it, your program compiles and runs. As expected, of course. Went on to a VM with Ubuntu 20.04/64 bit. Cloned the repo again. Now even the runtime package refuses to compile, in some assembler part in procedure BlendMems_SS2 in unit GR32_BlendSSE2.... This issue was already posted in https://forum.lazarus.freepascal.org/index.php?topic=53095.0. Giving up on the master branch, I moved on to the version distributed by OPM: the package now is the Pilot-Logic version, named pl_Graphics32. Compilation fails due to an error in  "Canvas.Brush.Color := clButton" -- this is due to the unknown clButton identifier. I wonder how anybody could compile this... Replacing this by clBtnFace (and, further down the same procedure, the clDisabledButtonText by clGray, and the clButtonText by clWindowText). Next issue is usage of unit Qt5Objects in GR32_Backends_LCL_Qt5 which does not exist, only a QtObjects (my IDE is compiled for qt5 here). Removing the "5" finally makes the package compile. Testing your program I do see the black area where the bitmap appears on Windows - so, I confirm the issue. Switching to gtk2 widgetset - same issue. Going to a notebook which has a 32 bit Linux. Now even the git master version compiles (after making the color changes). But in your demo I still see the black area where the Image32 is supposed to be. Giving up for the moment. To summarize, I confirm the problem that you reported, but it seems to be a Linux issue in general, not just a 64-bit Linux issue as you write. And it is an issue which exists aöready in the github master version, not only in the PilotLogic version. It is disappointing to see that the great Graphics32 package essentially is still Windows-only. Compilation issues with undefined identifiers remaining unnoticed indicates that there is little or no maintainance for non-Windows platforms. You should file a bug report on the GR32 github. But I have little hope that this bug will be fixed soon. ---------------------------------------------------------------------- att2 · 2021-05-24 10:41 I can confirm the issue on a Linux Mint 19 Tara VM with Lazarus 1.8.4 and FPC 3.2.0b1. When I use the Online Package Manager and when I compile the "pl_Graphics32" libaray, I get the compiling error : QuoteCompile package pl_Graphics32 7.2.1: Exit code 256, Errors: 1, Hints: 2 Hint: Start of reading config file /home/arm1/fpc2/fpc/bin/x86_64-linux/fpc.cfg Hint: End of reading config file /home/arm1/fpc2/fpc/bin/x86_64-linux/fpc.cfg Verbose: Free Pascal Compiler version 3.2.0-beta-r20:39835 [2018/10/17] for aarch64 Verbose: Copyright (c) 1993-2018 by Florian Klaempfl and others Verbose: Target OS: Linux for AArch64 Verbose: Compiling pl_graphics32.pas Verbose: Compiling ./source/AllGR32Register.pas Verbose: Compiling ./source/GR32.pas /home/arm1/fpc2/config_lazarus/onlinepackagemanager/packages/ct4laz/pl _components/pl_graphics32/source/GR32.inc(48,6) Error: Illegal assembler style specified "INTEL" Verbose: Compiling ./source/GR32_AllStrings.pas /home/arm1/fpc2/config_lazarus/onlinepackagemanager/packages/ct4laz/pl _components/pl_graphics32/source/GR32_AllStrings.pas(82,1) Verbose: There were 1 errors compiling module, stopping Verbose: Compilation aborted Verbose: /home/arm1/fpc2/fpc/bin/x86_64-linux/ppcrossa64 returned an error exitcode I am trying to cross-compile for aarch64 in this case. So it seems if I have a project that cross-compiles for a Raspberry-Pi-Clone, I simply cannot do this? ---------------------------------------------------------------------- wp · 2021-05-24 11:06 It is my impression that Graphics32 works correctly only on Windows, at least unless there is nobody who really takes care of it on other platforms. ---------------------------------------------------------------------- Handoko · 2021-05-24 12:28 I just tested Graphics32 on Linux. I opened some of the examples, all were buggy on Ubuntu Mate 64-bit. ---------------------------------------------------------------------- winni · 2021-05-24 13:36 Use BGRAbitmap and BGRAcontrols. Errors are seldom and quick solved. Winni