松
松子
Unregistered / Unconfirmed
GUEST, unregistred user!
procedure screencap(leftpos,toppos,rightpos,bottompos:integer);
var
rectwidth,rectheight:integer;
sourcedc,destdc,bhandle:integer;
bitmap:Tbitmap;
jp:Tjpegimage;
begin
rectwidth:=rightpos-leftpos;
rectheight:=bottompos-toppos;
sourcedc:=createdc('DISPLAY','','',nil);
destdc:=createcompatibledc(sourcedc);
bhandle:=createcompatiblebitmap(sourcedc,rectwidth,rectheight);
selectobject(destdc,bhandle);
bitblt(destdc,0,0,rectwidth,rectheight,sourcedc,leftpos,toppos,srccopy);
bitmap:=Tbitmap.create;
bitmap.handle:=bhandle;
jp:=Tjpegimage.create;
jp.assign(bitmap);
bmpstream:=TMemoryStream.Create;
jp.SaveToStream(bmpstream); //报错
bmpstream.position:=0;
leftsize:=bmpstream.size;
bitmap.free;
jp.Free;
deletedc(destdc);
releasedc(bhandle,sourcedc);
end;
请问,错在哪?
var
rectwidth,rectheight:integer;
sourcedc,destdc,bhandle:integer;
bitmap:Tbitmap;
jp:Tjpegimage;
begin
rectwidth:=rightpos-leftpos;
rectheight:=bottompos-toppos;
sourcedc:=createdc('DISPLAY','','',nil);
destdc:=createcompatibledc(sourcedc);
bhandle:=createcompatiblebitmap(sourcedc,rectwidth,rectheight);
selectobject(destdc,bhandle);
bitblt(destdc,0,0,rectwidth,rectheight,sourcedc,leftpos,toppos,srccopy);
bitmap:=Tbitmap.create;
bitmap.handle:=bhandle;
jp:=Tjpegimage.create;
jp.assign(bitmap);
bmpstream:=TMemoryStream.Create;
jp.SaveToStream(bmpstream); //报错
bmpstream.position:=0;
leftsize:=bmpstream.size;
bitmap.free;
jp.Free;
deletedc(destdc);
releasedc(bhandle,sourcedc);
end;
请问,错在哪?