Screenshot with GetDC not working on Carbon - Mac OS X Lion 10.7
Original Reporter info from Mantis: talinnell
-
Reporter name: Tristan Linnell
Original Reporter info from Mantis: talinnell
- Reporter name: Tristan Linnell
Description:
I have been using the following code to take screenshots of my app window for the last few years, with no problems. With Mac OS X 10.7 Lion however, the resulting image is all black.
procedure TfrmMain.CaptureScreenshot(var Image: TBitmap);
var
BMP: TBitmap;
ScreenDC: HDC;
begin
BMP := TBitmap.Create;
ScreenDC := GetDC(0);
BMP.LoadFromDevice(ScreenDC);
ReleaseDC(0, ScreenDC);
Image.SetSize(Self.Width, Self.Height);
Image.Canvas.CopyRect(Rect(0, 0, Self.Width - 1, Self.Height - 1), BMP.Canvas,
Rect(Self.Left, Self.Top, Self.Left + Self.Width - 1, Self.Top + Self.Height - 1 + 22));
BMP.Free;
end;
It is the example code from the Lazarus Wiki on taking screenshots.
Thank you,
Tristan
Mantis conversion info:
- Mantis ID: 21845
- Version: 0.9.30.4
- Monitored by: » Shebuka (Anton S.)