|
Rank: Advanced Member Groups: Member
Joined: 8/29/2016 Posts: 64
|
If I am trying to capture the picture with specific size and position, it doesn't work. This bug appear only on some sites and to see it you need to scroll the page first. After it scrolled you won't get new content, you will see old content (before scrolling). If you use: var capture = view2.Capture(); instead of var capture = view.Capture(new System.Drawing.Rectangle(0, 0, 1000, 1000)); it works correctly.
Code: C#
Task.Run(() =>
{
ThreadRunner runner = new ThreadRunner();
WebView view = runner.CreateWebView();
view.Resize(1000,1000);
object image = runner.Send((WebView view2, object args) =>
{
NavigationTask loadTask = view2.LoadUrl("https://mouseflow.com/demo/");
if (loadTask.WaitOne(60000))
{
//view2.Resize(1000, view.GetPageSize().Height);
view.SetScrollOffset(0, 1000);
//Thread.Sleep(1000);
view.GetContentAreaSize();
// Doesn't get the correct image from the WebView, page is scrolled but
// content is other
var capture = view2.Capture(new System.Drawing.Rectangle(0, 0, 1000, 1000));
// Works okay
//var capture = view2.Capture();
return capture;
}
return null;
}, view, null);
((System.Drawing.Image)image).Save("D:\\ppp.png");
});
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Hi,
This behavior is by design. When you use Capture(rect), the rect you specified is the absolute rectangle of page, which is independent of the current scrolling position. If you want the capture to start from the current scrolling position, you can add that to your rect's offset. This is exactly what WebView.Capture() does.
Thanks!
|
|
Rank: Advanced Member Groups: Member
Joined: 8/29/2016 Posts: 64
|
Thank you for the answer. I was using other components before and it was capturing visible area only.
Your idea I like better! :)
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Great. Glad to hear that you like it!
|
|