Enhance pixel formats and associated-alpha operations with optimizations
Merged
JI
3mo ago+106337+106337+012345678901234567890123456789012345678901234567890123456789-1286-1286-0123456789012345678901234567890123456789
Prerequisites
- I have written a descriptive pull-request title
- I have verified that there are no overlapping pull-requests open
- I have verified that I am following the existing coding patterns and practice as demonstrated in the repository. These follow strict Stylecop rules :cop:.
- I have provided test coverage for my change (where applicable)
Description
This pull request introduces several improvements and new features to the ImageSharp library, focusing on enhanced AOT (Ahead-Of-Time) compilation support, expanded pixel format handling, and increased alpha representation awareness in the Color struct. Additionally, a new test project is added to the solution. The most important changes are summarized below.
AOT Compiler and Pixel Format Support
- Added support for new pixel formats (e.g.,
Argb32P,Abgr32P,Bgra32P,HalfVector4P,NormalizedByte4P,Rgb96,Rgba128,Rgba32P,RgbaHalf,RgbaHalfP) in both pixel seeding and image cloning withinAotCompilerTools.cs. This ensures these formats are available and optimized for AOT compilation scenarios. [1] [2] [3] [4] - Integrated EXR image format support into AOT compilation by including
ExrEncoder,ExrDecoder, and their core methods in the compilation routines. [1] [2] [3] [4] [5] - Added new image processors to the AOT compilation pipeline, such as
AutoLevelProcessor,ConvolutionProcessor, andMedianBlurProcessor, to broaden the range of supported image operations in AOT environments. [1] [2]
Color Struct and Alpha Representation Enhancements
- Refactored the
Colorstruct to explicitly track and expose the alpha representation (Associatedvs.Unassociated) for both the color and its underlying data. This includes new constructor parameters, properties, and improved handling when converting from pixels or vectors. [1] [2] - Updated static methods like
FromPixel,FromScaledVector, and their bulk span-based overloads to properly propagate alpha representation, ensuring accurate color conversions and preventing data loss, especially for associated alpha formats. [1] [2] [3] - Modified
WithAlphaandToHexmethods to use the correct alpha representation and ensure consistent, precise color manipulation and serialization. [1] [2]
Solution and Project Structure
- Added the
ImageSharp.PublicApi.Testsproject to the solution (ImageSharp.sln), including build configuration and solution folder mapping, to improve public API test coverage. [1] [2] [3]
These changes collectively enhance the robustness, flexibility, and future-proofing of ImageSharp for both runtime and compile-time scenarios.