BAGRABitmap load images proportions [SOLVED ] lazarus / 39-Graphics ---------------------------------------------------------------------- Pe3s · 2024-06-22 12:23 Hello, how can I load an image while maintaining its proportions to fit the window? ---------------------------------------------------------------------- Handoko · 2024-06-22 13:58 Maybe this can help: https://forum.lazarus.freepascal.org/index.php/topic,43823.msg307918.h tml#msg307918 ---------------------------------------------------------------------- Pe3s · 2024-06-23 09:59 how to solve the problem, when scaling the window the image disappears, the invalidate and repaint instructions are not available ---------------------------------------------------------------------- Roland57 · 2024-06-24 04:21 Hello. The same question was asked on the French-speaking Lazarus forum some days ago. I attach below the provided solution. Hope that you can adapt it to your needs. Best regards. ---------------------------------------------------------------------- Pe3s · 2024-06-24 10:22 Hello, where did I make a mistake that the image is not displayed when it is opened? 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 private    image: TBGRABitmap;    imageLoaded: Boolean;   public   end; var  Form1: TForm1; implementation {$R *.lfm} { TForm1 } procedure TForm1.FormDestroy(Sender: TObject);begin  image.Free;end; procedure TForm1.FormCreate(Sender: TObject);begin  imageloaded := False;  image := TBGRABitmap.Create;end; procedure TForm1.Panel1Paint(Sender: TObject);var  image2: TBGRABitmap;  hw, wh, w, h, x, y: Integer;begin  if not(imageLoaded) then Exit;   hw := image.Height * Panel1.ClientWidth;  wh := image.Width * Panel1.ClientHeight;   if wh > hw then  begin    w := Panel1.ClientWidth;    h := hw div image.Width;  end else  begin    h := Panel1.ClientHeight;    w := wh div image.Height;  end;  x := (Panel1.ClientWidth - w) div 2;  y := (Panel1.ClientHeight - h) div 2;   image2 := image.Resample(w, h) as TBGRABitmap;  image2.Draw(Panel1.Canvas, x, y, True);  image2.Free;end; procedure TForm1.ToolButton1Click(Sender: TObject);begin  if OpenPictureDialog1.Execute then  begin    image.LoadFromFile(OpenPictureDialog1.FileName);    imageLoaded:= True;  end;end; ---------------------------------------------------------------------- Handoko · 2024-06-24 12:23 Maybe you need to put this:   Panel1.Invalidate; between line #61 and #62. ---------------------------------------------------------------------- Dzandaa · 2024-06-25 09:11 Hi @Pe3s I don't know if this is what you need, but here is a template that create a resizable Form with BGRAPicture Load and save with Zoom and Pan. You need the BGRABitmap Pack. https://wiki.freepascal.org/Project_Templates Extract from the .zip and put the BGRAPicture in you Template Directory. You'll have a new entry in File->New project from template->BGRA Picture Form Fill the Dialog box with the name of your program, Form and Unit and select where you want to create your new program. Feel free to modify. B-> ---------------------------------------------------------------------- Pe3s · 2024-06-26 19:30 Thank you