Y
yukaikai
Unregistered / Unconfirmed
GUEST, unregistred user!
使用以下代码抓屏幕,想在上面做简单处理,比如:加文字等,但是总是没有效果,为什么?谢谢回答!
procedure TEPCSnapScrn.SnapScrn(LeftPos,TopPos,RightPos,BottomPos:integer;VFIleName:String);
var
RectWidth,RectHeight:integer;
SourceDC,DestDC,Bhandle:integer;
Bitmap:TBitmap;
BmpStream:TFileStream;
LeftSize:Integer;
R:TRect;
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;
BitMap.Canvas.Pen.Color:=clYellow;
R:=Rect(20,20,500,500);
Bitmap.Canvas.Chord(R.Left, R.Top, R.Right, R.Bottom, R.Right, R.Top, R.Left, R.Top);
Bitmap.SaveToFile(VFileName);
Bitmap.Free;
DeleteDC(DestDC);
ReleaseDC(Bhandle,SourceDC);
end;
procedure TEPCSnapScrn.SnapScrn(LeftPos,TopPos,RightPos,BottomPos:integer;VFIleName:String);
var
RectWidth,RectHeight:integer;
SourceDC,DestDC,Bhandle:integer;
Bitmap:TBitmap;
BmpStream:TFileStream;
LeftSize:Integer;
R:TRect;
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;
BitMap.Canvas.Pen.Color:=clYellow;
R:=Rect(20,20,500,500);
Bitmap.Canvas.Chord(R.Left, R.Top, R.Right, R.Bottom, R.Right, R.Top, R.Left, R.Top);
Bitmap.SaveToFile(VFileName);
Bitmap.Free;
DeleteDC(DestDC);
ReleaseDC(Bhandle,SourceDC);
end;