-
-
Notifications
You must be signed in to change notification settings - Fork 891
Introduce representation-agnostic Color type #908
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
(non-namespace providing)
Codecov Report
@@ Coverage Diff @@
## master #908 +/- ##
==========================================
- Coverage 89.6% 89.17% -0.43%
==========================================
Files 1060 1079 +19
Lines 46542 47573 +1031
Branches 3268 3270 +2
==========================================
+ Hits 41703 42425 +722
- Misses 4128 4396 +268
- Partials 711 752 +41
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #908 +/- ##
==========================================
- Coverage 89.61% 89.29% -0.33%
==========================================
Files 1060 1079 +19
Lines 46586 47631 +1045
Branches 3272 3273 +1
==========================================
+ Hits 41750 42530 +780
- Misses 4125 4387 +262
- Partials 711 714 +3
Continue to review full report at Codecov.
|
JimBobSquarePants
left a comment
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 absolutely love the direction this has gone. I think it's a quantum leap in usability. 👍
I think we can tighten up some of the code reuse though taking advantage of implicit casting. I'm happy to make those changes.
| using (IFrameQuantizer<TPixel> palleteFrameQuantizer = palleteQuantizer.CreateFrameQuantizer(image.GetConfiguration())) | ||
| using (QuantizedFrame<TPixel> paletteQuantized = palleteFrameQuantizer.QuantizeFrame(frame)) | ||
| using (IFrameQuantizer<TPixel> palleteFrameQuantizer = | ||
| new PaletteFrameQuantizer<TPixel>(this.quantizer.Diffuser, quantized.Palette)) |
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.
This is all so much nicer! 😍
| /// <param name="indexedPixels">The span of indexed pixels.</param> | ||
| /// <param name="stream">The stream to write to.</param> | ||
| public void Encode(Span<byte> indexedPixels, Stream stream) | ||
| public void Encode(ReadOnlySpan<byte> indexedPixels, Stream stream) |
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.
Good!
| /// </summary> | ||
| /// <param name="source">The <see cref="Rgba64"/>.</param> | ||
| /// <returns>The <see cref="Color"/>.</returns> | ||
| public static implicit operator Color(Rgba64 source) => new Color(source); |
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.
shouldn't these implicit operators be on the Pixel type instead of Color? there are alot more Pixel types after all.
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.
Good point! I think I will change this.
add micro-optimizations
# Conflicts:
# src/ImageSharp/Processing/Processors/Quantization/QuantizedFrame{TPixel}.cs
Introduce representation-agnostic Color type
Prerequisites
Description
Colorstruct with a hidden internal hi-res representation, that is convertible to all pixel typesColor.BlackorColor.WebSafePalette)Colortype now.Coloron all public API-s (Consequence:PaletteQuantizer<TPixel>has been dropped.)ReadOnlyMemory<T>on public API-s instead ofT[]QuantizedFrame<T>.GetPixelSpan()returnsReadOnlySpan<T>. Populating the span is an implementation detail. IntroduceIQuantizedFrame<T>to maintain clean abstractions here.ColorBuilder<T>.FromRGBA()toFromRgbaConsequence on our terminlogy
Color ≠ Pixel any longer. Color is a general term, pixel is a representation drawable on an
Image<TPixel>.