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
Initial implementation of GDI+ effects #10750
Conversation
This exposes most of the GDI+ effects under the [RequiresPreviewFeatures] while we take it to .NET API review. Effects are added under the `Imaging\Effects` namespace. The new effects are: - BlackSaturation - Blur - BrightnessContrast - ColorBalance - ColorLookupTable - ColorMatrix - Contrast - Density - Exposure - Highlight - Levels - Midtone - Shadow - Sharpen - Tint - WhiteSaturation This also adds: - New, efficient constructor to ColorMatrix that takes a span of floats - Overload for Graphics.DrawImage that allows you to draw with an effect (and fix the perf of the indexer) - An ApplyEffect method on Bitmap that lets you apply an effect to an existing bitmap - Adds the uses preview features flag to the scratch projects Effects are applied to bitmaps, not associated with them. The image doesn't retain a handle, it just modifies the bits using the effect. As such I have not exposed a way to mutate the effect classes after creation. The cost of creating an effects class is not high, but they should be disposed to avoid having them clutter the finalizer queue. I also did not include the red eye removal effect as it is sort of a one-off from general image effects. GDI+ won't be adding any new effects (these were added over 20 years ago). Tests are pending.
Related to #8835 |
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #10750 +/- ##
===================================================
- Coverage 72.66649% 72.65214% -0.01435%
===================================================
Files 2903 2925 +22
Lines 622024 622685 +661
Branches 46863 46918 +55
===================================================
+ Hits 452003 452394 +391
- Misses 161715 161952 +237
- Partials 8306 8339 +33
Flags with carried forward coverage won't be shown. Click here to find out more. |
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.
Didn't look at each individual line, but it looks very reasonable to me.
One question though:
Don't we need a) modified public-API text files, and b) a list of concrete API changes in the PR/Issue description for the API review?
@KlausLoeffelmann #8835 has the API proposal and we don't have api.txt files for System.Drawing. We build for multiple frameworks so I'm not even sure it is possible; I'll look into it when I get a chance. |
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.
Few minor comments but overall looks good! This is exciting 🥳
src/System.Windows.Forms/tests/IntegrationTests/ScratchProject/ScratchProject.csproj
Outdated
Show resolved
Hide resolved
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 exposes most of the GDI+ effects under the [RequiresPreviewFeatures] while we take it to .NET API review.
Effects are added under the
Imaging\Effects
namespace. The new effects are:This also adds:
Effects are applied to bitmaps, not associated with them. The image doesn't retain a handle, it just modifies the bits using the effect. As such I have not exposed a way to mutate the effect classes after creation. The cost of creating an effects class is not high, but they should be disposed to avoid having them clutter the finalizer queue.
I also did not include the red eye removal effect as it is sort of a one-off from general image effects. GDI+ won't be adding any new effects (these were added over 20 years ago).
Tests are pending.
Microsoft Reviewers: Open in CodeFlow