-
-
Notifications
You must be signed in to change notification settings - Fork 851
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
Fix gaussian blurring changing the blur colour when transperancy is used #1834
Fix gaussian blurring changing the blur colour when transperancy is used #1834
Conversation
2019922
to
56890ba
Compare
Codecov Report
@@ Coverage Diff @@
## master #1834 +/- ##
=======================================
- Coverage 87% 87% -1%
=======================================
Files 937 937
Lines 48420 48421 +1
Branches 6054 6054
=======================================
- Hits 42323 42222 -101
- Misses 5095 5193 +98
- Partials 1002 1006 +4
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
Took a little while but I worked out how to do the reference images for tests (and yep, I did run the optimizer on them so the file size is smaller for the repo). Running the test on this PR: As you can see, the blurring was doing all sorts of weirdness with colours without that line. |
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.
@@ -396,6 +396,8 @@ private void Convolve4(int y, Span<Vector4> span) | |||
|
|||
PixelOperations<TPixel>.Instance.ToVector4(this.configuration, sourceRow, sourceBuffer); | |||
|
|||
Numerics.Premultiply(sourceBuffer); |
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 can be made conditional on PixelTypeInfo.AlphaRepresentation
:
ImageSharp/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeProcessor{TPixel}.cs
Lines 191 to 194 in 9777a3b
PixelAlphaRepresentation? alphaRepresentation = PixelOperations<TPixel>.Instance.GetPixelTypeInfo()?.AlphaRepresentation; | |
// Premultiply only if alpha representation is unknown or Unassociated: | |
bool needsPremultiplication = alphaRepresentation == null || alphaRepresentation.Value == PixelAlphaRepresentation.Unassociated; |
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.
Yeah. Something to look into. I keep meaning to see what else we can add to PixelTypeInfo
actually that would help us in other places.
Prerequisites
Description
Firstly, all credit goes to @JimBobSquarePants for identifying the fix.
Blurring an image that has a transparent background can lead to strange results depending on the colour.
For example, take this code:
Master generates this:
This PR generates:
I do want to add tests for it, just working out how to do it like how you have your Bokeh blur tests.