在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
1 using jpeg,ExtCtrls;
2 procedure TForm1.ScreenCap(LeftPos,TopPos,RightPos,BottomPos:integer); 3 var 4 RectWidth,RectHeight:integer; 5 SourceDC,DestDC,Bhandle:integer; 6 Bitmap:TBitmap; 7 MyJpeg: TJpegImage; 8 Stream:TMemoryStream; 9 begin 10 MyJpeg:= TJpegImage.Create; 11 RectWidth:=RightPos-LeftPos; 12 RectHeight:=BottomPos-TopPos; 13 SourceDC:=CreateDC('DISPLAY','','',nil); 14 DestDC:=CreateCompatibleDC(SourceDC); 15 Bhandle:=CreateCompatibleBitmap(SourceDC, 16 RectWidth,RectHeight); 17 SelectObject(DestDC,Bhandle); 18 BitBlt(DestDC,0,0,RectWidth,RectHeight,SourceDC, 19 LeftPos,TopPos,SRCCOPY); 20 Bitmap:=TBitmap.Create; 21 Bitmap.Handle:=BHandle; 22 Stream := TMemoryStream.Create; 23 Bitmap.SaveToStream(Stream); 24 Stream.Free; 25 try 26 MyJpeg.Assign(Bitmap); 27 MyJpeg.CompressionQuality:=70; 28 MyJpeg.Compress; 29 MyJpeg.SaveToFile('C:\MyJPEGImage.JPG'); 30 finally 31 MyJpeg.Free; 32 Bitmap.Free; 33 DeleteDC(DestDC); 34 ReleaseDC(Bhandle,SourceDC); 35 end; 36 end; |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论