I need help with BeginUpdate and EndUpdate lazarus / 39-Graphics ---------------------------------------------------------------------- stem · 2020-02-09 14:25 Hi, I have a procedure which gets a TImage object (myImage) as parameter and calculates some colors. The colors get stored with 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 myImage.canvas.Pixels[col, row] := myColor; Everything works fine. To speed up the calculation, I've put everything in try and finally together with BeginUpdate() and EndUpdate(): 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 try  myImage.Picture.Bitmap.BeginUpdate();  ... (my code)finally  myImage.Picture.Bitmap.EndUpdate();end;  Unfortunately this stops painting the image completely. If I comment out the two lines with BeginUpdate() and EndUpdate(), everything works again. What am I doing wrong? Thank you. stem ---------------------------------------------------------------------- circular · 2020-02-09 14:40 myImage.Canvas is the surface of the control, which gets replaced on repaint. If you want the pixels to stay in the image you would rather use myImage.Picture.Bitmap.Canvas. Note that the Bitmap size must be set up correctly. ---------------------------------------------------------------------- stem · 2020-02-09 15:09 Quote from: circular on February 09, 2020, 03:40:22 pmIf you want the pixels to stay in the image you would rather use myImage.Picture.Bitmap.Canvas. Note that the Bitmap size must be set up correctly. I replaced my code the way you suggested. The image gets correctly painted with myImage.Picture.Bitmap.Canvas, but only (again) if I comment out the two lines with BeginUpdate() and EndUpdate() ... If the two lines are active, the image is completely black. stem ---------------------------------------------------------------------- balazsszekely · 2020-02-09 16:41 Set myimage width and height to 500, then: 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);begin  with MyImage.Picture.Bitmap do  begin    SetSize(500, 500);    BeginUpdate(True);    try      Canvas.Pen.Color := clRed;      Canvas.Line(0, 0, 500, 500);      Canvas.Line(500, 0, 0, 500);    finally      EndUpdate;    end;  end;end; ---------------------------------------------------------------------- stem · 2020-02-09 21:30 Thank you!