Welcome Guest Search | Active Topics | Sign In | Register

WebView Capture changes Options
Panda
Posted: Wednesday, August 10, 2016 4:57:24 AM
Rank: Advanced Member
Groups: Member

Joined: 10/7/2015
Posts: 35
Hi,

I noticed you changed the Capture feature recently (EO.Total 2016.0.21 - Fixed WebView.Capture not working issue, also enhanced the capture feature to allow capturing anywhere in the page, not just the onscreen area)

Actually, we discovered that this a breaking change for us.
Although we like it and it is very useful.

In fact, using the Capture() method is our main business of using EO WebBrowser.
Our users manipulate the browser, for the sole reason of capturing sections of reports.

So I'm not sure you are aware but the breaking change here was that the Rectangle that is passed to WebView.Capture() now needs to include the scrolling position offset - before it did not.

For example, we used to calculate the position of the Rectangle that the user selected on the WebView (via a bounding box).
We could calculate where the Rectangle was by offseting from the left of the browser control.
It didn't matter if the browser was scrolled left or not.

After this change, the scroll position does matter and will break our old offset code.

Now we have to use the offset PLUS also add the scroll position offset ie document.scrollLeft() - if there is any.
Otherwise if we simply add the offset of the browser window, it is not enough.

I think you will know this, given the changes you made.
I imagine it is probably necessary for capturing something off screen - and that feature is actually very useful to us too.

But I am still having the problem that if the ZoomFactor is not 1 - the Capture() rectangle is now wrong again. By a factor that I cannot work out.

eg when the zoomfactor is 1.5 (150%) my Capture() rectangle coordinates are wrong again, even after making the above described corrections which always work when the zoomFactor is 1...

My captured rectangle is now WRONG (only in the left coordinate) by a factor of approximately 1.158x - in this case.
I see no relation in that number. But I need to multiply my Rectangle's X coordinate by that number - only when zoomFactor is not 1, to get the right capture.

I understand you'll need a test project.
It might take me a while to do it, I suspect.

eo_support
Posted: Wednesday, August 10, 2016 3:31:32 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,229
Hi,

Both scrolling and zoom factor are interesting point. We will look into this and see what we can do. If we need test project we will let you know.

Thanks!
eo_support
Posted: Wednesday, August 10, 2016 7:58:53 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,229
Hi,

We have looked into this. The rule for this seems to be that:

Scroll: Capturing coordination is unrelated to page scroll position

For example, Capture(0, 200, 100, 100) on Y axis will always capture at 200 pixels from top of the page to 300 pixels from top of the page, no matter where the scroll offset of the current view. If you want to start capture from the current window top, you can do Capture(0, window.pageYOffset, 100, 100). Note here "Capture(0, window.pageYOffset, 100, 100)" is not the actual code, it's just for expressing the idea.

ZoomFactor: All coordination values are multiplied by the zoom factor

For example, in order to capture the same rectangle (0, 200, 100, 100) at zoom factor as 1.5, the coordination must be (0, 300, 150, 150). Note that all values, not just the size must multiply by the zoom factor. As such if you wish to capture from the window top, you can use Capture(0, window.pageYOffset * zoomFactor, 100 * zoomFactor, 100 * zoomFactor). The key is all coordination values are multiplied.

Please let us know if this is consistent with what you see on your end.

Thanks!
Panda
Posted: Wednesday, August 10, 2016 9:22:03 PM
Rank: Advanced Member
Groups: Member

Joined: 10/7/2015
Posts: 35
Hi,
Thanks for that.
I have possibly one difference with what you said in getting this to work - "The key is all coordination values are multiplied"

You're probably still right in context, but I think it's because we always need to include Scroll position that we have a slight difference.
Because we need to open the WebView and show exactly what the user previously had showing on the screen.
So, we set the WebView control window to the same size, the scroll position to the same position and position/capture the same Rectangle.

In doing this, we should note that the Scroll position needs to be multiplied by the zoomFactor but *NOT* the offset from left/top.
So I have a calculation to store the Rectangle that the user selects with a bounding box - that does this:
(and this now works and my problem is solved)

Rectangle(
x: scrollX * zoomFactor + window.leftOffset,
y: scrollY * zoomFactor + window.topOffset,
width: width * zoomFactor,
height: height * zoomFactor
)

I'm not sure if I'm failing to explain anything about our scenario, but I hope this is informative
eo_support
Posted: Wednesday, August 10, 2016 9:52:59 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,229
Hi,

You must multiple the scroll offset as well. Try to think zoom factor as a coordination multiplier. Internally it is implemented with a scale matrix, which does exactly the same on all coordination values. So you always figure out the unscaled value first, then multiply to get the scaled value, where as the unscaled value = scroll offset + x/y offset. So the final value will be zoom factor * (scroll offset + x/y offset).

Thanks


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.