View Issue Details

IDProjectCategoryView StatusLast Update
0021845LazarusLCLpublic2019-12-12 13:05
ReporterTristan Linnell Assigned ToJuha Manninen  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionwon't fix 
Product Version0.9.30.4 
Summary0021845: Screenshot with GetDC not working on Carbon - Mac OS X Lion 10.7
DescriptionI 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
TagsNo tags attached.
Fixed in Revision
LazTarget-
WidgetsetCarbon
Attached Files

Activities

Felipe Monteiro de Carvalho

2012-04-29 11:38

developer   ~0059094

Yes, Apple broke our previous way of doing screenshots and introduced a new one which works only in 10.6+

LCL-CustomDrawn-Cocoa already uses the new method and it works fine.

Tristan Linnell

2012-05-16 11:25

reporter   ~0059643

Is there any example code for the new technique anywhere?
Thanks,
Tristan

Hans Luijten

2013-10-04 19:47

reporter   ~0070536

Bug remains (Laz. 10.0.12) - even though it's Apple to blame.

A fix (as suggested in Lazarus Forums: http://forum.lazarus.freepascal.org/index.php?topic=16980.0) would be nice to be able to keep working cross platform.

Sample code would be a nice temporary work around but I couldn't get the LCL-CustomDrawn-Cocoa to work (probably my lack of knowledge).

Felipe Monteiro de Carvalho

2015-02-13 00:05

developer   ~0081009

Use LCL-Cocoa it works there.

Juha Manninen

2019-12-12 13:05

developer   ~0119788

Resolving as "won't fix". Clearly nobody will fix such Carbon bugs any more.

Issue History

Date Modified Username Field Change
2012-04-23 14:48 Tristan Linnell New Issue
2012-04-23 14:48 Tristan Linnell Widgetset => Carbon
2012-04-29 11:38 Felipe Monteiro de Carvalho Note Added: 0059094
2012-05-16 11:25 Tristan Linnell Note Added: 0059643
2013-10-04 19:47 Hans Luijten Note Added: 0070536
2015-02-13 00:05 Felipe Monteiro de Carvalho Note Added: 0081009
2015-05-17 20:01 Felipe Monteiro de Carvalho LazTarget => -
2015-05-17 20:01 Felipe Monteiro de Carvalho Summary Screenshot with GetDC not working on Mac OS X Lion 10.7 => Screenshot with GetDC not working on Carbon - Mac OS X Lion 10.7
2019-12-12 13:05 Juha Manninen Assigned To => Juha Manninen
2019-12-12 13:05 Juha Manninen Status new => resolved
2019-12-12 13:05 Juha Manninen Resolution open => won't fix
2019-12-12 13:05 Juha Manninen Widgetset Carbon => Carbon
2019-12-12 13:05 Juha Manninen Note Added: 0119788