EtheaDev / SVGIconImageList

Three engines to render SVG (Delphi Image32, Skia4Delphi, Direct2D wrapper) and four components to simplify use of SVG images (resize, fixedcolor, grayscale...)
Apache License 2.0
321 stars 93 forks source link

Runtime error using TSVGIconImage control in a 64-bit test project #267

Closed VladimirMishka closed 8 months ago

VladimirMishka commented 8 months ago

I am using Windows 11 with Delphi 11.3 Alexandria Community Edition. I would like to use the TSVGIconImage control in a 64-bit Windows app by live binding the TSVGIconImage control to a TMemo (which will contain the SVG XML text). I am testing this idea with a simple project that contains a TSVGIconImage control, a TMemo, and a TButton.

The app runs as expected a 32-bit Windows application, as follows: (1) Run the app; (2) copy and paste the example chessboard_SVG,txt into the Memo (in the final app the text will be generated from a python script to the TMemo using the python-chess library so I don't want to load the text from a file), and (3) Press the Button (which doesn't contain any code, it just shifts the focus from the Memo). The chessboard appears in the SVGIconImage control.

When I try to run the app as a 64-bit Windows application, it compiles, but there is an immediate runtime Access violation and, obviously, the form does not appear.

I am thinking that the problem may be that the default Factory is not compatible with a 64-bit application,. It doesn't matter to me what factory I use. I also don't know which one to choose. I tried using "SetGlobalSVGFactory(GetSkiaSVGFactory);" in an initialize section within the .pas file and that didn't compile (both SetGlobalSVGFactory and GetSkiaSVGFactory were reported as being undefined). Perhaps I am missing something in the uses section to do it that way. Although I am a relatively experienced Delphi programmer, I have never used Conditional Defines in my applications and I don't understand how to try that approach.

Please tell me how to get this simple application running as a 64-bit Windows application.

I have attached my sample SVG text and what I hope are sufficient project files.

chessboard_SVG.txt Test_SVG_Chessboard.zip

Thank you.

carloBarazzetta commented 8 months ago

I've tested the demo also with 64bit platforms and works fine for me, without AV. Please check you have the latest patch for Delphi 11.3, and the lastest version of this Projects. The native Factory Image32 is fully 32 and 64 bit compliant, and is the best factory you can use (see the SvgViewer.exe demo as explained into wiki section). I've also removed Vcl.Skia and System.Skia from your project, because skia is not necessary. image In the title of the form you can see "64 bit" because I've added to your test:

procedure TForm1.FormCreate(Sender: TObject);
begin
  {$IFDEF win64}
  Caption := '64 bit';
  {$ELSE}
  Caption := '32 bit';
  {$ENDIF}
end;