[Customdrawn] Some patches
Felipe Monteiro de Carvalho
felipemonteiro.carvalho at gmail.com
Tue Apr 3 10:40:12 CEST 2012
On Tue, Apr 3, 2012 at 10:29 AM, Giuliano Colla
<giuliano.colla at fastwebnet.it> wrote:
> I've verified that with XGetImage on the root window you really get the
> image of your screen, and not only the desktop background:
>
> http://www.copeca.it/colla/snap1.jpg
Great! =)
> If you give me some hints (e.g. which backend supports screen capture, where
> it's implemented, and how the main program uses that feature. IOW which are
> the source files to look at), I can try and do the same for X11, just to see
> what happens.
I am already starting to forget what was already implemented and where
... because this thing has just grown huge =)
But the Cocoa backend supports screenshot taking.
>From the LCL side the screenshot is TBitmap.LoadFromDevice which will
call customdrawnlclintfh.inc this routine:
function RawImage_FromDevice(out ARawImage: TRawImage; ADC: HDC; const
ARect: TRect): Boolean; override;
Each backend needs to implement this routine so implement it in
customdrawnlclintf_x11.inc
See how Cocoa does it:
function TCDWidgetSet.RawImage_FromDevice(out ARawImage: TRawImage;
ADC: HDC; const ARect: TRect): Boolean;
var
screenshotImage: CGImageRef;
lRect: CGRect;
lScreenRawImage: TRawImage;
lDataLength: Integer;
begin
Result := True;
ARawImage.Init;
ARawImage.Description.Init_BPP32_A8R8G8B8_BIO_TTB(ScreenBitmapWidth,
ScreenBitmapHeight);
// Take the screenshot
screenshotImage := CGDisplayCreateImage(CGMainDisplayID()); // Requires 10.6+
// Draw it to our screen bitmap
lRect := CGRectMake(0, 0, ScreenBitmapWidth, ScreenBitmapHeight);
CGContextDrawImage(ScreenBitmapContext, lRect, screenshotImage);
// Now copy the data
ScreenImage.GetRawImage(lScreenRawImage, False);
ARawImage.CreateData(False);
lDataLength := Min(lScreenRawImage.DataSize, ARawImage.DataSize);
System.Move(lScreenRawImage.Data^, ARawImage.Data^, lDataLength);
end;
--
Felipe Monteiro de Carvalho
More information about the Customdrawn
mailing list