-
-
Notifications
You must be signed in to change notification settings - Fork 888
Introduce extended pixel conversion #869
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
Changes from all commits
e217d13
877f314
b0ff7cf
d126b85
1a922f6
d1dd90c
70c4e11
37563cc
d2fddce
acb1dbc
575a484
4a0b100
408e196
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| // Copyright (c) Six Labors and contributors. | ||
| // Licensed under the Apache License, Version 2.0. | ||
|
|
||
| using System; | ||
|
|
||
| using SixLabors.ImageSharp.ColorSpaces.Companding; | ||
|
|
||
| namespace SixLabors.ImageSharp.PixelFormats | ||
| { | ||
| /// <summary> | ||
| /// Flags responsible to select additional operations which could be effitiently applied in | ||
| /// <see cref="PixelOperations{TPixel}.ToVector4(SixLabors.ImageSharp.Configuration,System.ReadOnlySpan{TPixel},System.Span{System.Numerics.Vector4},SixLabors.ImageSharp.PixelFormats.PixelConversionModifiers)"/> | ||
| /// or | ||
| /// <see cref="PixelOperations{TPixel}.FromVector4Destructive(SixLabors.ImageSharp.Configuration,System.Span{System.Numerics.Vector4},System.Span{TPixel},SixLabors.ImageSharp.PixelFormats.PixelConversionModifiers)"/> | ||
| /// knowing the pixel type. | ||
| /// </summary> | ||
| [Flags] | ||
| internal enum PixelConversionModifiers | ||
| { | ||
| /// <summary> | ||
| /// No special operation is selected | ||
| /// </summary> | ||
| None = 0, | ||
|
|
||
| /// <summary> | ||
| /// Select <see cref="IPixel.ToScaledVector4"/> and <see cref="IPixel.FromScaledVector4"/> instead the standard (non scaled) variants. | ||
| /// </summary> | ||
| Scale = 1 << 0, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @JimBobSquarePants I keep thinking whether we should replace Scaled / Scale with Normalized / Normalize in our terminology. Seems more precize to me. Or is this wrong thinking? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Actually no. Normalization in our situation is exactly what we are doing and I think I prefer it! It means breaking |
||
|
|
||
| /// <summary> | ||
| /// Enable alpha premultiplication / unpremultiplication | ||
| /// </summary> | ||
| Premultiply = 1 << 1, | ||
|
|
||
| /// <summary> | ||
| /// Enable SRGB companding (defined in <see cref="SRgbCompanding"/>). | ||
| /// </summary> | ||
| SRgbCompand = 1 << 2, | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| // Copyright (c) Six Labors and contributors. | ||
| // Licensed under the Apache License, Version 2.0. | ||
|
|
||
| using System.Runtime.CompilerServices; | ||
|
|
||
| namespace SixLabors.ImageSharp.PixelFormats | ||
| { | ||
| internal static class PixelConversionModifiersExtensions | ||
| { | ||
| [MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
| public static bool IsDefined(this PixelConversionModifiers modifiers, PixelConversionModifiers expected) => | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice! |
||
| (modifiers & expected) == expected; | ||
|
|
||
| [MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
| public static PixelConversionModifiers Remove( | ||
| this PixelConversionModifiers modifiers, | ||
| PixelConversionModifiers removeThis) => | ||
| modifiers & ~removeThis; | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.
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.
Please review my namings here!
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.
Naming is good! 👍