11
11
******************************************************************************
13
13
*****************************************************************************
15
* This file is part of the Lazarus Component Library (LCL) *
17
* See the file COPYING.modifiedLGPL.txt, included in this distribution, *
18
* for details about the copyright. *
20
* This program is distributed in the hope that it will be useful, *
21
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
22
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
14
This file is part of the Lazarus Component Library (LCL)
16
See the file COPYING.modifiedLGPL.txt, included in this distribution,
17
for details about the license.
24
18
*****************************************************************************
151
145
So get this internal bitmap and pass it to RawImage_FromBitmap
152
146
------------------------------------------------------------------------------}
153
147
function TCDWidgetSet.RawImage_FromDevice(out ARawImage: TRawImage; ADC: HDC; const ARect: TRect): Boolean;
150
//XImage: XLib.TXImage;
154
lx,ly,lwidth,lheight: culong;
155
lDataLength: Integer;
157
procedure DescriptionFix(var ArawImage: TRawImage; Awidth,AHeight: Integer);
159
Description: TRawImageDescription absolute ArawImage.Description;
161
// setup an artificial ScanLineImage with format RGB 32 bit, 32bit depth format
162
//FillChar(Description, SizeOf(Description), 0);
163
with Description do begin;
165
Depth := 24; // used bits per pixel
168
BitOrder := riboBitsInOrder;
169
ByteOrder := riboLSBFirst;
170
LineOrder := riloTopToBottom;
171
BitsPerPixel := 32; // bits per pixel. can be greater than Depth.
172
LineEnd := rileDWordBoundary;
173
RedPrec := 8; // red precision. bits for red
176
GreenShift := 8; // bitshift. Direction: from least to most signifikant
181
MaskBitsPerPixel := 1;
183
MaskLineEnd:=rileByteBoundary;
184
MaskBitOrder:=riboBitsInOrder;
185
PaletteColorCount:= 0;
186
PaletteBitsPerIndex:=0;
188
PaletteLineEnd:=rileTight;
189
PaletteBitOrder:=riboBitsInOrder;
190
PaletteByteOrder:=riboLSBFirst;
155
195
{$ifdef VerboseCDWinAPI}
156
196
DebugLn('Trace:> [WinAPI GetRawImageFromDevice] SrcDC: ', dbghex(ADC),
158
198
' SrcHeight: ', dbgs(ARect.Bottom - ARect.Top));
161
// todo: copy only passed rectangle
201
// create a raw Image to hold screenshot
204
lwidth:=ARect.Right-ARect.Left;
205
lheight:=Arect.Bottom-ARect.Top;
207
// We should get the description from the drawable but this may do
208
ARawImage.Description.Init_BPP32_A8R8G8B8_BIO_TTB(lwidth, lheight);
209
ARawImage.CreateData(True);
211
RootWindow:= XDefaultRootWindow(FDisplay);
213
PlaneMask:=XAllPlanes();
214
// Take the screenshot
216
FDisplay,RootWindow, // Screen, Window
218
lwidth,lheight, // width, height
219
PlaneMask, // All planes
220
ZPixmap); // Image format
221
// copy screen shot to our rawImage
222
lDataLength:= ARawImage.DataSize;
223
System.Move( Image^.Data^,ARawImage.Data^,lDataLength);
224
// We should fix the description from the drawable but this will do for now
225
DescriptionFix(ARawImage,lwidth,lheight);
227
ARawImage.Palette:=nil;
168
231
procedure TCDWidgetset.ShowVirtualKeyboard();