advice on handling vector graphs, svg in my case lazarus / 39-Graphics ---------------------------------------------------------------------- Thaddy · 2025-04-15 07:30 What is the general opinion on the best way to handle vector graph formats like svg in FPC? Background is the cards discussion and I tested several solutions for svg formats, but I still have to render the individual cards from the cards tile in the background to reach acceptable performance on somewhat slower hardware. ---------------------------------------------------------------------- zamtmn · 2025-04-15 08:49 You'll have to write it all yourself. I have only general recommendations - OpenGL\Vulcan, tree-like data storage structures ---------------------------------------------------------------------- Thaddy · 2025-04-15 08:58 Not very helpful. Of course not, something like this snippet works: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 uses  BGRABitmap, BGRABitmapTypes; var  Bitmap: TBGRABitmap;begin  Bitmap := TBGRABitmap.Create;  try    Bitmap.LoadFromFile('example.svg'); // Load your SVG file    Bitmap.Draw(Canvas, 0, 0, True);    // Draw it on a canvas  finally    Bitmap.Free;  end;end;The question is if there are more efficient options? ---------------------------------------------------------------------- zamtmn · 2025-04-15 09:06 For money yes http://delphihtmlcomponents.com/FileBrowser.zip https://delphihtmlcomponents.com/MapView.zip ---------------------------------------------------------------------- Thaddy · 2025-04-15 11:14 OK, then I write it myself. Money is for difficult code, not for such things. ---------------------------------------------------------------------- zamtmn · 2025-04-15 11:17 I'm going to upset you - vector graphics are quite difficult. But in any case, we are waiting for your results. ---------------------------------------------------------------------- Lulu · 2025-04-15 18:37 Hi, I don't know if I understand well, but i post what I use to manage svg file with BGRABitmap. 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 // return a TBGRABitmap from an SVG file.// aWidth and aHeight = -1 => return an image with original size as described in svg.// aWidth and aHeight <> -1 => return a streched image that fit in the given rectangle (don't keep aspect ratio).// Only aImageWidth = '-1' => returned image width is computed from aHeight to keep aspect ratio.// Only aImageHeight = '-1' => returned image height is computed from aWidth to keep aspect ratio.// the drawing is centered in the returned bitmapfunction LoadBitmapFromSVG(const aSVGFilename: string; aWidth, aHeight: integer): TBGRABitmap;var svg: TBGRASVG;  FWHFactor, cw, ch: single;begin  Result := NIL;  svg := TBGRASVG.Create( aSVGFileName );  try    cw := svg.WidthAsPixel;    ch := svg.HeightAsPixel;    FWHFactor := cw/ch;     if (aWidth > -1) and (aHeight > -1) then begin      // return a streched image that fit in the given rectangle (don't keep aspect ratio).      Result := TBGRABitmap.Create(aWidth, aHeight, BGRAPixelTransparent);      svg.StretchDraw(Result.Canvas2D, 0, 0, aWidth, aHeight, False);      exit;    end;     if (aWidth = -1) and (aHeight = -1) then begin      // return an image with original size as described in svg.      aWidth := Round(cw);      aHeight := Round(ch);    end    else    if aWidth = -1      then aWidth := round(aHeight*FWHFactor) // compute width to keep aspect ratio    else    if aHeight = -1      then aHeight := round(aWidth/FWHFactor); // compute height to keep aspect ratio     Result := TBGRABitmap.Create(aWidth, aHeight, BGRAPixelTransparent);    svg.StretchDraw(Result.Canvas2D, 0, 0, aWidth, aHeight, False);  finally    svg.Free;  end;end; ---------------------------------------------------------------------- Thaddy · 2025-04-16 08:07 @Lulu That is very helpful, thanks a lot! @zamtmn I am a retired cs (erratic but knowledgable), I can do that.