-
-
Notifications
You must be signed in to change notification settings - Fork 890
Support High Precision TPixel formats via Color #1797
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
Codecov Report
@@ Coverage Diff @@
## master #1797 +/- ##
=======================================
Coverage 87.10% 87.10%
=======================================
Files 936 936
Lines 47832 47861 +29
Branches 6009 6009
=======================================
+ Hits 41662 41690 +28
+ Misses 5178 5177 -1
- Partials 992 994 +2
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
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.
Let's bring this back to design discussion, and re-evaluate our options:
Replace Rgba64 with Vector4
- Higher precision, covers (somewhat) more cases
- We think it might solve the user wish from SixLabors/ImageSharp.Drawing#165, but no confirmation yet
- Keeps things simple
- Increases
Colorsize from 64 bits to 128 bits - Floating point flakiness may lead to conversion inaccuracies
Add optional boxed IPixel
- Definitely solves all potential wishes for arbitrary Colors
- Increased complexity / bloat
- Increases
Colorsize from 64 bits to 128 bits - Always accurate as soon as backing pixel implementation is accurate
I don't see that Vector4 is a clear winner. At least we should see more input from @calrsom. (Use case, actual pixel type, how/why can be Vector4 good enough.)
If there is no consensus, I'd prefer to keep things as they are now.
|
@antonfirsov one thing I’m struggling with is how bulk operations would work with the boxed value. From a safety perspective you’d have to check each item in the input Color span to ensure they conform to the correct type. |
We don't/shouldn't be using Also do we even have any |
|
I agree with @tocsoft, we don't do (and should never do) bulk conversion of
When we initialize a pixel-specific operation executor, that uses a series of colors, we need to convert ImageSharp/src/ImageSharp/Processing/Processors/Quantization/PaletteQuantizer.cs Lines 56 to 60 in 4638965
This happens on a very small batch of data, so the cost is negligible compared to the quantization. |
|
We already expose a bulk method on the Color type. ImageSharp/src/ImageSharp/Color/Color.cs Lines 229 to 245 in 527e0fb
|
|
@JimBobSquarePants yes, we use that method in |
|
I’m just pointing out that we expose is and as such we’d have to lose any optimisation to use the boxes value. We wouldn’t use it on a hot path nor mix color precision but who knows what madness lies beyond our walls! I’m happy to experiment and convert it to a loop with check but just wanted everyone to be aware. EDIT. Doing some experimentation here and it's getting messy. Have created #1801 for comparison |
|
Closed in favor of #1801 |
Prerequisites
Description
Switches out the
Rgba64color backing type forRgbaVectorinColor. This allows supporting all the pixel formats in the library without loss of precision.A new
Color.FromPixel<TPixel>(TPixel pixel)method has been provided to support this.See SixLabors/ImageSharp.Drawing#165