-
-
Notifications
You must be signed in to change notification settings - Fork 888
Add Projective Transforms #546
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@antonfirsov Surprising comparison results here. 32bit passing 64 bit failing? WTF? |
|
@JimBobSquarePants the difference is not big however. I suspect the root cause is a difference between SIMD and software implementations of Hope it's not CPU dependent & locally reproducible. |
| image.Mutate(i => { i.Transform(m); }); | ||
|
|
||
| string testOutputDetails = $"{taperSide}-{taperCorner}"; | ||
| image.DebugSave(provider, testOutputDetails); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JimBobSquarePants added some tests to cover CreateTaperMatrix() parameters. I may get it wrong but the XxxOrYyy stuff might be the inverse of the intended. Can you check the output?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll have to do some tests locally to ensure the output is expected. The class is based on a Skia example and and old Charles Petzold blog post.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I managed to workaround the floating point issue. It is related to Vector2 again.
The API is perfect. If CreateTaperMatrix() parameters behave as you originally intended, we can add the reference images for Transform_WithTaperMatrix and merge the PR. (But we probably need to invert TaperCorner behavior.)
| /// <param name="taperCorner">An enumeration that indicates on which corners to taper the rectangle.</param> | ||
| /// <param name="taperFraction">The amount to taper.</param> | ||
| /// <returns>The <see cref="Matrix4x4"/></returns> | ||
| public static Matrix4x4 CreateTaperMatrix(Size size, TaperSide taperSide, TaperCorner taperCorner, float taperFraction) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool suff! Covers basic cases & good for testing without getting outside the scope of the library.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding the extra tests, they affirm the expected output well.
Codecov Report
@@ Coverage Diff @@
## master #546 +/- ##
==========================================
+ Coverage 88.28% 88.69% +0.41%
==========================================
Files 838 840 +2
Lines 35186 35300 +114
Branches 2538 2544 +6
==========================================
+ Hits 31064 31310 +246
+ Misses 3377 3243 -134
- Partials 745 747 +2
Continue to review full report at Codecov.
|
|
@antonfirsov Back to you; do your magic please. |
|
@JimBobSquarePants you sure |
@antonfirsov I think it's correct. In the first example we are choosing to taper the "Bottom" side on either the "Left" or "Top" corner. Since "Left" is possible regardless of whether "Top" is impossible "Left" is chosen. In the seconds example we are choosing to taper the "Bottom" side on either the "Right" or "Bottom" corner. Since "Right" is possible regardless of whether "Bottom" is possible "Right" is chosen. The original article with source code for the class this is based on can be found here: SkiaSharp have an example here: I can attempt to compare against the demos. (Feel free to have a look first though) https://developer.xamarin.com/samples/xamarin-forms/SkiaSharpForms/Demos/ |
|
LOL .. that image! But isn't the first example tapering towards the right corner? Or should I start over my English courses? :D |
|
Ah no... I can see how this is confusing but the language is correct. A classic definition of taper would be
You're tapering towards the bottom edge and choosing which corner to taper with. |
|
I understand now. |
|
Well .. almost. Haven't noticed, the tests are failing again, gonna check it out now. |



Prerequisites
Description
Adds the ability to perform projective transforms (perspective, taper) on images