[Solved] How can I use TBGRALayeredBitmap with multiple images in real time? lazarus / 39-Graphics ---------------------------------------------------------------------- loaded · 2020-03-06 06:54 Hi All I have 3 different image objects with a resolution of 1920x1080, I can layer them and at the same time, I can display each image with a transparency value specific to the following 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 unit Unit1; {$mode objfpc}{$H+} interface uses  bgrabitmap, BGRABitmapTypes,BGRALayers,  Classes, SysUtils, Forms, Controls, Graphics,  Dialogs, StdCtrls, ExtCtrls, Menus, Buttons, ComCtrls; type   { TForm1 }   TForm1 = class(TForm)    BitBtn1: TBitBtn;    Image1: TImage;    Image2: TImage;    Image3: TImage;    Render: TImage;    TrackBar1: TTrackBar;    TrackBar2: TTrackBar;    TrackBar3: TTrackBar;    procedure BitBtn1Click(Sender: TObject);    procedure TrackBar1Change(Sender: TObject);    function blayers:Boolean;   private   public   end; var  Form1: TForm1;implementation {$R *.lfm}  { TForm1 }  function btobgra(bt:TBitmap):Tbgrabitmap;var  br:Tbgrabitmap;begin  result:=Tbgrabitmap.Create(bt,false);end; function  TForm1.blayers:Boolean;var layer:TBGRALayeredBitmap;begin    try    render.Picture:=nil;    render.canvas.Brush.Color:=clWhite;    render.canvas.FillRect(render.Canvas.ClipRect);    layer:=TBGRALayeredBitmap.Create(render.Width,render.Height);    layer.AddLayer(btobgra(Image1.Picture.Bitmap),TrackBar1.Position);    layer.AddLayer(btobgra(Image2.Picture.Bitmap),TrackBar2.Position);    layer.AddLayer(btobgra(Image3.Picture.Bitmap),TrackBar3.Position);    layer.Draw(Render.canvas,0,0);    layer.Free;    result:=true;    except    result:=false;    end;end;  procedure TForm1.BitBtn1Click(Sender: TObject); var   cron:cardinal;begin  cron:=GetTickCount64;  if blayers then  TButton(sender).Caption:=float tostr((GetTickCount64-cron)/1000);end; procedure TForm1.TrackBar1Change(Sender: TObject); var   cron:cardinal;begin  cron:=GetTickCount64;  if blayers then  Form1.Caption:=floattostr((GetTickCount64-cron)/1000);end;  end.    I am making possible changes within the trackbar onchange procedure. In the meantime, there is a delay in imaging. What's more, the white screen issue arises in continuous use. Then I have to close the program. I would gladly listen if there are any suggestions and suggestions to be able to do the above process without any problem simultaneously with the change of trackbar position. Respects. ---------------------------------------------------------------------- circular · 2020-03-06 09:46 Hello I suppose your code creates the layered image every time it is displayed. You can instead create it once and then set the opacity on the fly with LayerOpacity property. Also use AddOwnedLayer instead of AddLayer to avoid memory leak. Regards ---------------------------------------------------------------------- loaded · 2020-03-06 11:31 Mr. Circular , You’re a great help, i must say. You made my job very easy. I would like to ask one more thing that there may be another more useful thing to learn; Is there any alternative method instead of the draw method? Regards. ---------------------------------------------------------------------- circular · 2020-03-06 11:37 You're welcome. Instead of Draw you can call ComputeFlatImage to get the resulting image. What else would you like to do? ---------------------------------------------------------------------- loaded · 2020-03-06 12:18 It was good that I learned the ComputeFlatImage method. Quote from: circular on March 06, 2020, 12:37:27 pmWhat else would you like to do? What more, thanks to you, I solved my problem. ---------------------------------------------------------------------- circular · 2020-03-06 19:36 Ok