回复 18楼gaobowen的帖子
您好, 厂商今早回复,原文如下:
If the customer wants to be able to implement this without any user interaction (as it seems from your prior email), I believe the only way to accomplish this would be to capture the entire screen using the ScreenCaptureEngine.CaptureFullScreen() method and then cropping or copying the specific area. The CaptureArea() method would seem to fit this, but calling this method automatically invokes a process by which the SDK awaits the user clicking with the mouse to define the area. There's no way to specify the specific area to capture. Because the CaptureArea() feature allows the user to capture many different types of shapes, there's no good way to pass the specific points to complete the capture. It's also possible this limitation is in place to assure a proper shape is used so the capture can be completed.
If the customer is okay with this method of capturing, there is a robust example in the documentation that shows the different structures used. It also shows how these can be manually filled in and the dialogs removed. They can replace the CaptureArea() method with CaptureFullScreen() followed by using the CropCommand class or CopyRectangleCommand class to get the specific area desired. The documentation example can be found here:
https://www.leadtools.com/help/l ... ncaptureengine.html
==============================================================================================================
大意是说,目前没有一个方法能够让您指定一个特定的区域进行自动的截屏,因为CaptureArea这个方法是让用户画一个区域进行截取,必须等待用户点击热键或者鼠标按键,所以无法做到。
Support提供了一个思路,就是截取整个屏幕,然后通过CropCommand或者CopyRectangleCommand这两个命令来截取您想要的区域。
我这边做过测试是可以实现的,我做了一个小例子,固定截取屏幕的左下角。
效果如下图:
核心代码在button2 Click事件中:
Dim scAreaOptions As ScreenCaptureAreaOptions
scAreaOptions = ScreenCaptureEngine.DefaultCaptureAreaOptions
Dim scOptions As ScreenCaptureOptions
scOptions = New ScreenCaptureOptions
‘ 将截图热键设置为空,就会直接触发截图结束
scOptions.Hotkey = Keys.None
Dim scInformation As ScreenCaptureInformation = Nothing
scEngine.CaptureOptions = scOptions
Dim image As RasterImage
' 截图方式为全屏
image = scEngine.CaptureFullScreen(scInformation)
scEngine.StopCapture()
'image.Dispose()
ScreenCaptureEngine.Shutdown()
最后挂载scEngine.CaptureInformation截图结束事件,在这个事件中取到截图图像,并对其做裁剪处理:
Public Sub scEngine_CaptureInformation(ByVal sender As Object, ByVal e As ScreenCaptureInformationEventArgs) Handles scEngine.CaptureInformation
' 拿到截图结果
RasterImageViewer2.Image = e.Image
Dim cmd As CopyRectangleCommand = New CopyRectangleCommand()
cmd.CreateFlags = RasterMemoryFlags.Conventional
' 创建一个区域,屏幕左下角到整个图片的10分之一处
cmd.Rectangle = New LeadRect(0, _
0, _
RasterImageViewer2.Image.Width / 10, _
RasterImageViewer2.Image.Height / 10)
cmd.Run(RasterImageViewer2.Image)
' 将裁剪结果显示在左边
RasterImageViewer1.Image = cmd.DestinationImage
' everything worked fine
e.Cancel = False
End Sub
我将我的源程序附在这里,您可以下载解压查看。
以上,谢谢。 |