[Answered, no solution] GetFormImage on MacOS generates black bitmap lazarus / 39-Graphics ---------------------------------------------------------------------- wittbo · 2019-06-03 12:46 Given this simple procedure: procedure TmyForm.Button1Click(Sender: TObject); var bm: TBitmap; begin    bm := myForm.GetFormImage;    bm.Canvas.Changed;    bm.SaveToFile('/users/myuser/downloads/test.bmp');    bm.Free end; The file gets generated with the correct dimensions width and height, but the contents of the bitmap in the file is entirely black. Any idea? Does GetFormImage only work on Windows? ---------------------------------------------------------------------- lucamar · 2019-06-03 14:59 Quote from: wittbo on June 03, 2019, 02:46:46 pmDoes GetFormImage only work on Windows? No, it works also on Linux. See attached image, made using: 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 TMainForm.btDoTestClick(Sender: TObject);var  Bitmap: TBitmap;begin  Bitmap := GetFormImage;  if Assigned(Bitmap) then  try    {Bitmap.Canvas.Changed; - not needed: there's no OnChange handler}    Bitmap.SaveToFile('test.bmp');    Image.Picture.LoadFromFile('test.bmp');  finally    Bitmap.Free;  end;end; Unrelated, but note that it is very bad practice to reference the auto-created form instance inside the methods. If you realy need to reference the current object use Self, as in: Self.GetFormImage ---------------------------------------------------------------------- bylaardt · 2019-06-03 23:52 this reminds me of an old topic: https://forum.lazarus.freepascal.org/index.php/topic,27896.msg173144.h tml#msg173144 ---------------------------------------------------------------------- wittbo · 2019-06-04 09:13 Sorry, but none of the solutions (GetFormimage, ...copyrect, ...) does work on MacOS. The Bitmap remains black. I believe, it is a special MacOS problem(or cocoa): i will copy a link to this thread into the macos forum. ---------------------------------------------------------------------- bylaardt · 2019-06-04 15:19 even paintto? ---------------------------------------------------------------------- wittbo · 2019-06-05 08:39 Skalogryz wrote in the correspondent macos thread:  that's easy. The function has not been implemented for cocoa yet https://forum.lazarus.freepascal.org/index.php/topic,45606.0.html Therefore actually no solution for Mac users. ---------------------------------------------------------------------- bylaardt · 2019-06-05 13:46 have you try? 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 MyCapture:=TBitMap.Create(application);  MyCapture.SetSize(ClientWidth,ClientHeight);  MyCapture.canvas.FillRect(0,0,ClientWidth,ClientHeight);  self.PaintTo(MyCapture.canvas,0,0);  MyCapture.SaveToFile('/home/bylaardt/MyFormImage.bmp');  MyCapture.free; ---------------------------------------------------------------------- wittbo · 2019-06-06 09:56 Sorry, just tested. But now the Image isn't black, now it's completely white.