Bug 45301 - ComputeBounds incorrect for cubic curves
Summary: ComputeBounds incorrect for cubic curves
Status: REOPENED
Alias: None
Product: Android
Classification: Xamarin
Component: BCL Class Libraries ()
Version: 7.0 (C8)
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Marek Habersack
URL:
Depends on:
Blocks:
 
Reported: 2016-10-12 03:39 UTC by Roland Grießer
Modified: 2016-10-15 03:25 UTC (History)
1 user (show)

Tags: XATriaged
Is this bug a regression?: ---
Last known good build:


Attachments
Expected and actual bounds of the shape (29.39 KB, image/jpeg)
2016-10-15 03:20 UTC, Roland Grießer
Details
Test-application including workaround (31.95 KB, application/x-zip-compressed)
2016-10-15 03:23 UTC, Roland Grießer
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report for Bug 45301 on Developer Community or GitHub if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: Developer Community HTML or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
REOPENED

Description Roland Grießer 2016-10-12 03:39:58 UTC
When calling the path.ComputeBounds(), the returned bounds are too big when using a cubic bezier curve like described in https://bugs.eclipse.org/bugs/show_bug.cgi?id=495278.

for example:

            path.MoveTo(52.2716f, 27.8072f);
            path.CubicTo(48.9356f, 24.164f, 42.0671f, 25.7204f, 38.0992f, 31.3618f);
            path.CubicTo(33.0737f, 25.3024f, 27.0713f, 24.164f, 23.7257f, 27.8072f);
            path.CubicTo(14.4142f, 37.9485f, 34.3451f, 52.5246f, 37.9599f, 54.1634f);
            path.LineTo(38.0438f, 54.2109f);
            path.LineTo(38.0438f, 54.1634f);
            path.CubicTo(41.6554f, 52.5246f, 61.5832f, 37.9485f, 52.2716f, 27.8072f);
            path.Close();

This gives bounds of the outmost control points (14.4142, 24.164, 61.5832, 54.2109), where in fact the curve is much tighter.
Comment 1 Marek Habersack 2016-10-13 12:22:05 UTC
Please attach a small, self-contained project which demonstrates and reproduces the issue and then reopen the bug, thanks!
Comment 2 Roland Grießer 2016-10-15 03:20:42 UTC
Created attachment 18052 [details]
Expected and actual bounds of the shape

When calling the Android.Graphics.Path.ComputeBounds, the black rectangle is returned as bounds (caused by the control points of the cubic curves).
When doing the same on iOS, the blue rectangle is returned (giving the actual bounds of the path, as expected)
Comment 3 Roland Grießer 2016-10-15 03:23:22 UTC
Created attachment 18053 [details]
Test-application including workaround

The test applications draws the path 2 times and calculates the bounds once with the built-in computeBounds and once with a custom computeBounds. 
Then the path is stretched to fill the containing View, where the difference between the two calculation methods get visible (built-in path is rendered too small).
Comment 4 Roland Grießer 2016-10-15 03:25:59 UTC
Attached a project to demonstrate the bug/issue.
As far as i found out, this is concerned to the Android.Graphics.Path.computeBounds implementation, because the second parameter "exact" is now ignored.