Rank: Advanced Member Groups: Member
Joined: 10/7/2015 Posts: 35
|
Hi,
If I set the ZoomFactor to a higher number, like "3", and then almost immediately call WebView.Capture(), the captured image is not zoomed.
But, if I pause in the debugger, or add a Thread.Sleep(300) after calling ZoomFactor = 3, then calling WebView.Capture() gets the correctly zoomed image.
Doing this zooming and capture is important for us, because we are basically programmatically taking a snapshot after the user selects a region using a bounding box.
Do you think there would be a suggestion to make sure that capture() waits for any zooming to finish? Or is there any generic mechanism in WebView to wait for rendering to complete for this case?
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Thanks for the suggestion. While this makes sense it is not so easy to implement. Internally Chrome engine works asynchronously in nature since the final goal is to render the result on screen --- and that can involve multiple delays at various steps in different component. So it is no easy task to sync them all up and clearly determine when the zoom factor has been applied. For example, if you set zoom level to one value and then another value quickly after, then somewhere in the pipe line the first zoom level will be canceled. If we were to track the completion of zoom level, then that cancelation event has to be propogated back somehow. Such mechanism does not exist in the chrome browser engine. As such it would be quite some code changes to make this happen if it is even possible. So we do not think it's a good idea to go down this path.
|
Rank: Advanced Member Groups: Member
Joined: 10/7/2015 Posts: 35
|
Thanks, I will stick with the code I have then, which always seems to work so far - I reproduce below for the benefit of anyone else. webview.ZoomFactor = x; Thread.Sleep(300); webview.Capture(...)
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Great. Thanks for sharing!
|