Qt: fix RawImage_FromDevice (by Felipe request)

git-svn-id: trunk@11934 -
This commit is contained in:
paul 2007-09-04 07:20:04 +00:00
parent 3d77f2e0a2
commit f20510c8f5

View File

@ -374,13 +374,21 @@ function TQtWidgetSet.RawImage_FromDevice(out ARawImage: TRawImage; ADC: HDC; co
var var
Desc: TRawImageDescription absolute ARawImage.Description; Desc: TRawImageDescription absolute ARawImage.Description;
IsDesktopDC: Boolean;
//SrcWidth, SrcHeight: Integer; //SrcWidth, SrcHeight: Integer;
WinID: Cardinal; WinID: Cardinal;
desktop: QDesktopWidgetH; DCSize: TSize;
ScreenSize: TSize;
Pixmap: TQtPixmap; Pixmap: TQtPixmap;
Image: QImageH; Image: QImageH;
Context: TQtDeviceContext;
procedure RawImage_FromImage(AImage: QImageH);
begin
ARawImage.DataSize := QImage_numBytes(AImage);
ARawImage.Data := GetMem(ARawImage.DataSize);
Move(QImage_bits(AImage)^, ARawImage.Data^, ARawImage.DataSize);
ARawImage.Mask := nil;
end;
begin begin
{$ifdef VerboseQtWinAPI} {$ifdef VerboseQtWinAPI}
WriteLn('Trace:> [WinAPI GetRawImageFromDevice] SrcDC: ', dbghex(ADC), WriteLn('Trace:> [WinAPI GetRawImageFromDevice] SrcDC: ', dbghex(ADC),
@ -388,44 +396,45 @@ begin
' SrcHeight: ', dbgs(ARect.Bottom - ARect.Top)); ' SrcHeight: ', dbgs(ARect.Bottom - ARect.Top));
{$endif} {$endif}
// todo: copy only passed rectangle
Result := True; Result := True;
FillStandardDescription(ARawImage.Description); FillStandardDescription(ARawImage.Description);
Context := TQtDeviceContext(ADC);
//SrcWidth := ARect.Right - ARect.Left; with DCSize, Context.getDeviceSize do
//SrcHeight := ARect.Bottom - ARect.Top;
IsDesktopDC := True; // Hard-coded, but a real check should be made
if IsDesktopDC then
begin begin
desktop := QApplication_desktop; cx := x;
QWidget_size(QDesktopWidget_screen(desktop), @ScreenSize); cy := y;
WinID := QWidget_winId(QDesktopWidget_screen(desktop)); end;
Pixmap := TQtPixmap.Create(@ScreenSize); Pixmap := TQtPixmap.Create(@DCSize);
if Context.Parent <> nil then
begin
WinID := QWidget_winId(Context.Parent);
try try
Pixmap.grabWindow(WinID); Pixmap.grabWindow(WinID);
Image := QImage_Create; Image := QImage_Create;
Pixmap.toImage(Image); Pixmap.toImage(Image);
ARawImage.DataSize := QImage_numBytes(Image); RawImage_FromImage(Image);
ARawImage.Data := GetMem(ARawImage.DataSize); QImage_destroy(Image);
Move(QImage_bits(Image)^, ARawImage.Data^, ARawImage.DataSize);
finally finally
Pixmap.Free; Pixmap.Free;
end; end;
end else
// In this case we use the size of the desktop
Desc.Width := QWidget_width(QApplication_desktop);
Desc.Height := QWidget_height(QApplication_desktop);
end
else
begin begin
{$note TODO: get DC bitmap} if Context.vImage <> nil then
RawImage_FromImage(Context.vImage)
else
Result := False; Result := False;
end; end;
// In this case we use the size of the context
Desc.Width := DCSize.cx;
Desc.Height := DCSize.cy;
{$ifdef VerboseQtWinAPI} {$ifdef VerboseQtWinAPI}
WriteLn('Trace:< [WinAPI GetRawImageFromDevice]'); WriteLn('Trace:< [WinAPI GetRawImageFromDevice]');
{$endif} {$endif}