高手们啊...
procedure GraspScreen(left, top, right, bottom: Integer);
Type
tagBITMAP = packed record
bmType: Longint;
bmWidth: Longint;
bmHeight: Longint;
bmWidthBytes: Longint;
bmPlanes: Word;
bmBitsPixel: Word;
bmBits: Pointer;
end;
var
RWidth,RHeight:Integer;
SourceDC,DestDC,BmpHandle:Integer;
sBitmap:TBitmap;
Buff:integer;
pBmp:^tagBITMAP;
m:Tmemorystream;
BInfo:TBitmapInfo;
DebugStr:String;
begin
RWidth:=Right-Left;
RHeight:=Bottom-Top;
SourceDc:=GetDC(0);
DestDC:=CreateCompatibleDC(SourceDC);
BmpHandle:=CreateCompatibleBitmap(SourceDC,Rwidth,RHeight);
SelectObject(DestDc,BmpHandle);
//以下的语句成功,DebugStr='1'
DebugStr:=inttostr(Integer(Bitblt(DestDC,0,0,RWidth,RHeight,SourceDC,Left,Top,SRCCOPY)));
Buff:=sizeof(pBmp^);
//以下的语句也成功,不过pBmp^.bmBits是否就是指向其内存?
GetObject(BmpHandle,Buff,pBmp);
//以下的语句失败。 应该如果写?
DebugStr:=inttostr(GetDIBits(SourceDc,BmpHandle,0,RHeight,pBmp^.bmBits , BInfo,DIB_RGB_COLORS));
m:=tmemorystream.Create ;
try
//假如GetDIBits一句成功,是不是以下语句就完成了内存转存的工作?
m.WriteBuffer( pBmp^.bmBits ^,BInfo.bmiHeader.biSize);
....
finally
m.free;
end;
DeleteDC(DestDc);
ReleaseDC(0,SourceDC);
end;