diff --git a/.editorconfig b/.editorconfig
index f84e6de2a0..2e3045fb17 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -253,6 +253,9 @@ csharp_space_between_square_brackets = false
# https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/formatting-rules#wrap-options
csharp_preserve_single_line_statements = false
csharp_preserve_single_line_blocks = true
+# Namespace options
+# https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/formatting-rules#namespace-options
+csharp_style_namespace_declarations = file_scoped:warning
##########################################
# .NET Naming Rules
@@ -452,4 +455,4 @@ dotnet_naming_rule.parameters_rule.severity = warning
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
-##########################################
\ No newline at end of file
+##########################################
diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs
new file mode 100644
index 0000000000..e6e79e0408
--- /dev/null
+++ b/.git-blame-ignore-revs
@@ -0,0 +1,4 @@
+# file-scoped namespaces and global usings
+5528a2923ccc63d776c91994b0b17a2c3ad5be94
+d14c82023fc01a6fca99c42212cb3c97991fae9e
+0e9a066195a100ae56b4ca49cee9927fb15e1482
\ No newline at end of file
diff --git a/README.md b/README.md
index 34466eccd7..cfa6fc7d67 100644
--- a/README.md
+++ b/README.md
@@ -77,6 +77,12 @@ To clone ImageSharp locally, click the "Clone in [YOUR_OS]" button above or run
git clone https://github.com/SixLabors/ImageSharp
```
+Then set the following config to ensure blame commands ignore mass reformatting commits.
+
+```bash
+git config blame.ignoreRevsFile .git-blame-ignore-revs
+```
+
If working with Windows please ensure that you have enabled long file paths in git (run as Administrator).
```bash
diff --git a/SixLabors.ImageSharp.props b/SixLabors.ImageSharp.props
new file mode 100644
index 0000000000..6ec4d8c594
--- /dev/null
+++ b/SixLabors.ImageSharp.props
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/shared-infrastructure b/shared-infrastructure
index 5eb77e2d9e..f79b8d073a 160000
--- a/shared-infrastructure
+++ b/shared-infrastructure
@@ -1 +1 @@
-Subproject commit 5eb77e2d9eb4f0ece012c996941ab78db1af2a41
+Subproject commit f79b8d073aeb2deb4cb095a9d4b94aa2be26c848
diff --git a/src/ImageSharp/Advanced/AdvancedImageExtensions.cs b/src/ImageSharp/Advanced/AdvancedImageExtensions.cs
index 2fbb429957..10267c8ef7 100644
--- a/src/ImageSharp/Advanced/AdvancedImageExtensions.cs
+++ b/src/ImageSharp/Advanced/AdvancedImageExtensions.cs
@@ -1,185 +1,179 @@
// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.
-using System;
-using System.Collections.Generic;
using System.Globalization;
-using System.IO;
using System.Text;
-using System.Threading;
-using System.Threading.Tasks;
using SixLabors.ImageSharp.Formats;
using SixLabors.ImageSharp.Memory;
using SixLabors.ImageSharp.PixelFormats;
-namespace SixLabors.ImageSharp.Advanced
+namespace SixLabors.ImageSharp.Advanced;
+
+///
+/// Extension methods over Image{TPixel}
+///
+public static class AdvancedImageExtensions
{
///
- /// Extension methods over Image{TPixel}
+ /// For a given file path find the best encoder to use via its extension.
///
- public static class AdvancedImageExtensions
+ /// The source image.
+ /// The target file path to save the image to.
+ /// The file path is null.
+ /// No encoder available for provided path.
+ /// The matching .
+ public static IImageEncoder DetectEncoder(this Image source, string filePath)
{
- ///
- /// For a given file path find the best encoder to use via its extension.
- ///
- /// The source image.
- /// The target file path to save the image to.
- /// The file path is null.
- /// No encoder available for provided path.
- /// The matching .
- public static IImageEncoder DetectEncoder(this Image source, string filePath)
- {
- Guard.NotNull(filePath, nameof(filePath));
+ Guard.NotNull(filePath, nameof(filePath));
- string ext = Path.GetExtension(filePath);
- IImageFormat format = source.GetConfiguration().ImageFormatsManager.FindFormatByFileExtension(ext);
- if (format is null)
+ string ext = Path.GetExtension(filePath);
+ IImageFormat format = source.GetConfiguration().ImageFormatsManager.FindFormatByFileExtension(ext);
+ if (format is null)
+ {
+ StringBuilder sb = new();
+ sb.AppendLine(CultureInfo.InvariantCulture, $"No encoder was found for extension '{ext}'. Registered encoders include:");
+ foreach (IImageFormat fmt in source.GetConfiguration().ImageFormats)
{
- StringBuilder sb = new();
- sb.AppendLine(CultureInfo.InvariantCulture, $"No encoder was found for extension '{ext}'. Registered encoders include:");
- foreach (IImageFormat fmt in source.GetConfiguration().ImageFormats)
- {
- sb.AppendFormat(CultureInfo.InvariantCulture, " - {0} : {1}{2}", fmt.Name, string.Join(", ", fmt.FileExtensions), Environment.NewLine);
- }
-
- throw new NotSupportedException(sb.ToString());
+ sb.AppendFormat(CultureInfo.InvariantCulture, " - {0} : {1}{2}", fmt.Name, string.Join(", ", fmt.FileExtensions), Environment.NewLine);
}
- IImageEncoder encoder = source.GetConfiguration().ImageFormatsManager.FindEncoder(format);
+ throw new NotSupportedException(sb.ToString());
+ }
+
+ IImageEncoder encoder = source.GetConfiguration().ImageFormatsManager.FindEncoder(format);
- if (encoder is null)
+ if (encoder is null)
+ {
+ StringBuilder sb = new();
+ sb.AppendLine(CultureInfo.InvariantCulture, $"No encoder was found for extension '{ext}' using image format '{format.Name}'. Registered encoders include:");
+ foreach (KeyValuePair enc in source.GetConfiguration().ImageFormatsManager.ImageEncoders)
{
- StringBuilder sb = new();
- sb.AppendLine(CultureInfo.InvariantCulture, $"No encoder was found for extension '{ext}' using image format '{format.Name}'. Registered encoders include:");
- foreach (KeyValuePair enc in source.GetConfiguration().ImageFormatsManager.ImageEncoders)
- {
- sb.AppendFormat(CultureInfo.InvariantCulture, " - {0} : {1}{2}", enc.Key, enc.Value.GetType().Name, Environment.NewLine);
- }
-
- throw new NotSupportedException(sb.ToString());
+ sb.AppendFormat(CultureInfo.InvariantCulture, " - {0} : {1}{2}", enc.Key, enc.Value.GetType().Name, Environment.NewLine);
}
- return encoder;
+ throw new NotSupportedException(sb.ToString());
}
- ///
- /// Accepts a to implement a double-dispatch pattern in order to
- /// apply pixel-specific operations on non-generic instances
- ///
- /// The source image.
- /// The image visitor.
- public static void AcceptVisitor(this Image source, IImageVisitor visitor)
- => source.Accept(visitor);
-
- ///
- /// Accepts a to implement a double-dispatch pattern in order to
- /// apply pixel-specific operations on non-generic instances
- ///
- /// The source image.
- /// The image visitor.
- /// The token to monitor for cancellation requests.
- /// A representing the asynchronous operation.
- public static Task AcceptVisitorAsync(this Image source, IImageVisitorAsync visitor, CancellationToken cancellationToken = default)
- => source.AcceptAsync(visitor, cancellationToken);
-
- ///
- /// Gets the configuration for the image.
- ///
- /// The source image.
- /// Returns the configuration.
- public static Configuration GetConfiguration(this Image source)
- => GetConfiguration((IConfigurationProvider)source);
-
- ///
- /// Gets the configuration for the image frame.
- ///
- /// The source image.
- /// Returns the configuration.
- public static Configuration GetConfiguration(this ImageFrame source)
- => GetConfiguration((IConfigurationProvider)source);
-
- ///
- /// Gets the configuration.
- ///
- /// The source image
- /// Returns the bounds of the image
- private static Configuration GetConfiguration(IConfigurationProvider source)
- => source?.Configuration ?? Configuration.Default;
-
- ///
- /// Gets the representation of the pixels as a containing the backing pixel data of the image
- /// stored in row major order, as a list of contiguous blocks in the source image's pixel format.
- ///
- /// The source image.
- /// The type of the pixel.
- /// The .
- ///
- /// Certain Image Processors may invalidate the returned and all it's buffers,
- /// therefore it's not recommended to mutate the image while holding a reference to it's .
- ///
- /// Thrown when the in .
- public static IMemoryGroup GetPixelMemoryGroup(this ImageFrame source)
- where TPixel : unmanaged, IPixel
- => source?.PixelBuffer.FastMemoryGroup.View ?? throw new ArgumentNullException(nameof(source));
-
- ///
- /// Gets the representation of the pixels as a containing the backing pixel data of the image
- /// stored in row major order, as a list of contiguous blocks in the source image's pixel format.
- ///
- /// The source image.
- /// The type of the pixel.
- /// The .
- ///
- /// Certain Image Processors may invalidate the returned and all it's buffers,
- /// therefore it's not recommended to mutate the image while holding a reference to it's .
- ///
- /// Thrown when the in .
- public static IMemoryGroup GetPixelMemoryGroup(this Image source)
- where TPixel : unmanaged, IPixel
- => source?.Frames.RootFrame.GetPixelMemoryGroup() ?? throw new ArgumentNullException(nameof(source));
-
- ///
- /// Gets the representation of the pixels as a of contiguous memory
- /// at row beginning from the first pixel on that row.
- ///
- /// The type of the pixel.
- /// The source.
- /// The row.
- /// The
- public static Memory DangerousGetPixelRowMemory(this ImageFrame source, int rowIndex)
- where TPixel : unmanaged, IPixel
- {
- Guard.NotNull(source, nameof(source));
- Guard.MustBeGreaterThanOrEqualTo(rowIndex, 0, nameof(rowIndex));
- Guard.MustBeLessThan(rowIndex, source.Height, nameof(rowIndex));
+ return encoder;
+ }
- return source.PixelBuffer.GetSafeRowMemory(rowIndex);
- }
+ ///
+ /// Accepts a to implement a double-dispatch pattern in order to
+ /// apply pixel-specific operations on non-generic instances
+ ///
+ /// The source image.
+ /// The image visitor.
+ public static void AcceptVisitor(this Image source, IImageVisitor visitor)
+ => source.Accept(visitor);
- ///
- /// Gets the representation of the pixels as of contiguous memory
- /// at row beginning from the first pixel on that row.
- ///
- /// The type of the pixel.
- /// The source.
- /// The row.
- /// The
- public static Memory DangerousGetPixelRowMemory(this Image source, int rowIndex)
- where TPixel : unmanaged, IPixel
- {
- Guard.NotNull(source, nameof(source));
- Guard.MustBeGreaterThanOrEqualTo(rowIndex, 0, nameof(rowIndex));
- Guard.MustBeLessThan(rowIndex, source.Height, nameof(rowIndex));
+ ///
+ /// Accepts a to implement a double-dispatch pattern in order to
+ /// apply pixel-specific operations on non-generic instances
+ ///
+ /// The source image.
+ /// The image visitor.
+ /// The token to monitor for cancellation requests.
+ /// A representing the asynchronous operation.
+ public static Task AcceptVisitorAsync(this Image source, IImageVisitorAsync visitor, CancellationToken cancellationToken = default)
+ => source.AcceptAsync(visitor, cancellationToken);
- return source.Frames.RootFrame.PixelBuffer.GetSafeRowMemory(rowIndex);
- }
+ ///
+ /// Gets the configuration for the image.
+ ///
+ /// The source image.
+ /// Returns the configuration.
+ public static Configuration GetConfiguration(this Image source)
+ => GetConfiguration((IConfigurationProvider)source);
+
+ ///
+ /// Gets the configuration for the image frame.
+ ///
+ /// The source image.
+ /// Returns the configuration.
+ public static Configuration GetConfiguration(this ImageFrame source)
+ => GetConfiguration((IConfigurationProvider)source);
+
+ ///
+ /// Gets the configuration.
+ ///
+ /// The source image
+ /// Returns the bounds of the image
+ private static Configuration GetConfiguration(IConfigurationProvider source)
+ => source?.Configuration ?? Configuration.Default;
+
+ ///
+ /// Gets the representation of the pixels as a containing the backing pixel data of the image
+ /// stored in row major order, as a list of contiguous blocks in the source image's pixel format.
+ ///
+ /// The source image.
+ /// The type of the pixel.
+ /// The .
+ ///
+ /// Certain Image Processors may invalidate the returned and all it's buffers,
+ /// therefore it's not recommended to mutate the image while holding a reference to it's .
+ ///
+ /// Thrown when the in .
+ public static IMemoryGroup GetPixelMemoryGroup(this ImageFrame source)
+ where TPixel : unmanaged, IPixel
+ => source?.PixelBuffer.FastMemoryGroup.View ?? throw new ArgumentNullException(nameof(source));
- ///
- /// Gets the assigned to 'source'.
- ///
- /// The source image.
- /// Returns the configuration.
- internal static MemoryAllocator GetMemoryAllocator(this IConfigurationProvider source)
- => GetConfiguration(source).MemoryAllocator;
+ ///
+ /// Gets the representation of the pixels as a containing the backing pixel data of the image
+ /// stored in row major order, as a list of contiguous blocks in the source image's pixel format.
+ ///
+ /// The source image.
+ /// The type of the pixel.
+ /// The .
+ ///
+ /// Certain Image Processors may invalidate the returned and all it's buffers,
+ /// therefore it's not recommended to mutate the image while holding a reference to it's .
+ ///
+ /// Thrown when the in .
+ public static IMemoryGroup GetPixelMemoryGroup(this Image source)
+ where TPixel : unmanaged, IPixel
+ => source?.Frames.RootFrame.GetPixelMemoryGroup() ?? throw new ArgumentNullException(nameof(source));
+
+ ///
+ /// Gets the representation of the pixels as a of contiguous memory
+ /// at row beginning from the first pixel on that row.
+ ///
+ /// The type of the pixel.
+ /// The source.
+ /// The row.
+ /// The
+ public static Memory DangerousGetPixelRowMemory(this ImageFrame source, int rowIndex)
+ where TPixel : unmanaged, IPixel
+ {
+ Guard.NotNull(source, nameof(source));
+ Guard.MustBeGreaterThanOrEqualTo(rowIndex, 0, nameof(rowIndex));
+ Guard.MustBeLessThan(rowIndex, source.Height, nameof(rowIndex));
+
+ return source.PixelBuffer.GetSafeRowMemory(rowIndex);
+ }
+
+ ///
+ /// Gets the representation of the pixels as of contiguous memory
+ /// at row beginning from the first pixel on that row.
+ ///
+ /// The type of the pixel.
+ /// The source.
+ /// The row.
+ /// The
+ public static Memory DangerousGetPixelRowMemory(this Image source, int rowIndex)
+ where TPixel : unmanaged, IPixel
+ {
+ Guard.NotNull(source, nameof(source));
+ Guard.MustBeGreaterThanOrEqualTo(rowIndex, 0, nameof(rowIndex));
+ Guard.MustBeLessThan(rowIndex, source.Height, nameof(rowIndex));
+
+ return source.Frames.RootFrame.PixelBuffer.GetSafeRowMemory(rowIndex);
}
+
+ ///
+ /// Gets the assigned to 'source'.
+ ///
+ /// The source image.
+ /// Returns the configuration.
+ internal static MemoryAllocator GetMemoryAllocator(this IConfigurationProvider source)
+ => GetConfiguration(source).MemoryAllocator;
}
diff --git a/src/ImageSharp/Advanced/AotCompilerTools.cs b/src/ImageSharp/Advanced/AotCompilerTools.cs
index 1732a6bdbf..9c285e21de 100644
--- a/src/ImageSharp/Advanced/AotCompilerTools.cs
+++ b/src/ImageSharp/Advanced/AotCompilerTools.cs
@@ -1,7 +1,6 @@
// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.
-using System;
using System.Diagnostics.CodeAnalysis;
using System.Numerics;
using System.Runtime.CompilerServices;
@@ -30,534 +29,533 @@
using SixLabors.ImageSharp.Processing.Processors.Quantization;
using SixLabors.ImageSharp.Processing.Processors.Transforms;
-namespace SixLabors.ImageSharp.Advanced
+namespace SixLabors.ImageSharp.Advanced;
+
+///
+/// Unlike traditional Mono/.NET, code on the iPhone is statically compiled ahead of time instead of being
+/// compiled on demand by a JIT compiler. This means there are a few limitations with respect to generics,
+/// these are caused because not every possible generic instantiation can be determined up front at compile time.
+/// The Aot Compiler is designed to overcome the limitations of this compiler.
+/// None of the methods in this class should ever be called, the code only has to exist at compile-time to be picked up by the AoT compiler.
+/// (Very similar to the LinkerIncludes.cs technique used in Xamarin.Android projects.)
+///
+[ExcludeFromCodeCoverage]
+internal static class AotCompilerTools
{
///
- /// Unlike traditional Mono/.NET, code on the iPhone is statically compiled ahead of time instead of being
- /// compiled on demand by a JIT compiler. This means there are a few limitations with respect to generics,
- /// these are caused because not every possible generic instantiation can be determined up front at compile time.
- /// The Aot Compiler is designed to overcome the limitations of this compiler.
- /// None of the methods in this class should ever be called, the code only has to exist at compile-time to be picked up by the AoT compiler.
- /// (Very similar to the LinkerIncludes.cs technique used in Xamarin.Android projects.)
+ /// This is the method that seeds the AoT compiler.
+ /// None of these seed methods needs to actually be called to seed the compiler.
+ /// The calls just need to be present when the code is compiled, and each implementation will be built.
///
- [ExcludeFromCodeCoverage]
- internal static class AotCompilerTools
+ ///
+ /// This method doesn't actually do anything but serves an important purpose...
+ /// If you are running ImageSharp on iOS and try to call SaveAsGif, it will throw an exception:
+ /// "Attempting to JIT compile method... OctreeFrameQuantizer.ConstructPalette... while running in aot-only mode."
+ /// The reason this happens is the SaveAsGif method makes heavy use of generics, which are too confusing for the AoT
+ /// compiler used on Xamarin.iOS. It spins up the JIT compiler to try and figure it out, but that is an illegal op on
+ /// iOS so it bombs out.
+ /// If you are getting the above error, you need to call this method, which will pre-seed the AoT compiler with the
+ /// necessary methods to complete the SaveAsGif call. That's it, otherwise you should NEVER need this method!!!
+ ///
+ [Preserve]
+ private static void SeedPixelFormats()
{
- ///
- /// This is the method that seeds the AoT compiler.
- /// None of these seed methods needs to actually be called to seed the compiler.
- /// The calls just need to be present when the code is compiled, and each implementation will be built.
- ///
- ///
- /// This method doesn't actually do anything but serves an important purpose...
- /// If you are running ImageSharp on iOS and try to call SaveAsGif, it will throw an exception:
- /// "Attempting to JIT compile method... OctreeFrameQuantizer.ConstructPalette... while running in aot-only mode."
- /// The reason this happens is the SaveAsGif method makes heavy use of generics, which are too confusing for the AoT
- /// compiler used on Xamarin.iOS. It spins up the JIT compiler to try and figure it out, but that is an illegal op on
- /// iOS so it bombs out.
- /// If you are getting the above error, you need to call this method, which will pre-seed the AoT compiler with the
- /// necessary methods to complete the SaveAsGif call. That's it, otherwise you should NEVER need this method!!!
- ///
- [Preserve]
- private static void SeedPixelFormats()
+ try
{
- try
- {
- Unsafe.SizeOf();
- Unsafe.SizeOf();
- Unsafe.SizeOf();
- Unsafe.SizeOf();
- Unsafe.SizeOf();
- Unsafe.SizeOf();
- Unsafe.SizeOf();
- Unsafe.SizeOf();
- Unsafe.SizeOf();
-
- Seed();
- Seed();
- Seed();
- Seed();
- Seed();
- Seed();
- Seed();
- Seed();
- Seed();
- Seed();
- Seed();
- Seed();
- Seed();
- Seed();
- Seed();
- Seed();
- Seed();
- Seed();
- Seed();
- Seed();
- Seed();
- Seed();
- Seed();
- Seed();
- Seed();
- Seed();
- Seed();
- Seed();
- Seed();
- }
- catch
- {
- // nop
- }
-
- throw new InvalidOperationException("This method is used for AOT code generation only. Do not call it at runtime.");
+ Unsafe.SizeOf();
+ Unsafe.SizeOf();
+ Unsafe.SizeOf();
+ Unsafe.SizeOf();
+ Unsafe.SizeOf();
+ Unsafe.SizeOf();
+ Unsafe.SizeOf();
+ Unsafe.SizeOf();
+ Unsafe.SizeOf();
+
+ Seed();
+ Seed();
+ Seed();
+ Seed();
+ Seed();
+ Seed();
+ Seed();
+ Seed();
+ Seed();
+ Seed();
+ Seed();
+ Seed();
+ Seed();
+ Seed();
+ Seed();
+ Seed();
+ Seed();
+ Seed();
+ Seed();
+ Seed();
+ Seed();
+ Seed();
+ Seed();
+ Seed();
+ Seed();
+ Seed();
+ Seed();
+ Seed();
+ Seed();
}
-
- ///
- /// Seeds the compiler using the given pixel format.
- ///
- /// The pixel format.
- [Preserve]
- private static void Seed()
- where TPixel : unmanaged, IPixel
+ catch
{
- // This is we actually call all the individual methods you need to seed.
- AotCompileImage();
- AotCompileImageProcessingContextFactory();
- AotCompileImageEncoderInternals();
- AotCompileImageDecoderInternals();
- AotCompileImageEncoders();
- AotCompileImageDecoders();
- AotCompileImageProcessors();
- AotCompileGenericImageProcessors();
- AotCompileResamplers();
- AotCompileQuantizers();
- AotCompilePixelSamplingStrategys();
- AotCompileDithers();
- AotCompileMemoryManagers();
-
- Unsafe.SizeOf();
-
- // TODO: Do the discovery work to figure out what works and what doesn't.
+ // nop
}
- ///
- /// This method pre-seeds the for a given pixel format in the AoT compiler.
- ///
- /// The pixel format.
- [Preserve]
- private static unsafe void AotCompileImage()
- where TPixel : unmanaged, IPixel
- {
- Image img = default;
- img.CloneAs(default);
- img.CloneAs(default);
- img.CloneAs(default);
- img.CloneAs(default);
- img.CloneAs(default);
- img.CloneAs(default);
- img.CloneAs(default);
- img.CloneAs(default);
- img.CloneAs(default);
- img.CloneAs(default);
- img.CloneAs(default);
- img.CloneAs(default);
- img.CloneAs(default);
- img.CloneAs(default);
- img.CloneAs(default);
- img.CloneAs(default);
- img.CloneAs(default);
- img.CloneAs(default);
- img.CloneAs(default);
- img.CloneAs(default);
- img.CloneAs(default);
- img.CloneAs(default);
- img.CloneAs(default);
- img.CloneAs(default);
- img.CloneAs(default);
- img.CloneAs(default);
- img.CloneAs(default);
- img.CloneAs(default);
- img.CloneAs(default);
-
- ImageFrame.LoadPixelData(default, default(ReadOnlySpan), default, default);
- ImageFrame.LoadPixelData(default, default(ReadOnlySpan), default, default);
- }
+ throw new InvalidOperationException("This method is used for AOT code generation only. Do not call it at runtime.");
+ }
- ///
- /// This method pre-seeds the all in the AoT compiler.
- ///
- /// The pixel format.
- [Preserve]
- private static void AotCompileImageProcessingContextFactory()
- where TPixel : unmanaged, IPixel
- => default(DefaultImageOperationsProviderFactory).CreateImageProcessingContext(default, default, default);
-
- ///
- /// This method pre-seeds the all in the AoT compiler.
- ///
- /// The pixel format.
- [Preserve]
- private static void AotCompileImageEncoderInternals()
- where TPixel : unmanaged, IPixel
- {
- default(WebpEncoderCore).Encode(default, default, default);
- default(BmpEncoderCore).Encode(default, default, default);
- default(GifEncoderCore).Encode(default, default, default);
- default(JpegEncoderCore).Encode(default, default, default);
- default(PbmEncoderCore).Encode(default, default, default);
- default(PngEncoderCore).Encode(default, default, default);
- default(TgaEncoderCore).Encode(default, default, default);
- default(TiffEncoderCore).Encode(default, default, default);
- }
+ ///
+ /// Seeds the compiler using the given pixel format.
+ ///
+ /// The pixel format.
+ [Preserve]
+ private static void Seed()
+ where TPixel : unmanaged, IPixel
+ {
+ // This is we actually call all the individual methods you need to seed.
+ AotCompileImage();
+ AotCompileImageProcessingContextFactory();
+ AotCompileImageEncoderInternals();
+ AotCompileImageDecoderInternals();
+ AotCompileImageEncoders();
+ AotCompileImageDecoders();
+ AotCompileImageProcessors();
+ AotCompileGenericImageProcessors();
+ AotCompileResamplers();
+ AotCompileQuantizers();
+ AotCompilePixelSamplingStrategys();
+ AotCompileDithers();
+ AotCompileMemoryManagers();
+
+ Unsafe.SizeOf();
+
+ // TODO: Do the discovery work to figure out what works and what doesn't.
+ }
- ///
- /// This method pre-seeds the all in the AoT compiler.
- ///
- /// The pixel format.
- [Preserve]
- private static void AotCompileImageDecoderInternals()
- where TPixel : unmanaged, IPixel
- {
- default(WebpDecoderCore).Decode(default, default);
- default(BmpDecoderCore).Decode(default, default);
- default(GifDecoderCore).Decode(default, default);
- default(JpegDecoderCore).Decode(default, default);
- default(PbmDecoderCore).Decode(default, default);
- default(PngDecoderCore).Decode(default, default);
- default(TgaDecoderCore).Decode(default, default);
- default(TiffDecoderCore).Decode(default, default);
- }
+ ///
+ /// This method pre-seeds the for a given pixel format in the AoT compiler.
+ ///
+ /// The pixel format.
+ [Preserve]
+ private static unsafe void AotCompileImage()
+ where TPixel : unmanaged, IPixel
+ {
+ Image img = default;
+ img.CloneAs(default);
+ img.CloneAs(default);
+ img.CloneAs(default);
+ img.CloneAs(default);
+ img.CloneAs(default);
+ img.CloneAs(default);
+ img.CloneAs(default);
+ img.CloneAs(default);
+ img.CloneAs(default);
+ img.CloneAs(default);
+ img.CloneAs(default);
+ img.CloneAs(default);
+ img.CloneAs(default);
+ img.CloneAs(default);
+ img.CloneAs(default);
+ img.CloneAs(default);
+ img.CloneAs(default);
+ img.CloneAs(default);
+ img.CloneAs(default);
+ img.CloneAs(default);
+ img.CloneAs(default);
+ img.CloneAs(default);
+ img.CloneAs(default);
+ img.CloneAs(default);
+ img.CloneAs(default);
+ img.CloneAs(default);
+ img.CloneAs(default);
+ img.CloneAs(default);
+ img.CloneAs(default);
+
+ ImageFrame.LoadPixelData(default, default(ReadOnlySpan), default, default);
+ ImageFrame.LoadPixelData(default, default(ReadOnlySpan), default, default);
+ }
- ///
- /// This method pre-seeds the all in the AoT compiler.
- ///
- /// The pixel format.
- [Preserve]
- private static void AotCompileImageEncoders()
- where TPixel : unmanaged, IPixel
- {
- AotCompileImageEncoder();
- AotCompileImageEncoder();
- AotCompileImageEncoder();
- AotCompileImageEncoder();
- AotCompileImageEncoder();
- AotCompileImageEncoder();
- AotCompileImageEncoder();
- AotCompileImageEncoder();
- }
+ ///
+ /// This method pre-seeds the all in the AoT compiler.
+ ///
+ /// The pixel format.
+ [Preserve]
+ private static void AotCompileImageProcessingContextFactory()
+ where TPixel : unmanaged, IPixel
+ => default(DefaultImageOperationsProviderFactory).CreateImageProcessingContext(default, default, default);
- ///
- /// This method pre-seeds the all in the AoT compiler.
- ///
- /// The pixel format.
- [Preserve]
- private static void AotCompileImageDecoders()
- where TPixel : unmanaged, IPixel
- {
- AotCompileImageDecoder();
- AotCompileImageDecoder();
- AotCompileImageDecoder();
- AotCompileImageDecoder();
- AotCompileImageDecoder