Browse Source

Merge branch 'master' into af/discontinuous-buffers

af/octree-no-pixelmap
Anton Firszov 6 years ago
parent
commit
44c7b7a863
  1. 7
      .editorconfig
  2. 4
      .gitattributes
  3. 3
      Directory.Build.props
  4. 8
      README.md
  5. 4
      codecov.yml
  6. 2
      shared-infrastructure
  7. 3
      src/Directory.Build.props
  8. 28
      src/ImageSharp/Advanced/AdvancedImageExtensions.cs
  9. 4
      src/ImageSharp/Advanced/AotCompilerTools.cs
  10. 16
      src/ImageSharp/Advanced/IConfigurable.cs
  11. 16
      src/ImageSharp/Advanced/IConfigurationProvider.cs
  12. 2
      src/ImageSharp/Advanced/ParallelUtils/ParallelHelper.cs
  13. 2
      src/ImageSharp/Configuration.cs
  14. 5
      src/ImageSharp/Formats/Gif/GifDecoderCore.cs
  15. 2
      src/ImageSharp/Formats/Gif/GifEncoder.cs
  16. 23
      src/ImageSharp/Formats/Gif/GifEncoderCore.cs
  17. 4
      src/ImageSharp/Formats/Gif/GifMetadata.cs
  18. 8
      src/ImageSharp/Formats/Jpeg/Components/Encoder/YCbCrForwardConverter{TPixel}.cs
  19. 22
      src/ImageSharp/Image.cs
  20. 28
      src/ImageSharp/ImageFrame.cs
  21. 12
      src/ImageSharp/ImageFrame{TPixel}.cs
  22. 2
      src/ImageSharp/Image{TPixel}.cs
  23. 28
      src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.TagDataEntry.cs
  24. 2
      src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccLutAToBTagDataEntry.cs
  25. 2
      src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccLutBToATagDataEntry.cs
  26. 3
      src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccXyzTagDataEntry.cs
  27. 98
      src/ImageSharp/PixelFormats/PixelImplementations/Generated/Argb32.PixelOperations.Generated.cs
  28. 86
      src/ImageSharp/PixelFormats/PixelImplementations/Generated/Bgr24.PixelOperations.Generated.cs
  29. 98
      src/ImageSharp/PixelFormats/PixelImplementations/Generated/Bgra32.PixelOperations.Generated.cs
  30. 80
      src/ImageSharp/PixelFormats/PixelImplementations/Generated/Bgra5551.PixelOperations.Generated.cs
  31. 80
      src/ImageSharp/PixelFormats/PixelImplementations/Generated/L16.PixelOperations.Generated.cs
  32. 80
      src/ImageSharp/PixelFormats/PixelImplementations/Generated/L8.PixelOperations.Generated.cs
  33. 80
      src/ImageSharp/PixelFormats/PixelImplementations/Generated/La16.PixelOperations.Generated.cs
  34. 80
      src/ImageSharp/PixelFormats/PixelImplementations/Generated/La32.PixelOperations.Generated.cs
  35. 86
      src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgb24.PixelOperations.Generated.cs
  36. 82
      src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgb48.PixelOperations.Generated.cs
  37. 94
      src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgba32.PixelOperations.Generated.cs
  38. 82
      src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgba64.PixelOperations.Generated.cs
  39. 36
      src/ImageSharp/PixelFormats/PixelImplementations/Generated/_Common.ttinclude
  40. 18
      src/ImageSharp/PixelFormats/PixelImplementations/Rgba32.PixelOperations.cs
  41. 26
      src/ImageSharp/PixelFormats/PixelImplementations/RgbaVector.PixelOperations.cs
  42. 288
      src/ImageSharp/PixelFormats/PixelOperations{TPixel}.Generated.cs
  43. 24
      src/ImageSharp/PixelFormats/PixelOperations{TPixel}.Generated.tt
  44. 43
      src/ImageSharp/PixelFormats/PixelOperations{TPixel}.cs
  45. 10
      src/ImageSharp/Primitives/ColorMatrix.cs
  46. 102
      src/ImageSharp/Processing/Extensions/Effects/PixelRowDelegateExtensions.cs
  47. 102
      src/ImageSharp/Processing/Extensions/Effects/PixelShaderExtensions.cs
  48. 27
      src/ImageSharp/Processing/PixelRowOperation.cs
  49. 15
      src/ImageSharp/Processing/PixelShader.cs
  50. 16
      src/ImageSharp/Processing/PositionAwarePixelShader.cs
  51. 39
      src/ImageSharp/Processing/Processors/Effects/PixelRowDelegateProcessor.cs
  52. 21
      src/ImageSharp/Processing/Processors/Effects/PixelRowDelegateProcessorBase{TPixel}.cs
  53. 18
      src/ImageSharp/Processing/Processors/Effects/PixelRowDelegateProcessor{TPixel}.cs
  54. 58
      src/ImageSharp/Processing/Processors/Effects/PixelShaderProcessor.cs
  55. 39
      src/ImageSharp/Processing/Processors/Effects/PositionAwarePixelRowDelegateProcessor.cs
  56. 19
      src/ImageSharp/Processing/Processors/Effects/PositionAwarePixelRowDelegateProcessor{TPixel}.cs
  57. 58
      src/ImageSharp/Processing/Processors/Effects/PositionAwarePixelShaderProcessor.cs
  58. 10
      src/ImageSharp/Processing/Processors/Overlays/BackgroundColorProcessor{TPixel}.cs
  59. 8
      src/ImageSharp/Processing/Processors/Overlays/GlowProcessor{TPixel}.cs
  60. 8
      src/ImageSharp/Processing/Processors/Overlays/VignetteProcessor{TPixel}.cs
  61. 22
      src/ImageSharp/Processing/Processors/Quantization/FrameQuantizer{TPixel}.cs
  62. 10
      src/ImageSharp/Processing/Processors/Quantization/OctreeFrameQuantizer{TPixel}.cs
  63. 8
      src/ImageSharp/Processing/Processors/Quantization/OctreeQuantizer.cs
  64. 5
      src/ImageSharp/Processing/Processors/Quantization/PaletteFrameQuantizer{TPixel}.cs
  65. 4
      src/ImageSharp/Processing/Processors/Quantization/PaletteQuantizer.cs
  66. 42
      src/ImageSharp/Processing/Processors/Quantization/WuFrameQuantizer{TPixel}.cs
  67. 9
      src/ImageSharp/Processing/Processors/Quantization/WuQuantizer.cs
  68. 23
      tests/ImageSharp.Benchmarks/Codecs/DecodeTga.cs
  69. 16
      tests/ImageSharp.Benchmarks/Codecs/EncodeBmpMultiple.cs
  70. 13
      tests/ImageSharp.Benchmarks/Codecs/EncodeGifMultiple.cs
  71. 2
      tests/ImageSharp.Benchmarks/Codecs/EncodeTga.cs
  72. 5
      tests/ImageSharp.Benchmarks/Codecs/ImageBenchmarkTests.cs
  73. 6
      tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_CopyTo1x1.cs
  74. 7
      tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_CopyTo2x2.cs
  75. 19
      tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_DivideRound.cs
  76. 7
      tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_LoadFromInt16.cs
  77. 3
      tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_Round.cs
  78. 2
      tests/ImageSharp.Benchmarks/Codecs/Jpeg/DecodeJpegParseStreamOnly.cs
  79. 6
      tests/ImageSharp.Benchmarks/Codecs/Jpeg/DecodeJpeg_Aggregate.cs
  80. 41
      tests/ImageSharp.Benchmarks/Codecs/Jpeg/DecodeJpeg_ImageSpecific.cs
  81. 49
      tests/ImageSharp.Benchmarks/Codecs/Jpeg/DoubleBufferedStreams.cs
  82. 9
      tests/ImageSharp.Benchmarks/Codecs/Jpeg/EncodeJpeg.cs
  83. 16
      tests/ImageSharp.Benchmarks/Codecs/Jpeg/EncodeJpegMultiple.cs
  84. 6
      tests/ImageSharp.Benchmarks/Codecs/Jpeg/LoadResizeSave_Aggregate.cs
  85. 22
      tests/ImageSharp.Benchmarks/Codecs/Jpeg/LoadResizeSave_ImageSpecific.cs
  86. 2
      tests/ImageSharp.Benchmarks/Codecs/Jpeg/YCbCrColorConversion.cs
  87. 55
      tests/ImageSharp.Benchmarks/Codecs/MultiImageBenchmarkBase.cs
  88. 14
      tests/ImageSharp.Benchmarks/Color/Bulk/FromRgba32Bytes.cs
  89. 13
      tests/ImageSharp.Benchmarks/Color/Bulk/FromVector4.cs
  90. 5
      tests/ImageSharp.Benchmarks/Color/Bulk/Rgb24Bytes.cs
  91. 5
      tests/ImageSharp.Benchmarks/Color/Bulk/ToRgba32Bytes.cs
  92. 18
      tests/ImageSharp.Benchmarks/Color/Bulk/ToVector4.cs
  93. 5
      tests/ImageSharp.Benchmarks/Color/Bulk/ToVector4_Bgra32.cs
  94. 68
      tests/ImageSharp.Benchmarks/Color/Bulk/ToVector4_Rgba32.cs
  95. 8
      tests/ImageSharp.Benchmarks/Color/ColorspaceCieXyzToCieLabConvert.cs
  96. 7
      tests/ImageSharp.Benchmarks/Color/ColorspaceCieXyzToHunterLabConvert.cs
  97. 5
      tests/ImageSharp.Benchmarks/Color/ColorspaceCieXyzToLmsConvert.cs
  98. 10
      tests/ImageSharp.Benchmarks/Color/ColorspaceCieXyzToRgbConvert.cs
  99. 7
      tests/ImageSharp.Benchmarks/Color/RgbToYCbCr.LookupTables.cs
  100. 11
      tests/ImageSharp.Benchmarks/Color/RgbToYCbCr.cs

7
.editorconfig

@ -339,6 +339,7 @@ csharp_space_between_square_brackets = false
# warn when using var for built-in types,
# warn when using var when the type is not apparent, and
# warn when not using var when the type is apparent
# warn when using simplified "using" declaration
###############################################################################
[*.cs]
csharp_prefer_braces = true:silent
@ -367,6 +368,8 @@ csharp_style_throw_expression = true:suggestion
csharp_style_unused_value_expression_statement_preference = discard_variable:silent
csharp_style_unused_value_assignment_preference = discard_variable:suggestion
csharp_style_var_for_built_in_types = false:warning
csharp_style_var_elsewhere = false:warning
csharp_style_var_for_built_in_types = false:silent
csharp_style_var_when_type_is_apparent = true:warning
csharp_style_var_elsewhere = false:warning
csharp_prefer_simple_using_statement = false:silent

4
.gitattributes

@ -71,15 +71,17 @@
*.gif binary
*.jpg binary
*.ktx binary
*.otf binary
*.pbm binary
*.pdf binary
*.png binary
*.ppt binary
*.pptx binary
*.pvr binary
*.ttf binary
*.snk binary
*.tga binary
*.ttc binary
*.ttf binary
*.woff binary
*.woff2 binary
*.xls binary

3
Directory.Build.props

@ -103,8 +103,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.Net.Compilers.Toolset" IsImplicitlyDefined="true" />
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" IsImplicitlyDefined="true" />
<!--TODO: Enable this once tests Stylecop issues are fixed-->
<!--<PackageReference Include="StyleCop.Analyzers" IsImplicitlyDefined="true" />-->
<PackageReference Include="StyleCop.Analyzers" IsImplicitlyDefined="true" />
<AdditionalFiles Include="$(MSBuildThisFileDirectory)shared-infrastructure\stylecop.json" />
<!--NuGet package icon source-->
<None Include="$(MSBuildThisFileDirectory)shared-infrastructure\branding\icons\imagesharp\sixlabors.imagesharp.128.png" Pack="true" PackagePath="\icon.png" />

8
README.md

@ -9,6 +9,7 @@ SixLabors.ImageSharp
<div align="center">
[![Build Status](https://img.shields.io/github/workflow/status/SixLabors/ImageSharp/Build/master)](https://github.com/SixLabors/ImageSharp/actions)
[![Code coverage](https://codecov.io/gh/SixLabors/ImageSharp/branch/master/graph/badge.svg)](https://codecov.io/gh/SixLabors/ImageSharp)
[![GitHub license](https://img.shields.io/badge/license-Apache%202-blue.svg)](https://raw.githubusercontent.com/SixLabors/ImageSharp/master/LICENSE)
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/ImageSharp/General?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Twitter](https://img.shields.io/twitter/url/http/shields.io.svg?style=flat&logo=twitter)](https://twitter.com/intent/tweet?hashtags=imagesharp,dotnet,oss&text=ImageSharp.+A+new+cross-platform+2D+graphics+API+in+C%23&url=https%3a%2f%2fgithub.com%2fSixLabors%2fImageSharp&via=sixlabors)
@ -46,13 +47,6 @@ The **ImageSharp** library is made up of multiple packages:
- Transform methods like Resize, Crop, Skew, Rotate - anything that alters the dimensions of the image
- Non-transform methods like Gaussian Blur, Pixelate, Edge Detection - anything that maintains the original image dimensions
<!--
### Build Status
|Build Status|Code Coverage|
|:----------:|:-----------:|
|[![Build Status](https://img.shields.io/github/workflow/status/SixLabors/ImageSharp/Build/master)](https://github.com/SixLabors/ImageSharp/actions)|[![Code coverage](https://codecov.io/gh/SixLabors/ImageSharp/branch/master/graph/badge.svg)](https://codecov.io/gh/SixLabors/ImageSharp)|
-->
### Questions?
- Do you have questions? We are happy to help! Please [join our gitter channel](https://gitter.im/ImageSharp/General), or ask them on [stackoverflow](https://stackoverflow.com) using the `ImageSharp` tag. **Do not** open issues for questions!

4
codecov.yml

@ -5,3 +5,7 @@ codecov:
# https://github.com/codecov/support/issues/363
# https://docs.codecov.io/docs/comparing-commits
allow_coverage_offsets: true
# Avoid Report Expired
# https://docs.codecov.io/docs/codecov-yaml#section-expired-reports
max_report_age: off

2
shared-infrastructure

@ -1 +1 @@
Subproject commit 36b2d55f5bb0d91024955bd26ba220ee41cc96e5
Subproject commit a75469fdb93fb89b39a5b0b7c01cb7432ceef98f

3
src/Directory.Build.props

@ -27,9 +27,6 @@
</PropertyGroup>
<ItemGroup>
<!--TODO: Delete this once tests Stylecop issues are fixed-->
<PackageReference Include="StyleCop.Analyzers" IsImplicitlyDefined="true" />
<InternalsVisibleTo Include="DynamicProxyGenAssembly2" PublicKey="0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7" />
<InternalsVisibleTo Include="DynamicProxyGenAssembly2, PublicKeyToken=null" />
<InternalsVisibleTo Include="ImageSharp.Benchmarks" />

28
src/ImageSharp/Advanced/AdvancedImageExtensions.cs

@ -29,7 +29,23 @@ namespace SixLabors.ImageSharp.Advanced
/// <param name="source">The source image.</param>
/// <returns>Returns the configuration.</returns>
public static Configuration GetConfiguration(this Image source)
=> GetConfiguration((IConfigurable)source);
=> GetConfiguration((IConfigurationProvider)source);
/// <summary>
/// Gets the configuration for the image frame.
/// </summary>
/// <param name="source">The source image.</param>
/// <returns>Returns the configuration.</returns>
public static Configuration GetConfiguration(this ImageFrame source)
=> GetConfiguration((IConfigurationProvider)source);
/// <summary>
/// Gets the configuration .
/// </summary>
/// <param name="source">The source image</param>
/// <returns>Returns the bounds of the image</returns>
private static Configuration GetConfiguration(IConfigurationProvider source)
=> source?.Configuration ?? Configuration.Default;
/// <summary>
/// Gets the representation of the pixels as a <see cref="Span{T}"/> of contiguous memory in the source image's pixel format
@ -158,17 +174,9 @@ namespace SixLabors.ImageSharp.Advanced
/// </summary>
/// <param name="source">The source image.</param>
/// <returns>Returns the configuration.</returns>
internal static MemoryAllocator GetMemoryAllocator(this IConfigurable source)
internal static MemoryAllocator GetMemoryAllocator(this IConfigurationProvider source)
=> GetConfiguration(source).MemoryAllocator;
/// <summary>
/// Gets the configuration.
/// </summary>
/// <param name="source">The source image</param>
/// <returns>Returns the bounds of the image</returns>
private static Configuration GetConfiguration(IConfigurable source)
=> source?.Configuration ?? Configuration.Default;
/// <summary>
/// Returns a reference to the 0th element of the Pixel buffer.
/// Such a reference can be used for pinning but must never be dereferenced.

4
src/ImageSharp/Advanced/AotCompilerTools.cs

@ -109,7 +109,7 @@ namespace SixLabors.ImageSharp.Advanced
private static void AotCompileOctreeQuantizer<TPixel>()
where TPixel : struct, IPixel<TPixel>
{
using (var test = new OctreeFrameQuantizer<TPixel>(new OctreeQuantizer(false)))
using (var test = new OctreeFrameQuantizer<TPixel>(Configuration.Default, new OctreeQuantizer(false)))
{
test.AotGetPalette();
}
@ -122,7 +122,7 @@ namespace SixLabors.ImageSharp.Advanced
private static void AotCompileWuQuantizer<TPixel>()
where TPixel : struct, IPixel<TPixel>
{
using (var test = new WuFrameQuantizer<TPixel>(Configuration.Default.MemoryAllocator, new WuQuantizer(false)))
using (var test = new WuFrameQuantizer<TPixel>(Configuration.Default, new WuQuantizer(false)))
{
test.QuantizeFrame(new ImageFrame<TPixel>(Configuration.Default, 1, 1));
test.AotGetPalette();

16
src/ImageSharp/Advanced/IConfigurable.cs

@ -1,16 +0,0 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
namespace SixLabors.ImageSharp.Advanced
{
/// <summary>
/// Encapsulates the properties for configuration.
/// </summary>
internal interface IConfigurable
{
/// <summary>
/// Gets the configuration.
/// </summary>
Configuration Configuration { get; }
}
}

16
src/ImageSharp/Advanced/IConfigurationProvider.cs

@ -0,0 +1,16 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
namespace SixLabors.ImageSharp.Advanced
{
/// <summary>
/// Defines the contract for objects that can provide access to configuration.
/// </summary>
internal interface IConfigurationProvider
{
/// <summary>
/// Gets the configuration which allows altering default behaviour or extending the library.
/// </summary>
Configuration Configuration { get; }
}
}

2
src/ImageSharp/Advanced/ParallelUtils/ParallelHelper.cs

@ -26,7 +26,7 @@ namespace SixLabors.ImageSharp.Advanced.ParallelUtils
/// <param name="body">The method body defining the iteration logic on a single <see cref="RowInterval"/>.</param>
public static void IterateRows(Rectangle rectangle, Configuration configuration, Action<RowInterval> body)
{
ParallelExecutionSettings parallelSettings = ParallelExecutionSettings.FromConfiguration(configuration);
var parallelSettings = ParallelExecutionSettings.FromConfiguration(configuration);
IterateRows(rectangle, parallelSettings, body);
}

2
src/ImageSharp/Configuration.cs

@ -16,7 +16,7 @@ using SixLabors.ImageSharp.Processing;
namespace SixLabors.ImageSharp
{
/// <summary>
/// Provides configuration code which allows altering default behaviour or extending the library.
/// Provides configuration which allows altering default behaviour or extending the library.
/// </summary>
public sealed class Configuration
{

5
src/ImageSharp/Formats/Gif/GifDecoderCore.cs

@ -274,9 +274,8 @@ namespace SixLabors.ImageSharp.Formats.Gif
}
// Could be XMP or something else not supported yet.
// Back up and skip.
this.stream.Position -= appLength + 1;
this.SkipBlock(appLength);
// Skip the subblock and terminator.
this.SkipBlock(subBlockSize);
return;
}

2
src/ImageSharp/Formats/Gif/GifEncoder.cs

@ -28,7 +28,7 @@ namespace SixLabors.ImageSharp.Formats.Gif
public void Encode<TPixel>(Image<TPixel> image, Stream stream)
where TPixel : struct, IPixel<TPixel>
{
var encoder = new GifEncoderCore(image.GetConfiguration().MemoryAllocator, this);
var encoder = new GifEncoderCore(image.GetConfiguration(), this);
encoder.Encode(image, stream);
}
}

23
src/ImageSharp/Formats/Gif/GifEncoderCore.cs

@ -53,11 +53,12 @@ namespace SixLabors.ImageSharp.Formats.Gif
/// <summary>
/// Initializes a new instance of the <see cref="GifEncoderCore"/> class.
/// </summary>
/// <param name="memoryAllocator">The <see cref="MemoryAllocator"/> to use for buffer allocations.</param>
/// <param name="configuration">The configuration which allows altering default behaviour or extending the library.</param>
/// <param name="options">The options for the encoder.</param>
public GifEncoderCore(MemoryAllocator memoryAllocator, IGifEncoderOptions options)
public GifEncoderCore(Configuration configuration, IGifEncoderOptions options)
{
this.memoryAllocator = memoryAllocator;
this.configuration = configuration;
this.memoryAllocator = configuration.MemoryAllocator;
this.quantizer = options.Quantizer;
this.colorTableMode = options.ColorTableMode;
}
@ -74,16 +75,14 @@ namespace SixLabors.ImageSharp.Formats.Gif
Guard.NotNull(image, nameof(image));
Guard.NotNull(stream, nameof(stream));
this.configuration = image.GetConfiguration();
ImageMetadata metadata = image.Metadata;
GifMetadata gifMetadata = metadata.GetGifMetadata();
this.colorTableMode = this.colorTableMode ?? gifMetadata.ColorTableMode;
this.colorTableMode ??= gifMetadata.ColorTableMode;
bool useGlobalTable = this.colorTableMode == GifColorTableMode.Global;
// Quantize the image returning a palette.
IQuantizedFrame<TPixel> quantized;
using (IFrameQuantizer<TPixel> frameQuantizer = this.quantizer.CreateFrameQuantizer<TPixel>(image.GetConfiguration()))
using (IFrameQuantizer<TPixel> frameQuantizer = this.quantizer.CreateFrameQuantizer<TPixel>(this.configuration))
{
quantized = frameQuantizer.QuantizeFrame(image.Frames.RootFrame);
}
@ -146,7 +145,7 @@ namespace SixLabors.ImageSharp.Formats.Gif
else
{
using (IFrameQuantizer<TPixel> paletteFrameQuantizer =
new PaletteFrameQuantizer<TPixel>(this.quantizer.Diffuser, quantized.Palette))
new PaletteFrameQuantizer<TPixel>(this.configuration, this.quantizer.Diffuser, quantized.Palette))
{
using (IQuantizedFrame<TPixel> paletteQuantized = paletteFrameQuantizer.QuantizeFrame(frame))
{
@ -172,14 +171,14 @@ namespace SixLabors.ImageSharp.Formats.Gif
if (previousFrame != null && previousMeta.ColorTableLength != frameMetadata.ColorTableLength
&& frameMetadata.ColorTableLength > 0)
{
using (IFrameQuantizer<TPixel> frameQuantizer = this.quantizer.CreateFrameQuantizer<TPixel>(image.GetConfiguration(), frameMetadata.ColorTableLength))
using (IFrameQuantizer<TPixel> frameQuantizer = this.quantizer.CreateFrameQuantizer<TPixel>(this.configuration, frameMetadata.ColorTableLength))
{
quantized = frameQuantizer.QuantizeFrame(frame);
}
}
else
{
using (IFrameQuantizer<TPixel> frameQuantizer = this.quantizer.CreateFrameQuantizer<TPixel>(image.GetConfiguration()))
using (IFrameQuantizer<TPixel> frameQuantizer = this.quantizer.CreateFrameQuantizer<TPixel>(this.configuration))
{
quantized = frameQuantizer.QuantizeFrame(frame);
}
@ -202,9 +201,7 @@ namespace SixLabors.ImageSharp.Formats.Gif
/// <summary>
/// Returns the index of the most transparent color in the palette.
/// </summary>
/// <param name="quantized">
/// The quantized.
/// </param>
/// <param name="quantized">The quantized frame.</param>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <returns>
/// The <see cref="int"/>.

4
src/ImageSharp/Formats/Gif/GifMetadata.cs

@ -36,10 +36,10 @@ namespace SixLabors.ImageSharp.Formats.Gif
/// <summary>
/// Gets or sets the number of times any animation is repeated.
/// <remarks>
/// 0 means to repeat indefinitely, count is set as play n + 1 times
/// 0 means to repeat indefinitely, count is set as repeat n-1 times. Defaults to 1.
/// </remarks>
/// </summary>
public ushort RepeatCount { get; set; }
public ushort RepeatCount { get; set; } = 1;
/// <summary>
/// Gets or sets the color table mode.

8
src/ImageSharp/Formats/Jpeg/Components/Encoder/YCbCrForwardConverter{TPixel}.cs

@ -1,9 +1,9 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using System;
using System.Runtime.CompilerServices;
using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.PixelFormats;
namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Encoder
@ -60,7 +60,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Encoder
this.pixelBlock.LoadAndStretchEdges(frame, x, y);
Span<Rgb24> rgbSpan = this.rgbBlock.AsSpanUnsafe();
PixelOperations<TPixel>.Instance.ToRgb24(frame.Configuration, this.pixelBlock.AsSpanUnsafe(), rgbSpan);
PixelOperations<TPixel>.Instance.ToRgb24(frame.GetConfiguration(), this.pixelBlock.AsSpanUnsafe(), rgbSpan);
ref float yBlockStart = ref Unsafe.As<Block8x8F, float>(ref this.Y);
ref float cbBlockStart = ref Unsafe.As<Block8x8F, float>(ref this.Cb);
@ -81,4 +81,4 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Encoder
}
}
}
}
}

22
src/ImageSharp/Image.cs

@ -16,20 +16,23 @@ namespace SixLabors.ImageSharp
/// For the non-generic <see cref="Image"/> type, the pixel type is only known at runtime.
/// <see cref="Image"/> is always implemented by a pixel-specific <see cref="Image{TPixel}"/> instance.
/// </summary>
public abstract partial class Image : IImage, IConfigurable
public abstract partial class Image : IImage, IConfigurationProvider
{
private Size size;
private readonly Configuration configuration;
/// <summary>
/// Initializes a new instance of the <see cref="Image"/> class.
/// </summary>
/// <param name="configuration">The <see cref="Configuration"/>.</param>
/// <param name="configuration">
/// The configuration which allows altering default behaviour or extending the library.
/// </param>
/// <param name="pixelType">The <see cref="PixelTypeInfo"/>.</param>
/// <param name="metadata">The <see cref="ImageMetadata"/>.</param>
/// <param name="size">The <see cref="size"/>.</param>
protected Image(Configuration configuration, PixelTypeInfo pixelType, ImageMetadata metadata, Size size)
{
this.Configuration = configuration ?? Configuration.Default;
this.configuration = configuration ?? Configuration.Default;
this.PixelType = pixelType;
this.size = size;
this.Metadata = metadata ?? new ImageMetadata();
@ -48,11 +51,6 @@ namespace SixLabors.ImageSharp
{
}
/// <summary>
/// Gets the <see cref="Configuration"/>.
/// </summary>
protected Configuration Configuration { get; }
/// <summary>
/// Gets the <see cref="ImageFrameCollection"/> implementing the public <see cref="Frames"/> property.
/// </summary>
@ -75,10 +73,8 @@ namespace SixLabors.ImageSharp
/// </summary>
public ImageFrameCollection Frames => this.NonGenericFrameCollection;
/// <summary>
/// Gets the pixel buffer.
/// </summary>
Configuration IConfigurable.Configuration => this.Configuration;
/// <inheritdoc/>
Configuration IConfigurationProvider.Configuration => this.configuration;
/// <inheritdoc />
public void Dispose()
@ -108,7 +104,7 @@ namespace SixLabors.ImageSharp
/// <typeparam name="TPixel2">The pixel format.</typeparam>
/// <returns>The <see cref="Image{TPixel2}"/></returns>
public Image<TPixel2> CloneAs<TPixel2>()
where TPixel2 : struct, IPixel<TPixel2> => this.CloneAs<TPixel2>(this.Configuration);
where TPixel2 : struct, IPixel<TPixel2> => this.CloneAs<TPixel2>(this.GetConfiguration());
/// <summary>
/// Returns a copy of the image in the given pixel format.

28
src/ImageSharp/ImageFrame.cs

@ -2,7 +2,7 @@
// Licensed under the Apache License, Version 2.0.
using System;
using SixLabors.ImageSharp.Memory;
using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.Metadata;
using SixLabors.ImageSharp.PixelFormats;
@ -13,37 +13,28 @@ namespace SixLabors.ImageSharp
/// In case of animated formats like gif, it contains the single frame in a animation.
/// In all other cases it is the only frame of the image.
/// </summary>
public abstract partial class ImageFrame : IDisposable
public abstract partial class ImageFrame : IConfigurationProvider, IDisposable
{
private readonly Configuration configuration;
/// <summary>
/// Initializes a new instance of the <see cref="ImageFrame"/> class.
/// </summary>
/// <param name="configuration">The <see cref="Configuration"/>.</param>
/// <param name="width">The width.</param>
/// <param name="height">The height.</param>
/// <param name="configuration">The configuration which allows altering default behaviour or extending the library.</param>
/// <param name="width">The frame width.</param>
/// <param name="height">The frame height.</param>
/// <param name="metadata">The <see cref="ImageFrameMetadata"/>.</param>
protected ImageFrame(Configuration configuration, int width, int height, ImageFrameMetadata metadata)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.NotNull(metadata, nameof(metadata));
this.Configuration = configuration;
this.MemoryAllocator = configuration.MemoryAllocator;
this.configuration = configuration ?? Configuration.Default;
this.Width = width;
this.Height = height;
this.Metadata = metadata;
}
/// <summary>
/// Gets the <see cref="MemoryAllocator" /> to use for buffer allocations.
/// </summary>
public MemoryAllocator MemoryAllocator { get; }
/// <summary>
/// Gets the <see cref="Configuration"/> instance associated with this <see cref="ImageFrame{TPixel}"/>.
/// </summary>
internal Configuration Configuration { get; }
/// <summary>
/// Gets the width.
/// </summary>
@ -59,6 +50,9 @@ namespace SixLabors.ImageSharp
/// </summary>
public ImageFrameMetadata Metadata { get; }
/// <inheritdoc/>
Configuration IConfigurationProvider.Configuration => this.configuration;
/// <summary>
/// Gets the size of the frame.
/// </summary>

12
src/ImageSharp/ImageFrame{TPixel}.cs

@ -59,7 +59,7 @@ namespace SixLabors.ImageSharp
Guard.MustBeGreaterThan(width, 0, nameof(width));
Guard.MustBeGreaterThan(height, 0, nameof(height));
this.PixelBuffer = this.MemoryAllocator.Allocate2D<TPixel>(width, height, AllocationOptions.Clean);
this.PixelBuffer = this.GetConfiguration().MemoryAllocator.Allocate2D<TPixel>(width, height, AllocationOptions.Clean);
}
/// <summary>
@ -88,7 +88,7 @@ namespace SixLabors.ImageSharp
Guard.MustBeGreaterThan(width, 0, nameof(width));
Guard.MustBeGreaterThan(height, 0, nameof(height));
this.PixelBuffer = this.MemoryAllocator.Allocate2D<TPixel>(width, height);
this.PixelBuffer = this.GetConfiguration().MemoryAllocator.Allocate2D<TPixel>(width, height);
this.Clear(backgroundColor);
}
@ -132,7 +132,7 @@ namespace SixLabors.ImageSharp
Guard.NotNull(configuration, nameof(configuration));
Guard.NotNull(source, nameof(source));
this.PixelBuffer = this.MemoryAllocator.Allocate2D<TPixel>(source.PixelBuffer.Width, source.PixelBuffer.Height);
this.PixelBuffer = this.GetConfiguration().MemoryAllocator.Allocate2D<TPixel>(source.PixelBuffer.Width, source.PixelBuffer.Height);
source.PixelBuffer.GetSpan().CopyTo(this.PixelBuffer.GetSpan());
}
@ -219,7 +219,7 @@ namespace SixLabors.ImageSharp
this.PixelBuffer.GetSpan().CopyTo(dest1);
}
PixelOperations<TPixel>.Instance.To(this.Configuration, this.PixelBuffer.GetSpan(), destination);
PixelOperations<TPixel>.Instance.To(this.GetConfiguration(), this.PixelBuffer.GetSpan(), destination);
}
/// <inheritdoc/>
@ -229,7 +229,7 @@ namespace SixLabors.ImageSharp
/// Clones the current instance.
/// </summary>
/// <returns>The <see cref="ImageFrame{TPixel}"/></returns>
internal ImageFrame<TPixel> Clone() => this.Clone(this.Configuration);
internal ImageFrame<TPixel> Clone() => this.Clone(this.GetConfiguration());
/// <summary>
/// Clones the current instance.
@ -244,7 +244,7 @@ namespace SixLabors.ImageSharp
/// <typeparam name="TPixel2">The pixel format.</typeparam>
/// <returns>The <see cref="ImageFrame{TPixel2}"/></returns>
internal ImageFrame<TPixel2> CloneAs<TPixel2>()
where TPixel2 : struct, IPixel<TPixel2> => this.CloneAs<TPixel2>(this.Configuration);
where TPixel2 : struct, IPixel<TPixel2> => this.CloneAs<TPixel2>(this.GetConfiguration());
/// <summary>
/// Returns a copy of the image frame in the given pixel format.

2
src/ImageSharp/Image{TPixel}.cs

@ -154,7 +154,7 @@ namespace SixLabors.ImageSharp
/// Clones the current image
/// </summary>
/// <returns>Returns a new image with all the same metadata as the original.</returns>
public Image<TPixel> Clone() => this.Clone(this.Configuration);
public Image<TPixel> Clone() => this.Clone(this.GetConfiguration());
/// <summary>
/// Clones the current image with the given configuration.

28
src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.TagDataEntry.cs

@ -153,7 +153,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc
else
{
// The type is not know, so the values need be read
var values = new double[channelCount][];
double[][] values = new double[channelCount][];
for (int i = 0; i < channelCount; i++)
{
values[i] = new double[] { this.ReadUFix16(), this.ReadUFix16() };
@ -208,7 +208,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc
return new IccCurveTagDataEntry(this.ReadUFix8());
}
var cdata = new float[pointCount];
float[] cdata = new float[pointCount];
for (int i = 0; i < pointCount; i++)
{
cdata[i] = this.ReadUInt16() / 65535f;
@ -264,7 +264,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc
// Input LUT
var inValues = new IccLut[inChCount];
var gridPointCount = new byte[inChCount];
byte[] gridPointCount = new byte[inChCount];
for (int i = 0; i < inChCount; i++)
{
inValues[i] = this.ReadLut16(inTableCount);
@ -299,7 +299,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc
// Input LUT
var inValues = new IccLut[inChCount];
var gridPointCount = new byte[inChCount];
byte[] gridPointCount = new byte[inChCount];
for (int i = 0; i < inChCount; i++)
{
inValues[i] = this.ReadLut8();
@ -464,8 +464,8 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc
var text = new IccLocalizedString[recordCount];
var culture = new CultureInfo[recordCount];
var length = new uint[recordCount];
var offset = new uint[recordCount];
uint[] length = new uint[recordCount];
uint[] offset = new uint[recordCount];
for (int i = 0; i < recordCount; i++)
{
@ -627,7 +627,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc
ushort channelCount = this.ReadUInt16();
ushort measurementCount = this.ReadUInt16();
var offset = new uint[measurementCount];
uint[] offset = new uint[measurementCount];
for (int i = 0; i < measurementCount; i++)
{
offset[i] = this.ReadUInt32();
@ -651,7 +651,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc
public IccFix16ArrayTagDataEntry ReadFix16ArrayTagDataEntry(uint size)
{
uint count = (size - 8) / 4;
var arrayData = new float[count];
float[] arrayData = new float[count];
for (int i = 0; i < count; i++)
{
arrayData[i] = this.ReadFix16() / 256f;
@ -687,7 +687,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc
public IccUFix16ArrayTagDataEntry ReadUFix16ArrayTagDataEntry(uint size)
{
uint count = (size - 8) / 4;
var arrayData = new float[count];
float[] arrayData = new float[count];
for (int i = 0; i < count; i++)
{
arrayData[i] = this.ReadUFix16();
@ -704,7 +704,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc
public IccUInt16ArrayTagDataEntry ReadUInt16ArrayTagDataEntry(uint size)
{
uint count = (size - 8) / 2;
var arrayData = new ushort[count];
ushort[] arrayData = new ushort[count];
for (int i = 0; i < count; i++)
{
arrayData[i] = this.ReadUInt16();
@ -721,7 +721,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc
public IccUInt32ArrayTagDataEntry ReadUInt32ArrayTagDataEntry(uint size)
{
uint count = (size - 8) / 4;
var arrayData = new uint[count];
uint[] arrayData = new uint[count];
for (int i = 0; i < count; i++)
{
arrayData[i] = this.ReadUInt32();
@ -738,7 +738,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc
public IccUInt64ArrayTagDataEntry ReadUInt64ArrayTagDataEntry(uint size)
{
uint count = (size - 8) / 8;
var arrayData = new ulong[count];
ulong[] arrayData = new ulong[count];
for (int i = 0; i < count; i++)
{
arrayData[i] = this.ReadUInt64();
@ -878,14 +878,14 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc
public IccUcrBgTagDataEntry ReadUcrBgTagDataEntry(uint size)
{
uint ucrCount = this.ReadUInt32();
var ucrCurve = new ushort[ucrCount];
ushort[] ucrCurve = new ushort[ucrCount];
for (int i = 0; i < ucrCurve.Length; i++)
{
ucrCurve[i] = this.ReadUInt16();
}
uint bgCount = this.ReadUInt32();
var bgCurve = new ushort[bgCount];
ushort[] bgCurve = new ushort[bgCount];
for (int i = 0; i < bgCurve.Length; i++)
{
bgCurve[i] = this.ReadUInt16();

2
src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccLutAToBTagDataEntry.cs

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using System;

2
src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccLutBToATagDataEntry.cs

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using System;

3
src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccXyzTagDataEntry.cs

@ -3,6 +3,7 @@
using System;
using System.Numerics;
using System.Runtime.CompilerServices;
namespace SixLabors.ImageSharp.Metadata.Profiles.Icc
{
@ -53,4 +54,4 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc
return this.Equals((IccTagDataEntry)other);
}
}
}
}

98
src/ImageSharp/PixelFormats/PixelImplementations/Generated/Argb32.PixelOperations.Generated.cs

@ -11,7 +11,6 @@ using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace SixLabors.ImageSharp.PixelFormats
{
/// <content>
@ -25,27 +24,27 @@ namespace SixLabors.ImageSharp.PixelFormats
internal class PixelOperations : PixelOperations<Argb32>
{
/// <inheritdoc />
internal override void FromArgb32(Configuration configuration, ReadOnlySpan<Argb32> source, Span<Argb32> destPixels)
public override void FromArgb32(Configuration configuration, ReadOnlySpan<Argb32> source, Span<Argb32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(source, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(source, destinationPixels, nameof(destinationPixels));
source.CopyTo(destPixels);
source.CopyTo(destinationPixels);
}
/// <inheritdoc />
internal override void ToArgb32(Configuration configuration, ReadOnlySpan<Argb32> sourcePixels, Span<Argb32> destPixels)
public override void ToArgb32(Configuration configuration, ReadOnlySpan<Argb32> sourcePixels, Span<Argb32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
sourcePixels.CopyTo(destPixels);
sourcePixels.CopyTo(destinationPixels);
}
/// <inheritdoc />
public override void FromVector4Destructive(Configuration configuration, Span<Vector4> sourceVectors, Span<Argb32> destPixels, PixelConversionModifiers modifiers)
public override void FromVector4Destructive(Configuration configuration, Span<Vector4> sourceVectors, Span<Argb32> destinationPixels, PixelConversionModifiers modifiers)
{
Vector4Converters.RgbaCompatible.FromVector4(configuration, this, sourceVectors, destPixels, modifiers.Remove(PixelConversionModifiers.Scale));
Vector4Converters.RgbaCompatible.FromVector4(configuration, this, sourceVectors, destinationPixels, modifiers.Remove(PixelConversionModifiers.Scale));
}
/// <inheritdoc />
@ -54,13 +53,13 @@ namespace SixLabors.ImageSharp.PixelFormats
Vector4Converters.RgbaCompatible.ToVector4(configuration, this, sourcePixels, destVectors, modifiers.Remove(PixelConversionModifiers.Scale));
}
/// <inheritdoc />
internal override void ToRgba32(Configuration configuration, ReadOnlySpan<Argb32> sourcePixels, Span<Rgba32> destPixels)
public override void ToRgba32(Configuration configuration, ReadOnlySpan<Argb32> sourcePixels, Span<Rgba32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref uint sourceRef = ref Unsafe.As<Argb32,uint>(ref MemoryMarshal.GetReference(sourcePixels));
ref uint destRef = ref Unsafe.As<Rgba32, uint>(ref MemoryMarshal.GetReference(destPixels));
ref uint destRef = ref Unsafe.As<Rgba32, uint>(ref MemoryMarshal.GetReference(destinationPixels));
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -70,13 +69,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void FromRgba32(Configuration configuration, ReadOnlySpan<Rgba32> sourcePixels, Span<Argb32> destPixels)
public override void FromRgba32(Configuration configuration, ReadOnlySpan<Rgba32> sourcePixels, Span<Argb32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref uint sourceRef = ref Unsafe.As<Rgba32,uint>(ref MemoryMarshal.GetReference(sourcePixels));
ref uint destRef = ref Unsafe.As<Argb32, uint>(ref MemoryMarshal.GetReference(destPixels));
ref uint destRef = ref Unsafe.As<Argb32, uint>(ref MemoryMarshal.GetReference(destinationPixels));
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -85,13 +84,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
}
/// <inheritdoc />
internal override void ToBgra32(Configuration configuration, ReadOnlySpan<Argb32> sourcePixels, Span<Bgra32> destPixels)
public override void ToBgra32(Configuration configuration, ReadOnlySpan<Argb32> sourcePixels, Span<Bgra32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref uint sourceRef = ref Unsafe.As<Argb32,uint>(ref MemoryMarshal.GetReference(sourcePixels));
ref uint destRef = ref Unsafe.As<Bgra32, uint>(ref MemoryMarshal.GetReference(destPixels));
ref uint destRef = ref Unsafe.As<Bgra32, uint>(ref MemoryMarshal.GetReference(destinationPixels));
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -101,13 +100,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void FromBgra32(Configuration configuration, ReadOnlySpan<Bgra32> sourcePixels, Span<Argb32> destPixels)
public override void FromBgra32(Configuration configuration, ReadOnlySpan<Bgra32> sourcePixels, Span<Argb32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref uint sourceRef = ref Unsafe.As<Bgra32,uint>(ref MemoryMarshal.GetReference(sourcePixels));
ref uint destRef = ref Unsafe.As<Argb32, uint>(ref MemoryMarshal.GetReference(destPixels));
ref uint destRef = ref Unsafe.As<Argb32, uint>(ref MemoryMarshal.GetReference(destinationPixels));
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -117,13 +116,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToBgr24(Configuration configuration, ReadOnlySpan<Argb32> sourcePixels, Span<Bgr24> destPixels)
public override void ToBgr24(Configuration configuration, ReadOnlySpan<Argb32> sourcePixels, Span<Bgr24> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Argb32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Bgr24 destRef = ref MemoryMarshal.GetReference(destPixels);
ref Bgr24 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -135,13 +134,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToL8(Configuration configuration, ReadOnlySpan<Argb32> sourcePixels, Span<L8> destPixels)
public override void ToL8(Configuration configuration, ReadOnlySpan<Argb32> sourcePixels, Span<L8> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Argb32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref L8 destRef = ref MemoryMarshal.GetReference(destPixels);
ref L8 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -153,13 +152,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToL16(Configuration configuration, ReadOnlySpan<Argb32> sourcePixels, Span<L16> destPixels)
public override void ToL16(Configuration configuration, ReadOnlySpan<Argb32> sourcePixels, Span<L16> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Argb32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref L16 destRef = ref MemoryMarshal.GetReference(destPixels);
ref L16 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -171,13 +170,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToLa16(Configuration configuration, ReadOnlySpan<Argb32> sourcePixels, Span<La16> destPixels)
public override void ToLa16(Configuration configuration, ReadOnlySpan<Argb32> sourcePixels, Span<La16> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Argb32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref La16 destRef = ref MemoryMarshal.GetReference(destPixels);
ref La16 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -189,13 +188,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToLa32(Configuration configuration, ReadOnlySpan<Argb32> sourcePixels, Span<La32> destPixels)
public override void ToLa32(Configuration configuration, ReadOnlySpan<Argb32> sourcePixels, Span<La32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Argb32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref La32 destRef = ref MemoryMarshal.GetReference(destPixels);
ref La32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -207,13 +206,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToRgb24(Configuration configuration, ReadOnlySpan<Argb32> sourcePixels, Span<Rgb24> destPixels)
public override void ToRgb24(Configuration configuration, ReadOnlySpan<Argb32> sourcePixels, Span<Rgb24> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Argb32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgb24 destRef = ref MemoryMarshal.GetReference(destPixels);
ref Rgb24 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -225,13 +224,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToRgb48(Configuration configuration, ReadOnlySpan<Argb32> sourcePixels, Span<Rgb48> destPixels)
public override void ToRgb48(Configuration configuration, ReadOnlySpan<Argb32> sourcePixels, Span<Rgb48> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Argb32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgb48 destRef = ref MemoryMarshal.GetReference(destPixels);
ref Rgb48 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -243,13 +242,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToRgba64(Configuration configuration, ReadOnlySpan<Argb32> sourcePixels, Span<Rgba64> destPixels)
public override void ToRgba64(Configuration configuration, ReadOnlySpan<Argb32> sourcePixels, Span<Rgba64> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Argb32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgba64 destRef = ref MemoryMarshal.GetReference(destPixels);
ref Rgba64 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -261,13 +260,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToBgra5551(Configuration configuration, ReadOnlySpan<Argb32> sourcePixels, Span<Bgra5551> destPixels)
public override void ToBgra5551(Configuration configuration, ReadOnlySpan<Argb32> sourcePixels, Span<Bgra5551> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Argb32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destPixels);
ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -278,14 +277,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
}
/// <inheritdoc />
internal override void From<TSourcePixel>(
public override void From<TSourcePixel>(
Configuration configuration,
ReadOnlySpan<TSourcePixel> sourcePixels,
Span<Argb32> destinationPixels)
{
PixelOperations<TSourcePixel>.Instance.ToArgb32(configuration, sourcePixels, destinationPixels);
}
}
}
}

86
src/ImageSharp/PixelFormats/PixelImplementations/Generated/Bgr24.PixelOperations.Generated.cs

@ -11,7 +11,6 @@ using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace SixLabors.ImageSharp.PixelFormats
{
/// <content>
@ -25,27 +24,27 @@ namespace SixLabors.ImageSharp.PixelFormats
internal class PixelOperations : PixelOperations<Bgr24>
{
/// <inheritdoc />
internal override void FromBgr24(Configuration configuration, ReadOnlySpan<Bgr24> source, Span<Bgr24> destPixels)
public override void FromBgr24(Configuration configuration, ReadOnlySpan<Bgr24> source, Span<Bgr24> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(source, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(source, destinationPixels, nameof(destinationPixels));
source.CopyTo(destPixels);
source.CopyTo(destinationPixels);
}
/// <inheritdoc />
internal override void ToBgr24(Configuration configuration, ReadOnlySpan<Bgr24> sourcePixels, Span<Bgr24> destPixels)
public override void ToBgr24(Configuration configuration, ReadOnlySpan<Bgr24> sourcePixels, Span<Bgr24> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
sourcePixels.CopyTo(destPixels);
sourcePixels.CopyTo(destinationPixels);
}
/// <inheritdoc />
public override void FromVector4Destructive(Configuration configuration, Span<Vector4> sourceVectors, Span<Bgr24> destPixels, PixelConversionModifiers modifiers)
public override void FromVector4Destructive(Configuration configuration, Span<Vector4> sourceVectors, Span<Bgr24> destinationPixels, PixelConversionModifiers modifiers)
{
Vector4Converters.RgbaCompatible.FromVector4(configuration, this, sourceVectors, destPixels, modifiers.Remove(PixelConversionModifiers.Scale | PixelConversionModifiers.Premultiply));
Vector4Converters.RgbaCompatible.FromVector4(configuration, this, sourceVectors, destinationPixels, modifiers.Remove(PixelConversionModifiers.Scale | PixelConversionModifiers.Premultiply));
}
/// <inheritdoc />
@ -55,13 +54,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToArgb32(Configuration configuration, ReadOnlySpan<Bgr24> sourcePixels, Span<Argb32> destPixels)
public override void ToArgb32(Configuration configuration, ReadOnlySpan<Bgr24> sourcePixels, Span<Argb32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Argb32 destRef = ref MemoryMarshal.GetReference(destPixels);
ref Argb32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -73,13 +72,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToBgra32(Configuration configuration, ReadOnlySpan<Bgr24> sourcePixels, Span<Bgra32> destPixels)
public override void ToBgra32(Configuration configuration, ReadOnlySpan<Bgr24> sourcePixels, Span<Bgra32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Bgra32 destRef = ref MemoryMarshal.GetReference(destPixels);
ref Bgra32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -91,13 +90,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToL8(Configuration configuration, ReadOnlySpan<Bgr24> sourcePixels, Span<L8> destPixels)
public override void ToL8(Configuration configuration, ReadOnlySpan<Bgr24> sourcePixels, Span<L8> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref L8 destRef = ref MemoryMarshal.GetReference(destPixels);
ref L8 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -109,13 +108,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToL16(Configuration configuration, ReadOnlySpan<Bgr24> sourcePixels, Span<L16> destPixels)
public override void ToL16(Configuration configuration, ReadOnlySpan<Bgr24> sourcePixels, Span<L16> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref L16 destRef = ref MemoryMarshal.GetReference(destPixels);
ref L16 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -127,13 +126,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToLa16(Configuration configuration, ReadOnlySpan<Bgr24> sourcePixels, Span<La16> destPixels)
public override void ToLa16(Configuration configuration, ReadOnlySpan<Bgr24> sourcePixels, Span<La16> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref La16 destRef = ref MemoryMarshal.GetReference(destPixels);
ref La16 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -145,13 +144,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToLa32(Configuration configuration, ReadOnlySpan<Bgr24> sourcePixels, Span<La32> destPixels)
public override void ToLa32(Configuration configuration, ReadOnlySpan<Bgr24> sourcePixels, Span<La32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref La32 destRef = ref MemoryMarshal.GetReference(destPixels);
ref La32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -163,13 +162,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToRgb24(Configuration configuration, ReadOnlySpan<Bgr24> sourcePixels, Span<Rgb24> destPixels)
public override void ToRgb24(Configuration configuration, ReadOnlySpan<Bgr24> sourcePixels, Span<Rgb24> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgb24 destRef = ref MemoryMarshal.GetReference(destPixels);
ref Rgb24 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -181,13 +180,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToRgba32(Configuration configuration, ReadOnlySpan<Bgr24> sourcePixels, Span<Rgba32> destPixels)
public override void ToRgba32(Configuration configuration, ReadOnlySpan<Bgr24> sourcePixels, Span<Rgba32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgba32 destRef = ref MemoryMarshal.GetReference(destPixels);
ref Rgba32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -199,13 +198,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToRgb48(Configuration configuration, ReadOnlySpan<Bgr24> sourcePixels, Span<Rgb48> destPixels)
public override void ToRgb48(Configuration configuration, ReadOnlySpan<Bgr24> sourcePixels, Span<Rgb48> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgb48 destRef = ref MemoryMarshal.GetReference(destPixels);
ref Rgb48 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -217,13 +216,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToRgba64(Configuration configuration, ReadOnlySpan<Bgr24> sourcePixels, Span<Rgba64> destPixels)
public override void ToRgba64(Configuration configuration, ReadOnlySpan<Bgr24> sourcePixels, Span<Rgba64> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgba64 destRef = ref MemoryMarshal.GetReference(destPixels);
ref Rgba64 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -235,13 +234,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToBgra5551(Configuration configuration, ReadOnlySpan<Bgr24> sourcePixels, Span<Bgra5551> destPixels)
public override void ToBgra5551(Configuration configuration, ReadOnlySpan<Bgr24> sourcePixels, Span<Bgra5551> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destPixels);
ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -252,14 +251,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
}
/// <inheritdoc />
internal override void From<TSourcePixel>(
public override void From<TSourcePixel>(
Configuration configuration,
ReadOnlySpan<TSourcePixel> sourcePixels,
Span<Bgr24> destinationPixels)
{
PixelOperations<TSourcePixel>.Instance.ToBgr24(configuration, sourcePixels, destinationPixels);
}
}
}
}

98
src/ImageSharp/PixelFormats/PixelImplementations/Generated/Bgra32.PixelOperations.Generated.cs

@ -11,7 +11,6 @@ using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace SixLabors.ImageSharp.PixelFormats
{
/// <content>
@ -25,27 +24,27 @@ namespace SixLabors.ImageSharp.PixelFormats
internal class PixelOperations : PixelOperations<Bgra32>
{
/// <inheritdoc />
internal override void FromBgra32(Configuration configuration, ReadOnlySpan<Bgra32> source, Span<Bgra32> destPixels)
public override void FromBgra32(Configuration configuration, ReadOnlySpan<Bgra32> source, Span<Bgra32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(source, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(source, destinationPixels, nameof(destinationPixels));
source.CopyTo(destPixels);
source.CopyTo(destinationPixels);
}
/// <inheritdoc />
internal override void ToBgra32(Configuration configuration, ReadOnlySpan<Bgra32> sourcePixels, Span<Bgra32> destPixels)
public override void ToBgra32(Configuration configuration, ReadOnlySpan<Bgra32> sourcePixels, Span<Bgra32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
sourcePixels.CopyTo(destPixels);
sourcePixels.CopyTo(destinationPixels);
}
/// <inheritdoc />
public override void FromVector4Destructive(Configuration configuration, Span<Vector4> sourceVectors, Span<Bgra32> destPixels, PixelConversionModifiers modifiers)
public override void FromVector4Destructive(Configuration configuration, Span<Vector4> sourceVectors, Span<Bgra32> destinationPixels, PixelConversionModifiers modifiers)
{
Vector4Converters.RgbaCompatible.FromVector4(configuration, this, sourceVectors, destPixels, modifiers.Remove(PixelConversionModifiers.Scale));
Vector4Converters.RgbaCompatible.FromVector4(configuration, this, sourceVectors, destinationPixels, modifiers.Remove(PixelConversionModifiers.Scale));
}
/// <inheritdoc />
@ -54,13 +53,13 @@ namespace SixLabors.ImageSharp.PixelFormats
Vector4Converters.RgbaCompatible.ToVector4(configuration, this, sourcePixels, destVectors, modifiers.Remove(PixelConversionModifiers.Scale));
}
/// <inheritdoc />
internal override void ToRgba32(Configuration configuration, ReadOnlySpan<Bgra32> sourcePixels, Span<Rgba32> destPixels)
public override void ToRgba32(Configuration configuration, ReadOnlySpan<Bgra32> sourcePixels, Span<Rgba32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref uint sourceRef = ref Unsafe.As<Bgra32,uint>(ref MemoryMarshal.GetReference(sourcePixels));
ref uint destRef = ref Unsafe.As<Rgba32, uint>(ref MemoryMarshal.GetReference(destPixels));
ref uint destRef = ref Unsafe.As<Rgba32, uint>(ref MemoryMarshal.GetReference(destinationPixels));
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -70,13 +69,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void FromRgba32(Configuration configuration, ReadOnlySpan<Rgba32> sourcePixels, Span<Bgra32> destPixels)
public override void FromRgba32(Configuration configuration, ReadOnlySpan<Rgba32> sourcePixels, Span<Bgra32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref uint sourceRef = ref Unsafe.As<Rgba32,uint>(ref MemoryMarshal.GetReference(sourcePixels));
ref uint destRef = ref Unsafe.As<Bgra32, uint>(ref MemoryMarshal.GetReference(destPixels));
ref uint destRef = ref Unsafe.As<Bgra32, uint>(ref MemoryMarshal.GetReference(destinationPixels));
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -85,13 +84,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
}
/// <inheritdoc />
internal override void ToArgb32(Configuration configuration, ReadOnlySpan<Bgra32> sourcePixels, Span<Argb32> destPixels)
public override void ToArgb32(Configuration configuration, ReadOnlySpan<Bgra32> sourcePixels, Span<Argb32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref uint sourceRef = ref Unsafe.As<Bgra32,uint>(ref MemoryMarshal.GetReference(sourcePixels));
ref uint destRef = ref Unsafe.As<Argb32, uint>(ref MemoryMarshal.GetReference(destPixels));
ref uint destRef = ref Unsafe.As<Argb32, uint>(ref MemoryMarshal.GetReference(destinationPixels));
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -101,13 +100,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void FromArgb32(Configuration configuration, ReadOnlySpan<Argb32> sourcePixels, Span<Bgra32> destPixels)
public override void FromArgb32(Configuration configuration, ReadOnlySpan<Argb32> sourcePixels, Span<Bgra32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref uint sourceRef = ref Unsafe.As<Argb32,uint>(ref MemoryMarshal.GetReference(sourcePixels));
ref uint destRef = ref Unsafe.As<Bgra32, uint>(ref MemoryMarshal.GetReference(destPixels));
ref uint destRef = ref Unsafe.As<Bgra32, uint>(ref MemoryMarshal.GetReference(destinationPixels));
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -117,13 +116,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToBgr24(Configuration configuration, ReadOnlySpan<Bgra32> sourcePixels, Span<Bgr24> destPixels)
public override void ToBgr24(Configuration configuration, ReadOnlySpan<Bgra32> sourcePixels, Span<Bgr24> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Bgra32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Bgr24 destRef = ref MemoryMarshal.GetReference(destPixels);
ref Bgr24 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -135,13 +134,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToL8(Configuration configuration, ReadOnlySpan<Bgra32> sourcePixels, Span<L8> destPixels)
public override void ToL8(Configuration configuration, ReadOnlySpan<Bgra32> sourcePixels, Span<L8> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Bgra32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref L8 destRef = ref MemoryMarshal.GetReference(destPixels);
ref L8 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -153,13 +152,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToL16(Configuration configuration, ReadOnlySpan<Bgra32> sourcePixels, Span<L16> destPixels)
public override void ToL16(Configuration configuration, ReadOnlySpan<Bgra32> sourcePixels, Span<L16> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Bgra32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref L16 destRef = ref MemoryMarshal.GetReference(destPixels);
ref L16 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -171,13 +170,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToLa16(Configuration configuration, ReadOnlySpan<Bgra32> sourcePixels, Span<La16> destPixels)
public override void ToLa16(Configuration configuration, ReadOnlySpan<Bgra32> sourcePixels, Span<La16> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Bgra32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref La16 destRef = ref MemoryMarshal.GetReference(destPixels);
ref La16 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -189,13 +188,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToLa32(Configuration configuration, ReadOnlySpan<Bgra32> sourcePixels, Span<La32> destPixels)
public override void ToLa32(Configuration configuration, ReadOnlySpan<Bgra32> sourcePixels, Span<La32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Bgra32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref La32 destRef = ref MemoryMarshal.GetReference(destPixels);
ref La32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -207,13 +206,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToRgb24(Configuration configuration, ReadOnlySpan<Bgra32> sourcePixels, Span<Rgb24> destPixels)
public override void ToRgb24(Configuration configuration, ReadOnlySpan<Bgra32> sourcePixels, Span<Rgb24> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Bgra32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgb24 destRef = ref MemoryMarshal.GetReference(destPixels);
ref Rgb24 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -225,13 +224,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToRgb48(Configuration configuration, ReadOnlySpan<Bgra32> sourcePixels, Span<Rgb48> destPixels)
public override void ToRgb48(Configuration configuration, ReadOnlySpan<Bgra32> sourcePixels, Span<Rgb48> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Bgra32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgb48 destRef = ref MemoryMarshal.GetReference(destPixels);
ref Rgb48 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -243,13 +242,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToRgba64(Configuration configuration, ReadOnlySpan<Bgra32> sourcePixels, Span<Rgba64> destPixels)
public override void ToRgba64(Configuration configuration, ReadOnlySpan<Bgra32> sourcePixels, Span<Rgba64> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Bgra32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgba64 destRef = ref MemoryMarshal.GetReference(destPixels);
ref Rgba64 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -261,13 +260,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToBgra5551(Configuration configuration, ReadOnlySpan<Bgra32> sourcePixels, Span<Bgra5551> destPixels)
public override void ToBgra5551(Configuration configuration, ReadOnlySpan<Bgra32> sourcePixels, Span<Bgra5551> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Bgra32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destPixels);
ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -278,14 +277,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
}
/// <inheritdoc />
internal override void From<TSourcePixel>(
public override void From<TSourcePixel>(
Configuration configuration,
ReadOnlySpan<TSourcePixel> sourcePixels,
Span<Bgra32> destinationPixels)
{
PixelOperations<TSourcePixel>.Instance.ToBgra32(configuration, sourcePixels, destinationPixels);
}
}
}
}

80
src/ImageSharp/PixelFormats/PixelImplementations/Generated/Bgra5551.PixelOperations.Generated.cs

@ -24,32 +24,32 @@ namespace SixLabors.ImageSharp.PixelFormats
internal class PixelOperations : PixelOperations<Bgra5551>
{
/// <inheritdoc />
internal override void FromBgra5551(Configuration configuration, ReadOnlySpan<Bgra5551> source, Span<Bgra5551> destPixels)
public override void FromBgra5551(Configuration configuration, ReadOnlySpan<Bgra5551> source, Span<Bgra5551> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(source, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(source, destinationPixels, nameof(destinationPixels));
source.CopyTo(destPixels);
source.CopyTo(destinationPixels);
}
/// <inheritdoc />
internal override void ToBgra5551(Configuration configuration, ReadOnlySpan<Bgra5551> sourcePixels, Span<Bgra5551> destPixels)
public override void ToBgra5551(Configuration configuration, ReadOnlySpan<Bgra5551> sourcePixels, Span<Bgra5551> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
sourcePixels.CopyTo(destPixels);
sourcePixels.CopyTo(destinationPixels);
}
/// <inheritdoc />
internal override void ToArgb32(Configuration configuration, ReadOnlySpan<Bgra5551> sourcePixels, Span<Argb32> destPixels)
public override void ToArgb32(Configuration configuration, ReadOnlySpan<Bgra5551> sourcePixels, Span<Argb32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Bgra5551 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Argb32 destRef = ref MemoryMarshal.GetReference(destPixels);
ref Argb32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -61,13 +61,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToBgr24(Configuration configuration, ReadOnlySpan<Bgra5551> sourcePixels, Span<Bgr24> destPixels)
public override void ToBgr24(Configuration configuration, ReadOnlySpan<Bgra5551> sourcePixels, Span<Bgr24> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Bgra5551 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Bgr24 destRef = ref MemoryMarshal.GetReference(destPixels);
ref Bgr24 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -79,13 +79,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToBgra32(Configuration configuration, ReadOnlySpan<Bgra5551> sourcePixels, Span<Bgra32> destPixels)
public override void ToBgra32(Configuration configuration, ReadOnlySpan<Bgra5551> sourcePixels, Span<Bgra32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Bgra5551 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Bgra32 destRef = ref MemoryMarshal.GetReference(destPixels);
ref Bgra32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -97,13 +97,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToL8(Configuration configuration, ReadOnlySpan<Bgra5551> sourcePixels, Span<L8> destPixels)
public override void ToL8(Configuration configuration, ReadOnlySpan<Bgra5551> sourcePixels, Span<L8> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Bgra5551 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref L8 destRef = ref MemoryMarshal.GetReference(destPixels);
ref L8 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -115,13 +115,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToL16(Configuration configuration, ReadOnlySpan<Bgra5551> sourcePixels, Span<L16> destPixels)
public override void ToL16(Configuration configuration, ReadOnlySpan<Bgra5551> sourcePixels, Span<L16> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Bgra5551 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref L16 destRef = ref MemoryMarshal.GetReference(destPixels);
ref L16 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -133,13 +133,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToLa16(Configuration configuration, ReadOnlySpan<Bgra5551> sourcePixels, Span<La16> destPixels)
public override void ToLa16(Configuration configuration, ReadOnlySpan<Bgra5551> sourcePixels, Span<La16> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Bgra5551 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref La16 destRef = ref MemoryMarshal.GetReference(destPixels);
ref La16 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -151,13 +151,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToLa32(Configuration configuration, ReadOnlySpan<Bgra5551> sourcePixels, Span<La32> destPixels)
public override void ToLa32(Configuration configuration, ReadOnlySpan<Bgra5551> sourcePixels, Span<La32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Bgra5551 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref La32 destRef = ref MemoryMarshal.GetReference(destPixels);
ref La32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -169,13 +169,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToRgb24(Configuration configuration, ReadOnlySpan<Bgra5551> sourcePixels, Span<Rgb24> destPixels)
public override void ToRgb24(Configuration configuration, ReadOnlySpan<Bgra5551> sourcePixels, Span<Rgb24> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Bgra5551 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgb24 destRef = ref MemoryMarshal.GetReference(destPixels);
ref Rgb24 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -187,13 +187,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToRgba32(Configuration configuration, ReadOnlySpan<Bgra5551> sourcePixels, Span<Rgba32> destPixels)
public override void ToRgba32(Configuration configuration, ReadOnlySpan<Bgra5551> sourcePixels, Span<Rgba32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Bgra5551 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgba32 destRef = ref MemoryMarshal.GetReference(destPixels);
ref Rgba32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -205,13 +205,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToRgb48(Configuration configuration, ReadOnlySpan<Bgra5551> sourcePixels, Span<Rgb48> destPixels)
public override void ToRgb48(Configuration configuration, ReadOnlySpan<Bgra5551> sourcePixels, Span<Rgb48> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Bgra5551 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgb48 destRef = ref MemoryMarshal.GetReference(destPixels);
ref Rgb48 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -223,13 +223,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToRgba64(Configuration configuration, ReadOnlySpan<Bgra5551> sourcePixels, Span<Rgba64> destPixels)
public override void ToRgba64(Configuration configuration, ReadOnlySpan<Bgra5551> sourcePixels, Span<Rgba64> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Bgra5551 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgba64 destRef = ref MemoryMarshal.GetReference(destPixels);
ref Rgba64 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -240,7 +240,7 @@ namespace SixLabors.ImageSharp.PixelFormats
}
}
/// <inheritdoc />
internal override void From<TSourcePixel>(
public override void From<TSourcePixel>(
Configuration configuration,
ReadOnlySpan<TSourcePixel> sourcePixels,
Span<Bgra5551> destinationPixels)

80
src/ImageSharp/PixelFormats/PixelImplementations/Generated/L16.PixelOperations.Generated.cs

@ -24,32 +24,32 @@ namespace SixLabors.ImageSharp.PixelFormats
internal class PixelOperations : PixelOperations<L16>
{
/// <inheritdoc />
internal override void FromL16(Configuration configuration, ReadOnlySpan<L16> source, Span<L16> destPixels)
public override void FromL16(Configuration configuration, ReadOnlySpan<L16> source, Span<L16> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(source, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(source, destinationPixels, nameof(destinationPixels));
source.CopyTo(destPixels);
source.CopyTo(destinationPixels);
}
/// <inheritdoc />
internal override void ToL16(Configuration configuration, ReadOnlySpan<L16> sourcePixels, Span<L16> destPixels)
public override void ToL16(Configuration configuration, ReadOnlySpan<L16> sourcePixels, Span<L16> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
sourcePixels.CopyTo(destPixels);
sourcePixels.CopyTo(destinationPixels);
}
/// <inheritdoc />
internal override void ToArgb32(Configuration configuration, ReadOnlySpan<L16> sourcePixels, Span<Argb32> destPixels)
public override void ToArgb32(Configuration configuration, ReadOnlySpan<L16> sourcePixels, Span<Argb32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref L16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Argb32 destRef = ref MemoryMarshal.GetReference(destPixels);
ref Argb32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -61,13 +61,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToBgr24(Configuration configuration, ReadOnlySpan<L16> sourcePixels, Span<Bgr24> destPixels)
public override void ToBgr24(Configuration configuration, ReadOnlySpan<L16> sourcePixels, Span<Bgr24> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref L16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Bgr24 destRef = ref MemoryMarshal.GetReference(destPixels);
ref Bgr24 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -79,13 +79,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToBgra32(Configuration configuration, ReadOnlySpan<L16> sourcePixels, Span<Bgra32> destPixels)
public override void ToBgra32(Configuration configuration, ReadOnlySpan<L16> sourcePixels, Span<Bgra32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref L16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Bgra32 destRef = ref MemoryMarshal.GetReference(destPixels);
ref Bgra32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -97,13 +97,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToL8(Configuration configuration, ReadOnlySpan<L16> sourcePixels, Span<L8> destPixels)
public override void ToL8(Configuration configuration, ReadOnlySpan<L16> sourcePixels, Span<L8> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref L16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref L8 destRef = ref MemoryMarshal.GetReference(destPixels);
ref L8 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -115,13 +115,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToLa16(Configuration configuration, ReadOnlySpan<L16> sourcePixels, Span<La16> destPixels)
public override void ToLa16(Configuration configuration, ReadOnlySpan<L16> sourcePixels, Span<La16> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref L16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref La16 destRef = ref MemoryMarshal.GetReference(destPixels);
ref La16 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -133,13 +133,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToLa32(Configuration configuration, ReadOnlySpan<L16> sourcePixels, Span<La32> destPixels)
public override void ToLa32(Configuration configuration, ReadOnlySpan<L16> sourcePixels, Span<La32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref L16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref La32 destRef = ref MemoryMarshal.GetReference(destPixels);
ref La32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -151,13 +151,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToRgb24(Configuration configuration, ReadOnlySpan<L16> sourcePixels, Span<Rgb24> destPixels)
public override void ToRgb24(Configuration configuration, ReadOnlySpan<L16> sourcePixels, Span<Rgb24> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref L16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgb24 destRef = ref MemoryMarshal.GetReference(destPixels);
ref Rgb24 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -169,13 +169,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToRgba32(Configuration configuration, ReadOnlySpan<L16> sourcePixels, Span<Rgba32> destPixels)
public override void ToRgba32(Configuration configuration, ReadOnlySpan<L16> sourcePixels, Span<Rgba32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref L16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgba32 destRef = ref MemoryMarshal.GetReference(destPixels);
ref Rgba32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -187,13 +187,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToRgb48(Configuration configuration, ReadOnlySpan<L16> sourcePixels, Span<Rgb48> destPixels)
public override void ToRgb48(Configuration configuration, ReadOnlySpan<L16> sourcePixels, Span<Rgb48> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref L16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgb48 destRef = ref MemoryMarshal.GetReference(destPixels);
ref Rgb48 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -205,13 +205,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToRgba64(Configuration configuration, ReadOnlySpan<L16> sourcePixels, Span<Rgba64> destPixels)
public override void ToRgba64(Configuration configuration, ReadOnlySpan<L16> sourcePixels, Span<Rgba64> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref L16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgba64 destRef = ref MemoryMarshal.GetReference(destPixels);
ref Rgba64 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -223,13 +223,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToBgra5551(Configuration configuration, ReadOnlySpan<L16> sourcePixels, Span<Bgra5551> destPixels)
public override void ToBgra5551(Configuration configuration, ReadOnlySpan<L16> sourcePixels, Span<Bgra5551> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref L16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destPixels);
ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -240,7 +240,7 @@ namespace SixLabors.ImageSharp.PixelFormats
}
}
/// <inheritdoc />
internal override void From<TSourcePixel>(
public override void From<TSourcePixel>(
Configuration configuration,
ReadOnlySpan<TSourcePixel> sourcePixels,
Span<L16> destinationPixels)

80
src/ImageSharp/PixelFormats/PixelImplementations/Generated/L8.PixelOperations.Generated.cs

@ -24,32 +24,32 @@ namespace SixLabors.ImageSharp.PixelFormats
internal class PixelOperations : PixelOperations<L8>
{
/// <inheritdoc />
internal override void FromL8(Configuration configuration, ReadOnlySpan<L8> source, Span<L8> destPixels)
public override void FromL8(Configuration configuration, ReadOnlySpan<L8> source, Span<L8> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(source, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(source, destinationPixels, nameof(destinationPixels));
source.CopyTo(destPixels);
source.CopyTo(destinationPixels);
}
/// <inheritdoc />
internal override void ToL8(Configuration configuration, ReadOnlySpan<L8> sourcePixels, Span<L8> destPixels)
public override void ToL8(Configuration configuration, ReadOnlySpan<L8> sourcePixels, Span<L8> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
sourcePixels.CopyTo(destPixels);
sourcePixels.CopyTo(destinationPixels);
}
/// <inheritdoc />
internal override void ToArgb32(Configuration configuration, ReadOnlySpan<L8> sourcePixels, Span<Argb32> destPixels)
public override void ToArgb32(Configuration configuration, ReadOnlySpan<L8> sourcePixels, Span<Argb32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref L8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Argb32 destRef = ref MemoryMarshal.GetReference(destPixels);
ref Argb32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -61,13 +61,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToBgr24(Configuration configuration, ReadOnlySpan<L8> sourcePixels, Span<Bgr24> destPixels)
public override void ToBgr24(Configuration configuration, ReadOnlySpan<L8> sourcePixels, Span<Bgr24> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref L8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Bgr24 destRef = ref MemoryMarshal.GetReference(destPixels);
ref Bgr24 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -79,13 +79,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToBgra32(Configuration configuration, ReadOnlySpan<L8> sourcePixels, Span<Bgra32> destPixels)
public override void ToBgra32(Configuration configuration, ReadOnlySpan<L8> sourcePixels, Span<Bgra32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref L8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Bgra32 destRef = ref MemoryMarshal.GetReference(destPixels);
ref Bgra32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -97,13 +97,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToL16(Configuration configuration, ReadOnlySpan<L8> sourcePixels, Span<L16> destPixels)
public override void ToL16(Configuration configuration, ReadOnlySpan<L8> sourcePixels, Span<L16> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref L8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref L16 destRef = ref MemoryMarshal.GetReference(destPixels);
ref L16 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -115,13 +115,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToLa16(Configuration configuration, ReadOnlySpan<L8> sourcePixels, Span<La16> destPixels)
public override void ToLa16(Configuration configuration, ReadOnlySpan<L8> sourcePixels, Span<La16> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref L8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref La16 destRef = ref MemoryMarshal.GetReference(destPixels);
ref La16 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -133,13 +133,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToLa32(Configuration configuration, ReadOnlySpan<L8> sourcePixels, Span<La32> destPixels)
public override void ToLa32(Configuration configuration, ReadOnlySpan<L8> sourcePixels, Span<La32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref L8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref La32 destRef = ref MemoryMarshal.GetReference(destPixels);
ref La32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -151,13 +151,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToRgb24(Configuration configuration, ReadOnlySpan<L8> sourcePixels, Span<Rgb24> destPixels)
public override void ToRgb24(Configuration configuration, ReadOnlySpan<L8> sourcePixels, Span<Rgb24> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref L8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgb24 destRef = ref MemoryMarshal.GetReference(destPixels);
ref Rgb24 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -169,13 +169,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToRgba32(Configuration configuration, ReadOnlySpan<L8> sourcePixels, Span<Rgba32> destPixels)
public override void ToRgba32(Configuration configuration, ReadOnlySpan<L8> sourcePixels, Span<Rgba32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref L8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgba32 destRef = ref MemoryMarshal.GetReference(destPixels);
ref Rgba32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -187,13 +187,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToRgb48(Configuration configuration, ReadOnlySpan<L8> sourcePixels, Span<Rgb48> destPixels)
public override void ToRgb48(Configuration configuration, ReadOnlySpan<L8> sourcePixels, Span<Rgb48> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref L8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgb48 destRef = ref MemoryMarshal.GetReference(destPixels);
ref Rgb48 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -205,13 +205,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToRgba64(Configuration configuration, ReadOnlySpan<L8> sourcePixels, Span<Rgba64> destPixels)
public override void ToRgba64(Configuration configuration, ReadOnlySpan<L8> sourcePixels, Span<Rgba64> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref L8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgba64 destRef = ref MemoryMarshal.GetReference(destPixels);
ref Rgba64 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -223,13 +223,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToBgra5551(Configuration configuration, ReadOnlySpan<L8> sourcePixels, Span<Bgra5551> destPixels)
public override void ToBgra5551(Configuration configuration, ReadOnlySpan<L8> sourcePixels, Span<Bgra5551> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref L8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destPixels);
ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -240,7 +240,7 @@ namespace SixLabors.ImageSharp.PixelFormats
}
}
/// <inheritdoc />
internal override void From<TSourcePixel>(
public override void From<TSourcePixel>(
Configuration configuration,
ReadOnlySpan<TSourcePixel> sourcePixels,
Span<L8> destinationPixels)

80
src/ImageSharp/PixelFormats/PixelImplementations/Generated/La16.PixelOperations.Generated.cs

@ -24,32 +24,32 @@ namespace SixLabors.ImageSharp.PixelFormats
internal class PixelOperations : PixelOperations<La16>
{
/// <inheritdoc />
internal override void FromLa16(Configuration configuration, ReadOnlySpan<La16> source, Span<La16> destPixels)
public override void FromLa16(Configuration configuration, ReadOnlySpan<La16> source, Span<La16> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(source, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(source, destinationPixels, nameof(destinationPixels));
source.CopyTo(destPixels);
source.CopyTo(destinationPixels);
}
/// <inheritdoc />
internal override void ToLa16(Configuration configuration, ReadOnlySpan<La16> sourcePixels, Span<La16> destPixels)
public override void ToLa16(Configuration configuration, ReadOnlySpan<La16> sourcePixels, Span<La16> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
sourcePixels.CopyTo(destPixels);
sourcePixels.CopyTo(destinationPixels);
}
/// <inheritdoc />
internal override void ToArgb32(Configuration configuration, ReadOnlySpan<La16> sourcePixels, Span<Argb32> destPixels)
public override void ToArgb32(Configuration configuration, ReadOnlySpan<La16> sourcePixels, Span<Argb32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref La16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Argb32 destRef = ref MemoryMarshal.GetReference(destPixels);
ref Argb32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -61,13 +61,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToBgr24(Configuration configuration, ReadOnlySpan<La16> sourcePixels, Span<Bgr24> destPixels)
public override void ToBgr24(Configuration configuration, ReadOnlySpan<La16> sourcePixels, Span<Bgr24> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref La16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Bgr24 destRef = ref MemoryMarshal.GetReference(destPixels);
ref Bgr24 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -79,13 +79,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToBgra32(Configuration configuration, ReadOnlySpan<La16> sourcePixels, Span<Bgra32> destPixels)
public override void ToBgra32(Configuration configuration, ReadOnlySpan<La16> sourcePixels, Span<Bgra32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref La16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Bgra32 destRef = ref MemoryMarshal.GetReference(destPixels);
ref Bgra32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -97,13 +97,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToL8(Configuration configuration, ReadOnlySpan<La16> sourcePixels, Span<L8> destPixels)
public override void ToL8(Configuration configuration, ReadOnlySpan<La16> sourcePixels, Span<L8> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref La16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref L8 destRef = ref MemoryMarshal.GetReference(destPixels);
ref L8 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -115,13 +115,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToL16(Configuration configuration, ReadOnlySpan<La16> sourcePixels, Span<L16> destPixels)
public override void ToL16(Configuration configuration, ReadOnlySpan<La16> sourcePixels, Span<L16> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref La16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref L16 destRef = ref MemoryMarshal.GetReference(destPixels);
ref L16 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -133,13 +133,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToLa32(Configuration configuration, ReadOnlySpan<La16> sourcePixels, Span<La32> destPixels)
public override void ToLa32(Configuration configuration, ReadOnlySpan<La16> sourcePixels, Span<La32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref La16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref La32 destRef = ref MemoryMarshal.GetReference(destPixels);
ref La32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -151,13 +151,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToRgb24(Configuration configuration, ReadOnlySpan<La16> sourcePixels, Span<Rgb24> destPixels)
public override void ToRgb24(Configuration configuration, ReadOnlySpan<La16> sourcePixels, Span<Rgb24> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref La16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgb24 destRef = ref MemoryMarshal.GetReference(destPixels);
ref Rgb24 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -169,13 +169,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToRgba32(Configuration configuration, ReadOnlySpan<La16> sourcePixels, Span<Rgba32> destPixels)
public override void ToRgba32(Configuration configuration, ReadOnlySpan<La16> sourcePixels, Span<Rgba32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref La16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgba32 destRef = ref MemoryMarshal.GetReference(destPixels);
ref Rgba32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -187,13 +187,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToRgb48(Configuration configuration, ReadOnlySpan<La16> sourcePixels, Span<Rgb48> destPixels)
public override void ToRgb48(Configuration configuration, ReadOnlySpan<La16> sourcePixels, Span<Rgb48> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref La16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgb48 destRef = ref MemoryMarshal.GetReference(destPixels);
ref Rgb48 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -205,13 +205,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToRgba64(Configuration configuration, ReadOnlySpan<La16> sourcePixels, Span<Rgba64> destPixels)
public override void ToRgba64(Configuration configuration, ReadOnlySpan<La16> sourcePixels, Span<Rgba64> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref La16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgba64 destRef = ref MemoryMarshal.GetReference(destPixels);
ref Rgba64 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -223,13 +223,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToBgra5551(Configuration configuration, ReadOnlySpan<La16> sourcePixels, Span<Bgra5551> destPixels)
public override void ToBgra5551(Configuration configuration, ReadOnlySpan<La16> sourcePixels, Span<Bgra5551> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref La16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destPixels);
ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -240,7 +240,7 @@ namespace SixLabors.ImageSharp.PixelFormats
}
}
/// <inheritdoc />
internal override void From<TSourcePixel>(
public override void From<TSourcePixel>(
Configuration configuration,
ReadOnlySpan<TSourcePixel> sourcePixels,
Span<La16> destinationPixels)

80
src/ImageSharp/PixelFormats/PixelImplementations/Generated/La32.PixelOperations.Generated.cs

@ -24,32 +24,32 @@ namespace SixLabors.ImageSharp.PixelFormats
internal class PixelOperations : PixelOperations<La32>
{
/// <inheritdoc />
internal override void FromLa32(Configuration configuration, ReadOnlySpan<La32> source, Span<La32> destPixels)
public override void FromLa32(Configuration configuration, ReadOnlySpan<La32> source, Span<La32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(source, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(source, destinationPixels, nameof(destinationPixels));
source.CopyTo(destPixels);
source.CopyTo(destinationPixels);
}
/// <inheritdoc />
internal override void ToLa32(Configuration configuration, ReadOnlySpan<La32> sourcePixels, Span<La32> destPixels)
public override void ToLa32(Configuration configuration, ReadOnlySpan<La32> sourcePixels, Span<La32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
sourcePixels.CopyTo(destPixels);
sourcePixels.CopyTo(destinationPixels);
}
/// <inheritdoc />
internal override void ToArgb32(Configuration configuration, ReadOnlySpan<La32> sourcePixels, Span<Argb32> destPixels)
public override void ToArgb32(Configuration configuration, ReadOnlySpan<La32> sourcePixels, Span<Argb32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref La32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Argb32 destRef = ref MemoryMarshal.GetReference(destPixels);
ref Argb32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -61,13 +61,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToBgr24(Configuration configuration, ReadOnlySpan<La32> sourcePixels, Span<Bgr24> destPixels)
public override void ToBgr24(Configuration configuration, ReadOnlySpan<La32> sourcePixels, Span<Bgr24> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref La32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Bgr24 destRef = ref MemoryMarshal.GetReference(destPixels);
ref Bgr24 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -79,13 +79,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToBgra32(Configuration configuration, ReadOnlySpan<La32> sourcePixels, Span<Bgra32> destPixels)
public override void ToBgra32(Configuration configuration, ReadOnlySpan<La32> sourcePixels, Span<Bgra32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref La32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Bgra32 destRef = ref MemoryMarshal.GetReference(destPixels);
ref Bgra32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -97,13 +97,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToL8(Configuration configuration, ReadOnlySpan<La32> sourcePixels, Span<L8> destPixels)
public override void ToL8(Configuration configuration, ReadOnlySpan<La32> sourcePixels, Span<L8> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref La32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref L8 destRef = ref MemoryMarshal.GetReference(destPixels);
ref L8 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -115,13 +115,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToL16(Configuration configuration, ReadOnlySpan<La32> sourcePixels, Span<L16> destPixels)
public override void ToL16(Configuration configuration, ReadOnlySpan<La32> sourcePixels, Span<L16> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref La32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref L16 destRef = ref MemoryMarshal.GetReference(destPixels);
ref L16 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -133,13 +133,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToLa16(Configuration configuration, ReadOnlySpan<La32> sourcePixels, Span<La16> destPixels)
public override void ToLa16(Configuration configuration, ReadOnlySpan<La32> sourcePixels, Span<La16> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref La32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref La16 destRef = ref MemoryMarshal.GetReference(destPixels);
ref La16 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -151,13 +151,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToRgb24(Configuration configuration, ReadOnlySpan<La32> sourcePixels, Span<Rgb24> destPixels)
public override void ToRgb24(Configuration configuration, ReadOnlySpan<La32> sourcePixels, Span<Rgb24> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref La32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgb24 destRef = ref MemoryMarshal.GetReference(destPixels);
ref Rgb24 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -169,13 +169,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToRgba32(Configuration configuration, ReadOnlySpan<La32> sourcePixels, Span<Rgba32> destPixels)
public override void ToRgba32(Configuration configuration, ReadOnlySpan<La32> sourcePixels, Span<Rgba32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref La32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgba32 destRef = ref MemoryMarshal.GetReference(destPixels);
ref Rgba32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -187,13 +187,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToRgb48(Configuration configuration, ReadOnlySpan<La32> sourcePixels, Span<Rgb48> destPixels)
public override void ToRgb48(Configuration configuration, ReadOnlySpan<La32> sourcePixels, Span<Rgb48> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref La32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgb48 destRef = ref MemoryMarshal.GetReference(destPixels);
ref Rgb48 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -205,13 +205,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToRgba64(Configuration configuration, ReadOnlySpan<La32> sourcePixels, Span<Rgba64> destPixels)
public override void ToRgba64(Configuration configuration, ReadOnlySpan<La32> sourcePixels, Span<Rgba64> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref La32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgba64 destRef = ref MemoryMarshal.GetReference(destPixels);
ref Rgba64 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -223,13 +223,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToBgra5551(Configuration configuration, ReadOnlySpan<La32> sourcePixels, Span<Bgra5551> destPixels)
public override void ToBgra5551(Configuration configuration, ReadOnlySpan<La32> sourcePixels, Span<Bgra5551> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref La32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destPixels);
ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -240,7 +240,7 @@ namespace SixLabors.ImageSharp.PixelFormats
}
}
/// <inheritdoc />
internal override void From<TSourcePixel>(
public override void From<TSourcePixel>(
Configuration configuration,
ReadOnlySpan<TSourcePixel> sourcePixels,
Span<La32> destinationPixels)

86
src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgb24.PixelOperations.Generated.cs

@ -11,7 +11,6 @@ using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace SixLabors.ImageSharp.PixelFormats
{
/// <content>
@ -25,27 +24,27 @@ namespace SixLabors.ImageSharp.PixelFormats
internal class PixelOperations : PixelOperations<Rgb24>
{
/// <inheritdoc />
internal override void FromRgb24(Configuration configuration, ReadOnlySpan<Rgb24> source, Span<Rgb24> destPixels)
public override void FromRgb24(Configuration configuration, ReadOnlySpan<Rgb24> source, Span<Rgb24> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(source, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(source, destinationPixels, nameof(destinationPixels));
source.CopyTo(destPixels);
source.CopyTo(destinationPixels);
}
/// <inheritdoc />
internal override void ToRgb24(Configuration configuration, ReadOnlySpan<Rgb24> sourcePixels, Span<Rgb24> destPixels)
public override void ToRgb24(Configuration configuration, ReadOnlySpan<Rgb24> sourcePixels, Span<Rgb24> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
sourcePixels.CopyTo(destPixels);
sourcePixels.CopyTo(destinationPixels);
}
/// <inheritdoc />
public override void FromVector4Destructive(Configuration configuration, Span<Vector4> sourceVectors, Span<Rgb24> destPixels, PixelConversionModifiers modifiers)
public override void FromVector4Destructive(Configuration configuration, Span<Vector4> sourceVectors, Span<Rgb24> destinationPixels, PixelConversionModifiers modifiers)
{
Vector4Converters.RgbaCompatible.FromVector4(configuration, this, sourceVectors, destPixels, modifiers.Remove(PixelConversionModifiers.Scale | PixelConversionModifiers.Premultiply));
Vector4Converters.RgbaCompatible.FromVector4(configuration, this, sourceVectors, destinationPixels, modifiers.Remove(PixelConversionModifiers.Scale | PixelConversionModifiers.Premultiply));
}
/// <inheritdoc />
@ -55,13 +54,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToArgb32(Configuration configuration, ReadOnlySpan<Rgb24> sourcePixels, Span<Argb32> destPixels)
public override void ToArgb32(Configuration configuration, ReadOnlySpan<Rgb24> sourcePixels, Span<Argb32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Rgb24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Argb32 destRef = ref MemoryMarshal.GetReference(destPixels);
ref Argb32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -73,13 +72,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToBgr24(Configuration configuration, ReadOnlySpan<Rgb24> sourcePixels, Span<Bgr24> destPixels)
public override void ToBgr24(Configuration configuration, ReadOnlySpan<Rgb24> sourcePixels, Span<Bgr24> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Rgb24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Bgr24 destRef = ref MemoryMarshal.GetReference(destPixels);
ref Bgr24 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -91,13 +90,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToBgra32(Configuration configuration, ReadOnlySpan<Rgb24> sourcePixels, Span<Bgra32> destPixels)
public override void ToBgra32(Configuration configuration, ReadOnlySpan<Rgb24> sourcePixels, Span<Bgra32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Rgb24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Bgra32 destRef = ref MemoryMarshal.GetReference(destPixels);
ref Bgra32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -109,13 +108,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToL8(Configuration configuration, ReadOnlySpan<Rgb24> sourcePixels, Span<L8> destPixels)
public override void ToL8(Configuration configuration, ReadOnlySpan<Rgb24> sourcePixels, Span<L8> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Rgb24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref L8 destRef = ref MemoryMarshal.GetReference(destPixels);
ref L8 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -127,13 +126,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToL16(Configuration configuration, ReadOnlySpan<Rgb24> sourcePixels, Span<L16> destPixels)
public override void ToL16(Configuration configuration, ReadOnlySpan<Rgb24> sourcePixels, Span<L16> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Rgb24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref L16 destRef = ref MemoryMarshal.GetReference(destPixels);
ref L16 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -145,13 +144,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToLa16(Configuration configuration, ReadOnlySpan<Rgb24> sourcePixels, Span<La16> destPixels)
public override void ToLa16(Configuration configuration, ReadOnlySpan<Rgb24> sourcePixels, Span<La16> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Rgb24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref La16 destRef = ref MemoryMarshal.GetReference(destPixels);
ref La16 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -163,13 +162,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToLa32(Configuration configuration, ReadOnlySpan<Rgb24> sourcePixels, Span<La32> destPixels)
public override void ToLa32(Configuration configuration, ReadOnlySpan<Rgb24> sourcePixels, Span<La32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Rgb24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref La32 destRef = ref MemoryMarshal.GetReference(destPixels);
ref La32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -181,13 +180,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToRgba32(Configuration configuration, ReadOnlySpan<Rgb24> sourcePixels, Span<Rgba32> destPixels)
public override void ToRgba32(Configuration configuration, ReadOnlySpan<Rgb24> sourcePixels, Span<Rgba32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Rgb24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgba32 destRef = ref MemoryMarshal.GetReference(destPixels);
ref Rgba32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -199,13 +198,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToRgb48(Configuration configuration, ReadOnlySpan<Rgb24> sourcePixels, Span<Rgb48> destPixels)
public override void ToRgb48(Configuration configuration, ReadOnlySpan<Rgb24> sourcePixels, Span<Rgb48> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Rgb24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgb48 destRef = ref MemoryMarshal.GetReference(destPixels);
ref Rgb48 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -217,13 +216,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToRgba64(Configuration configuration, ReadOnlySpan<Rgb24> sourcePixels, Span<Rgba64> destPixels)
public override void ToRgba64(Configuration configuration, ReadOnlySpan<Rgb24> sourcePixels, Span<Rgba64> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Rgb24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgba64 destRef = ref MemoryMarshal.GetReference(destPixels);
ref Rgba64 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -235,13 +234,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToBgra5551(Configuration configuration, ReadOnlySpan<Rgb24> sourcePixels, Span<Bgra5551> destPixels)
public override void ToBgra5551(Configuration configuration, ReadOnlySpan<Rgb24> sourcePixels, Span<Bgra5551> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Rgb24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destPixels);
ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -252,14 +251,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
}
/// <inheritdoc />
internal override void From<TSourcePixel>(
public override void From<TSourcePixel>(
Configuration configuration,
ReadOnlySpan<TSourcePixel> sourcePixels,
Span<Rgb24> destinationPixels)
{
PixelOperations<TSourcePixel>.Instance.ToRgb24(configuration, sourcePixels, destinationPixels);
}
}
}
}

82
src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgb48.PixelOperations.Generated.cs

@ -11,7 +11,6 @@ using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace SixLabors.ImageSharp.PixelFormats
{
/// <content>
@ -25,32 +24,32 @@ namespace SixLabors.ImageSharp.PixelFormats
internal class PixelOperations : PixelOperations<Rgb48>
{
/// <inheritdoc />
internal override void FromRgb48(Configuration configuration, ReadOnlySpan<Rgb48> source, Span<Rgb48> destPixels)
public override void FromRgb48(Configuration configuration, ReadOnlySpan<Rgb48> source, Span<Rgb48> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(source, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(source, destinationPixels, nameof(destinationPixels));
source.CopyTo(destPixels);
source.CopyTo(destinationPixels);
}
/// <inheritdoc />
internal override void ToRgb48(Configuration configuration, ReadOnlySpan<Rgb48> sourcePixels, Span<Rgb48> destPixels)
public override void ToRgb48(Configuration configuration, ReadOnlySpan<Rgb48> sourcePixels, Span<Rgb48> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
sourcePixels.CopyTo(destPixels);
sourcePixels.CopyTo(destinationPixels);
}
/// <inheritdoc />
internal override void ToArgb32(Configuration configuration, ReadOnlySpan<Rgb48> sourcePixels, Span<Argb32> destPixels)
public override void ToArgb32(Configuration configuration, ReadOnlySpan<Rgb48> sourcePixels, Span<Argb32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Argb32 destRef = ref MemoryMarshal.GetReference(destPixels);
ref Argb32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -62,13 +61,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToBgr24(Configuration configuration, ReadOnlySpan<Rgb48> sourcePixels, Span<Bgr24> destPixels)
public override void ToBgr24(Configuration configuration, ReadOnlySpan<Rgb48> sourcePixels, Span<Bgr24> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Bgr24 destRef = ref MemoryMarshal.GetReference(destPixels);
ref Bgr24 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -80,13 +79,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToBgra32(Configuration configuration, ReadOnlySpan<Rgb48> sourcePixels, Span<Bgra32> destPixels)
public override void ToBgra32(Configuration configuration, ReadOnlySpan<Rgb48> sourcePixels, Span<Bgra32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Bgra32 destRef = ref MemoryMarshal.GetReference(destPixels);
ref Bgra32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -98,13 +97,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToL8(Configuration configuration, ReadOnlySpan<Rgb48> sourcePixels, Span<L8> destPixels)
public override void ToL8(Configuration configuration, ReadOnlySpan<Rgb48> sourcePixels, Span<L8> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref L8 destRef = ref MemoryMarshal.GetReference(destPixels);
ref L8 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -116,13 +115,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToL16(Configuration configuration, ReadOnlySpan<Rgb48> sourcePixels, Span<L16> destPixels)
public override void ToL16(Configuration configuration, ReadOnlySpan<Rgb48> sourcePixels, Span<L16> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref L16 destRef = ref MemoryMarshal.GetReference(destPixels);
ref L16 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -134,13 +133,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToLa16(Configuration configuration, ReadOnlySpan<Rgb48> sourcePixels, Span<La16> destPixels)
public override void ToLa16(Configuration configuration, ReadOnlySpan<Rgb48> sourcePixels, Span<La16> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref La16 destRef = ref MemoryMarshal.GetReference(destPixels);
ref La16 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -152,13 +151,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToLa32(Configuration configuration, ReadOnlySpan<Rgb48> sourcePixels, Span<La32> destPixels)
public override void ToLa32(Configuration configuration, ReadOnlySpan<Rgb48> sourcePixels, Span<La32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref La32 destRef = ref MemoryMarshal.GetReference(destPixels);
ref La32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -170,13 +169,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToRgb24(Configuration configuration, ReadOnlySpan<Rgb48> sourcePixels, Span<Rgb24> destPixels)
public override void ToRgb24(Configuration configuration, ReadOnlySpan<Rgb48> sourcePixels, Span<Rgb24> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgb24 destRef = ref MemoryMarshal.GetReference(destPixels);
ref Rgb24 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -188,13 +187,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToRgba32(Configuration configuration, ReadOnlySpan<Rgb48> sourcePixels, Span<Rgba32> destPixels)
public override void ToRgba32(Configuration configuration, ReadOnlySpan<Rgb48> sourcePixels, Span<Rgba32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgba32 destRef = ref MemoryMarshal.GetReference(destPixels);
ref Rgba32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -206,13 +205,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToRgba64(Configuration configuration, ReadOnlySpan<Rgb48> sourcePixels, Span<Rgba64> destPixels)
public override void ToRgba64(Configuration configuration, ReadOnlySpan<Rgb48> sourcePixels, Span<Rgba64> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgba64 destRef = ref MemoryMarshal.GetReference(destPixels);
ref Rgba64 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -224,13 +223,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToBgra5551(Configuration configuration, ReadOnlySpan<Rgb48> sourcePixels, Span<Bgra5551> destPixels)
public override void ToBgra5551(Configuration configuration, ReadOnlySpan<Rgb48> sourcePixels, Span<Bgra5551> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destPixels);
ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -241,14 +240,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
}
/// <inheritdoc />
internal override void From<TSourcePixel>(
public override void From<TSourcePixel>(
Configuration configuration,
ReadOnlySpan<TSourcePixel> sourcePixels,
Span<Rgb48> destinationPixels)
{
PixelOperations<TSourcePixel>.Instance.ToRgb48(configuration, sourcePixels, destinationPixels);
}
}
}
}

94
src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgba32.PixelOperations.Generated.cs

@ -11,7 +11,6 @@ using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace SixLabors.ImageSharp.PixelFormats
{
/// <content>
@ -25,31 +24,31 @@ namespace SixLabors.ImageSharp.PixelFormats
internal partial class PixelOperations : PixelOperations<Rgba32>
{
/// <inheritdoc />
internal override void FromRgba32(Configuration configuration, ReadOnlySpan<Rgba32> source, Span<Rgba32> destPixels)
public override void FromRgba32(Configuration configuration, ReadOnlySpan<Rgba32> source, Span<Rgba32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(source, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(source, destinationPixels, nameof(destinationPixels));
source.CopyTo(destPixels);
source.CopyTo(destinationPixels);
}
/// <inheritdoc />
internal override void ToRgba32(Configuration configuration, ReadOnlySpan<Rgba32> sourcePixels, Span<Rgba32> destPixels)
public override void ToRgba32(Configuration configuration, ReadOnlySpan<Rgba32> sourcePixels, Span<Rgba32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
sourcePixels.CopyTo(destPixels);
sourcePixels.CopyTo(destinationPixels);
}
/// <inheritdoc />
internal override void ToArgb32(Configuration configuration, ReadOnlySpan<Rgba32> sourcePixels, Span<Argb32> destPixels)
public override void ToArgb32(Configuration configuration, ReadOnlySpan<Rgba32> sourcePixels, Span<Argb32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref uint sourceRef = ref Unsafe.As<Rgba32,uint>(ref MemoryMarshal.GetReference(sourcePixels));
ref uint destRef = ref Unsafe.As<Argb32, uint>(ref MemoryMarshal.GetReference(destPixels));
ref uint destRef = ref Unsafe.As<Argb32, uint>(ref MemoryMarshal.GetReference(destinationPixels));
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -59,13 +58,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void FromArgb32(Configuration configuration, ReadOnlySpan<Argb32> sourcePixels, Span<Rgba32> destPixels)
public override void FromArgb32(Configuration configuration, ReadOnlySpan<Argb32> sourcePixels, Span<Rgba32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref uint sourceRef = ref Unsafe.As<Argb32,uint>(ref MemoryMarshal.GetReference(sourcePixels));
ref uint destRef = ref Unsafe.As<Rgba32, uint>(ref MemoryMarshal.GetReference(destPixels));
ref uint destRef = ref Unsafe.As<Rgba32, uint>(ref MemoryMarshal.GetReference(destinationPixels));
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -74,13 +73,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
}
/// <inheritdoc />
internal override void ToBgra32(Configuration configuration, ReadOnlySpan<Rgba32> sourcePixels, Span<Bgra32> destPixels)
public override void ToBgra32(Configuration configuration, ReadOnlySpan<Rgba32> sourcePixels, Span<Bgra32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref uint sourceRef = ref Unsafe.As<Rgba32,uint>(ref MemoryMarshal.GetReference(sourcePixels));
ref uint destRef = ref Unsafe.As<Bgra32, uint>(ref MemoryMarshal.GetReference(destPixels));
ref uint destRef = ref Unsafe.As<Bgra32, uint>(ref MemoryMarshal.GetReference(destinationPixels));
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -90,13 +89,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void FromBgra32(Configuration configuration, ReadOnlySpan<Bgra32> sourcePixels, Span<Rgba32> destPixels)
public override void FromBgra32(Configuration configuration, ReadOnlySpan<Bgra32> sourcePixels, Span<Rgba32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref uint sourceRef = ref Unsafe.As<Bgra32,uint>(ref MemoryMarshal.GetReference(sourcePixels));
ref uint destRef = ref Unsafe.As<Rgba32, uint>(ref MemoryMarshal.GetReference(destPixels));
ref uint destRef = ref Unsafe.As<Rgba32, uint>(ref MemoryMarshal.GetReference(destinationPixels));
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -106,13 +105,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToBgr24(Configuration configuration, ReadOnlySpan<Rgba32> sourcePixels, Span<Bgr24> destPixels)
public override void ToBgr24(Configuration configuration, ReadOnlySpan<Rgba32> sourcePixels, Span<Bgr24> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Rgba32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Bgr24 destRef = ref MemoryMarshal.GetReference(destPixels);
ref Bgr24 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -124,13 +123,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToL8(Configuration configuration, ReadOnlySpan<Rgba32> sourcePixels, Span<L8> destPixels)
public override void ToL8(Configuration configuration, ReadOnlySpan<Rgba32> sourcePixels, Span<L8> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Rgba32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref L8 destRef = ref MemoryMarshal.GetReference(destPixels);
ref L8 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -142,13 +141,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToL16(Configuration configuration, ReadOnlySpan<Rgba32> sourcePixels, Span<L16> destPixels)
public override void ToL16(Configuration configuration, ReadOnlySpan<Rgba32> sourcePixels, Span<L16> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Rgba32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref L16 destRef = ref MemoryMarshal.GetReference(destPixels);
ref L16 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -160,13 +159,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToLa16(Configuration configuration, ReadOnlySpan<Rgba32> sourcePixels, Span<La16> destPixels)
public override void ToLa16(Configuration configuration, ReadOnlySpan<Rgba32> sourcePixels, Span<La16> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Rgba32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref La16 destRef = ref MemoryMarshal.GetReference(destPixels);
ref La16 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -178,13 +177,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToLa32(Configuration configuration, ReadOnlySpan<Rgba32> sourcePixels, Span<La32> destPixels)
public override void ToLa32(Configuration configuration, ReadOnlySpan<Rgba32> sourcePixels, Span<La32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Rgba32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref La32 destRef = ref MemoryMarshal.GetReference(destPixels);
ref La32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -196,13 +195,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToRgb24(Configuration configuration, ReadOnlySpan<Rgba32> sourcePixels, Span<Rgb24> destPixels)
public override void ToRgb24(Configuration configuration, ReadOnlySpan<Rgba32> sourcePixels, Span<Rgb24> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Rgba32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgb24 destRef = ref MemoryMarshal.GetReference(destPixels);
ref Rgb24 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -214,13 +213,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToRgb48(Configuration configuration, ReadOnlySpan<Rgba32> sourcePixels, Span<Rgb48> destPixels)
public override void ToRgb48(Configuration configuration, ReadOnlySpan<Rgba32> sourcePixels, Span<Rgb48> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Rgba32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgb48 destRef = ref MemoryMarshal.GetReference(destPixels);
ref Rgb48 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -232,13 +231,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToRgba64(Configuration configuration, ReadOnlySpan<Rgba32> sourcePixels, Span<Rgba64> destPixels)
public override void ToRgba64(Configuration configuration, ReadOnlySpan<Rgba32> sourcePixels, Span<Rgba64> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Rgba32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgba64 destRef = ref MemoryMarshal.GetReference(destPixels);
ref Rgba64 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -250,13 +249,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToBgra5551(Configuration configuration, ReadOnlySpan<Rgba32> sourcePixels, Span<Bgra5551> destPixels)
public override void ToBgra5551(Configuration configuration, ReadOnlySpan<Rgba32> sourcePixels, Span<Bgra5551> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Rgba32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destPixels);
ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -267,14 +266,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
}
/// <inheritdoc />
internal override void From<TSourcePixel>(
public override void From<TSourcePixel>(
Configuration configuration,
ReadOnlySpan<TSourcePixel> sourcePixels,
Span<Rgba32> destinationPixels)
{
PixelOperations<TSourcePixel>.Instance.ToRgba32(configuration, sourcePixels, destinationPixels);
}
}
}
}

82
src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgba64.PixelOperations.Generated.cs

@ -11,7 +11,6 @@ using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace SixLabors.ImageSharp.PixelFormats
{
/// <content>
@ -25,32 +24,32 @@ namespace SixLabors.ImageSharp.PixelFormats
internal class PixelOperations : PixelOperations<Rgba64>
{
/// <inheritdoc />
internal override void FromRgba64(Configuration configuration, ReadOnlySpan<Rgba64> source, Span<Rgba64> destPixels)
public override void FromRgba64(Configuration configuration, ReadOnlySpan<Rgba64> source, Span<Rgba64> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(source, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(source, destinationPixels, nameof(destinationPixels));
source.CopyTo(destPixels);
source.CopyTo(destinationPixels);
}
/// <inheritdoc />
internal override void ToRgba64(Configuration configuration, ReadOnlySpan<Rgba64> sourcePixels, Span<Rgba64> destPixels)
public override void ToRgba64(Configuration configuration, ReadOnlySpan<Rgba64> sourcePixels, Span<Rgba64> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
sourcePixels.CopyTo(destPixels);
sourcePixels.CopyTo(destinationPixels);
}
/// <inheritdoc />
internal override void ToArgb32(Configuration configuration, ReadOnlySpan<Rgba64> sourcePixels, Span<Argb32> destPixels)
public override void ToArgb32(Configuration configuration, ReadOnlySpan<Rgba64> sourcePixels, Span<Argb32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Rgba64 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Argb32 destRef = ref MemoryMarshal.GetReference(destPixels);
ref Argb32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -62,13 +61,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToBgr24(Configuration configuration, ReadOnlySpan<Rgba64> sourcePixels, Span<Bgr24> destPixels)
public override void ToBgr24(Configuration configuration, ReadOnlySpan<Rgba64> sourcePixels, Span<Bgr24> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Rgba64 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Bgr24 destRef = ref MemoryMarshal.GetReference(destPixels);
ref Bgr24 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -80,13 +79,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToBgra32(Configuration configuration, ReadOnlySpan<Rgba64> sourcePixels, Span<Bgra32> destPixels)
public override void ToBgra32(Configuration configuration, ReadOnlySpan<Rgba64> sourcePixels, Span<Bgra32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Rgba64 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Bgra32 destRef = ref MemoryMarshal.GetReference(destPixels);
ref Bgra32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -98,13 +97,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToL8(Configuration configuration, ReadOnlySpan<Rgba64> sourcePixels, Span<L8> destPixels)
public override void ToL8(Configuration configuration, ReadOnlySpan<Rgba64> sourcePixels, Span<L8> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Rgba64 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref L8 destRef = ref MemoryMarshal.GetReference(destPixels);
ref L8 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -116,13 +115,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToL16(Configuration configuration, ReadOnlySpan<Rgba64> sourcePixels, Span<L16> destPixels)
public override void ToL16(Configuration configuration, ReadOnlySpan<Rgba64> sourcePixels, Span<L16> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Rgba64 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref L16 destRef = ref MemoryMarshal.GetReference(destPixels);
ref L16 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -134,13 +133,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToLa16(Configuration configuration, ReadOnlySpan<Rgba64> sourcePixels, Span<La16> destPixels)
public override void ToLa16(Configuration configuration, ReadOnlySpan<Rgba64> sourcePixels, Span<La16> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Rgba64 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref La16 destRef = ref MemoryMarshal.GetReference(destPixels);
ref La16 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -152,13 +151,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToLa32(Configuration configuration, ReadOnlySpan<Rgba64> sourcePixels, Span<La32> destPixels)
public override void ToLa32(Configuration configuration, ReadOnlySpan<Rgba64> sourcePixels, Span<La32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Rgba64 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref La32 destRef = ref MemoryMarshal.GetReference(destPixels);
ref La32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -170,13 +169,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToRgb24(Configuration configuration, ReadOnlySpan<Rgba64> sourcePixels, Span<Rgb24> destPixels)
public override void ToRgb24(Configuration configuration, ReadOnlySpan<Rgba64> sourcePixels, Span<Rgb24> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Rgba64 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgb24 destRef = ref MemoryMarshal.GetReference(destPixels);
ref Rgb24 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -188,13 +187,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToRgba32(Configuration configuration, ReadOnlySpan<Rgba64> sourcePixels, Span<Rgba32> destPixels)
public override void ToRgba32(Configuration configuration, ReadOnlySpan<Rgba64> sourcePixels, Span<Rgba32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Rgba64 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgba32 destRef = ref MemoryMarshal.GetReference(destPixels);
ref Rgba32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -206,13 +205,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToRgb48(Configuration configuration, ReadOnlySpan<Rgba64> sourcePixels, Span<Rgb48> destPixels)
public override void ToRgb48(Configuration configuration, ReadOnlySpan<Rgba64> sourcePixels, Span<Rgb48> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Rgba64 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgb48 destRef = ref MemoryMarshal.GetReference(destPixels);
ref Rgb48 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -224,13 +223,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToBgra5551(Configuration configuration, ReadOnlySpan<Rgba64> sourcePixels, Span<Bgra5551> destPixels)
public override void ToBgra5551(Configuration configuration, ReadOnlySpan<Rgba64> sourcePixels, Span<Bgra5551> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Rgba64 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destPixels);
ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -241,14 +240,13 @@ namespace SixLabors.ImageSharp.PixelFormats
}
}
/// <inheritdoc />
internal override void From<TSourcePixel>(
public override void From<TSourcePixel>(
Configuration configuration,
ReadOnlySpan<TSourcePixel> sourcePixels,
Span<Rgba64> destinationPixels)
{
PixelOperations<TSourcePixel>.Instance.ToRgba64(configuration, sourcePixels, destinationPixels);
}
}
}
}

36
src/ImageSharp/PixelFormats/PixelImplementations/Generated/_Common.ttinclude

@ -26,7 +26,7 @@ using System.Runtime.InteropServices;
{
#>
/// <inheritdoc />
internal override void From<TSourcePixel>(
public override void From<TSourcePixel>(
Configuration configuration,
ReadOnlySpan<TSourcePixel> sourcePixels,
Span<<#=pixelType#>> destinationPixels)
@ -40,21 +40,21 @@ using System.Runtime.InteropServices;
{
#>
/// <inheritdoc />
internal override void From<#=pixelType#>(Configuration configuration, ReadOnlySpan<<#=pixelType#>> source, Span<<#=pixelType#>> destPixels)
public override void From<#=pixelType#>(Configuration configuration, ReadOnlySpan<<#=pixelType#>> source, Span<<#=pixelType#>> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(source, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(source, destinationPixels, nameof(destinationPixels));
source.CopyTo(destPixels);
source.CopyTo(destinationPixels);
}
/// <inheritdoc />
internal override void To<#=pixelType#>(Configuration configuration, ReadOnlySpan<<#=pixelType#>> sourcePixels, Span<<#=pixelType#>> destPixels)
public override void To<#=pixelType#>(Configuration configuration, ReadOnlySpan<<#=pixelType#>> sourcePixels, Span<<#=pixelType#>> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
sourcePixels.CopyTo(destPixels);
sourcePixels.CopyTo(destinationPixels);
}
<#+
@ -65,13 +65,13 @@ using System.Runtime.InteropServices;
#>
/// <inheritdoc />
internal override void To<#=toPixelType#>(Configuration configuration, ReadOnlySpan<<#=fromPixelType#>> sourcePixels, Span<<#=toPixelType#>> destPixels)
public override void To<#=toPixelType#>(Configuration configuration, ReadOnlySpan<<#=fromPixelType#>> sourcePixels, Span<<#=toPixelType#>> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref <#=fromPixelType#> sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref <#=toPixelType#> destRef = ref MemoryMarshal.GetReference(destPixels);
ref <#=toPixelType#> destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -88,13 +88,13 @@ using System.Runtime.InteropServices;
{
#>
/// <inheritdoc />
internal override void To<#=otherPixelType#>(Configuration configuration, ReadOnlySpan<<#=thisPixelType#>> sourcePixels, Span<<#=otherPixelType#>> destPixels)
public override void To<#=otherPixelType#>(Configuration configuration, ReadOnlySpan<<#=thisPixelType#>> sourcePixels, Span<<#=otherPixelType#>> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref uint sourceRef = ref Unsafe.As<<#=thisPixelType#>,uint>(ref MemoryMarshal.GetReference(sourcePixels));
ref uint destRef = ref Unsafe.As<<#=otherPixelType#>, uint>(ref MemoryMarshal.GetReference(destPixels));
ref uint destRef = ref Unsafe.As<<#=otherPixelType#>, uint>(ref MemoryMarshal.GetReference(destinationPixels));
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -104,13 +104,13 @@ using System.Runtime.InteropServices;
}
/// <inheritdoc />
internal override void From<#=otherPixelType#>(Configuration configuration, ReadOnlySpan<<#=otherPixelType#>> sourcePixels, Span<<#=thisPixelType#>> destPixels)
public override void From<#=otherPixelType#>(Configuration configuration, ReadOnlySpan<<#=otherPixelType#>> sourcePixels, Span<<#=thisPixelType#>> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref uint sourceRef = ref Unsafe.As<<#=otherPixelType#>,uint>(ref MemoryMarshal.GetReference(sourcePixels));
ref uint destRef = ref Unsafe.As<<#=thisPixelType#>, uint>(ref MemoryMarshal.GetReference(destPixels));
ref uint destRef = ref Unsafe.As<<#=thisPixelType#>, uint>(ref MemoryMarshal.GetReference(destinationPixels));
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -130,9 +130,9 @@ using System.Runtime.InteropServices;
}
#>
/// <inheritdoc />
public override void FromVector4Destructive(Configuration configuration, Span<Vector4> sourceVectors, Span<<#=pixelType#>> destPixels, PixelConversionModifiers modifiers)
public override void FromVector4Destructive(Configuration configuration, Span<Vector4> sourceVectors, Span<<#=pixelType#>> destinationPixels, PixelConversionModifiers modifiers)
{
Vector4Converters.RgbaCompatible.FromVector4(configuration, this, sourceVectors, destPixels, modifiers.Remove(<#=removeTheseModifiers#>));
Vector4Converters.RgbaCompatible.FromVector4(configuration, this, sourceVectors, destinationPixels, modifiers.Remove(<#=removeTheseModifiers#>));
}
/// <inheritdoc />

18
src/ImageSharp/PixelFormats/PixelImplementations/Rgba32.PixelOperations.cs

@ -23,32 +23,32 @@ namespace SixLabors.ImageSharp.PixelFormats
public override void ToVector4(
Configuration configuration,
ReadOnlySpan<Rgba32> sourcePixels,
Span<Vector4> destVectors,
Span<Vector4> destinationVectors,
PixelConversionModifiers modifiers)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destVectors, nameof(destVectors));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationVectors, nameof(destinationVectors));
destVectors = destVectors.Slice(0, sourcePixels.Length);
destinationVectors = destinationVectors.Slice(0, sourcePixels.Length);
SimdUtils.BulkConvertByteToNormalizedFloat(
MemoryMarshal.Cast<Rgba32, byte>(sourcePixels),
MemoryMarshal.Cast<Vector4, float>(destVectors));
Vector4Converters.ApplyForwardConversionModifiers(destVectors, modifiers);
MemoryMarshal.Cast<Vector4, float>(destinationVectors));
Vector4Converters.ApplyForwardConversionModifiers(destinationVectors, modifiers);
}
/// <inheritdoc />
public override void FromVector4Destructive(
Configuration configuration,
Span<Vector4> sourceVectors,
Span<Rgba32> destPixels,
Span<Rgba32> destinationPixels,
PixelConversionModifiers modifiers)
{
Guard.DestinationShouldNotBeTooShort(sourceVectors, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourceVectors, destinationPixels, nameof(destinationPixels));
destPixels = destPixels.Slice(0, sourceVectors.Length);
destinationPixels = destinationPixels.Slice(0, sourceVectors.Length);
Vector4Converters.ApplyBackwardConversionModifiers(sourceVectors, modifiers);
SimdUtils.BulkConvertNormalizedFloatToByteClampOverflows(
MemoryMarshal.Cast<Vector4, float>(sourceVectors),
MemoryMarshal.Cast<Rgba32, byte>(destPixels));
MemoryMarshal.Cast<Rgba32, byte>(destinationPixels));
}
}
}

26
src/ImageSharp/PixelFormats/PixelImplementations/RgbaVector.PixelOperations.cs

@ -24,34 +24,34 @@ namespace SixLabors.ImageSharp.PixelFormats
public override void FromVector4Destructive(
Configuration configuration,
Span<Vector4> sourceVectors,
Span<RgbaVector> destinationColors,
Span<RgbaVector> destinationPixels,
PixelConversionModifiers modifiers)
{
Guard.DestinationShouldNotBeTooShort(sourceVectors, destinationColors, nameof(destinationColors));
Guard.DestinationShouldNotBeTooShort(sourceVectors, destinationPixels, nameof(destinationPixels));
Vector4Converters.ApplyBackwardConversionModifiers(sourceVectors, modifiers);
MemoryMarshal.Cast<Vector4, RgbaVector>(sourceVectors).CopyTo(destinationColors);
MemoryMarshal.Cast<Vector4, RgbaVector>(sourceVectors).CopyTo(destinationPixels);
}
/// <inheritdoc />
public override void ToVector4(
Configuration configuration,
ReadOnlySpan<RgbaVector> sourcePixels,
Span<Vector4> destVectors,
Span<Vector4> destinationVectors,
PixelConversionModifiers modifiers)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destVectors, nameof(destVectors));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationVectors, nameof(destinationVectors));
MemoryMarshal.Cast<RgbaVector, Vector4>(sourcePixels).CopyTo(destVectors);
Vector4Converters.ApplyForwardConversionModifiers(destVectors, modifiers);
MemoryMarshal.Cast<RgbaVector, Vector4>(sourcePixels).CopyTo(destinationVectors);
Vector4Converters.ApplyForwardConversionModifiers(destinationVectors, modifiers);
}
internal override void ToL8(Configuration configuration, ReadOnlySpan<RgbaVector> sourcePixels, Span<L8> destPixels)
public override void ToL8(Configuration configuration, ReadOnlySpan<RgbaVector> sourcePixels, Span<L8> destinationPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Vector4 sourceBaseRef = ref Unsafe.As<RgbaVector, Vector4>(ref MemoryMarshal.GetReference(sourcePixels));
ref L8 destBaseRef = ref MemoryMarshal.GetReference(destPixels);
ref L8 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -62,12 +62,12 @@ namespace SixLabors.ImageSharp.PixelFormats
}
}
internal override void ToL16(Configuration configuration, ReadOnlySpan<RgbaVector> sourcePixels, Span<L16> destPixels)
public override void ToL16(Configuration configuration, ReadOnlySpan<RgbaVector> sourcePixels, Span<L16> destinationPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Vector4 sourceBaseRef = ref Unsafe.As<RgbaVector, Vector4>(ref MemoryMarshal.GetReference(sourcePixels));
ref L16 destBaseRef = ref MemoryMarshal.GetReference(destPixels);
ref L16 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{

288
src/ImageSharp/PixelFormats/PixelOperations{TPixel}.Generated.cs

@ -15,13 +15,13 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations.</param>
/// <param name="source">The source <see cref="Span{T}"/> of <see cref="Argb32"/> data.</param>
/// <param name="destPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
internal virtual void FromArgb32(Configuration configuration, ReadOnlySpan<Argb32> source, Span<TPixel> destPixels)
/// <param name="destinationPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
public virtual void FromArgb32(Configuration configuration, ReadOnlySpan<Argb32> source, Span<TPixel> destinationPixels)
{
Guard.DestinationShouldNotBeTooShort(source, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(source, destinationPixels, nameof(destinationPixels));
ref Argb32 sourceBaseRef = ref MemoryMarshal.GetReference(source);
ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destPixels);
ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < source.Length; i++)
{
@ -38,12 +38,12 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations.</param>
/// <param name="sourceBytes">The <see cref="ReadOnlySpan{T}"/> to the source bytes.</param>
/// <param name="destPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
/// <param name="destinationPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
/// <param name="count">The number of pixels to convert.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void FromArgb32Bytes(Configuration configuration, ReadOnlySpan<byte> sourceBytes, Span<TPixel> destPixels, int count)
public void FromArgb32Bytes(Configuration configuration, ReadOnlySpan<byte> sourceBytes, Span<TPixel> destinationPixels, int count)
{
this.FromArgb32(configuration, MemoryMarshal.Cast<byte, Argb32>(sourceBytes).Slice(0, count), destPixels);
this.FromArgb32(configuration, MemoryMarshal.Cast<byte, Argb32>(sourceBytes).Slice(0, count), destinationPixels);
}
/// <summary>
@ -51,13 +51,13 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations</param>
/// <param name="sourcePixels">The span of source pixels</param>
/// <param name="destPixels">The destination span of <see cref="Argb32"/> data.</param>
internal virtual void ToArgb32(Configuration configuration, ReadOnlySpan<TPixel> sourcePixels, Span<Argb32> destPixels)
/// <param name="destinationPixels">The destination span of <see cref="Argb32"/> data.</param>
public virtual void ToArgb32(Configuration configuration, ReadOnlySpan<TPixel> sourcePixels, Span<Argb32> destinationPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Argb32 destBaseRef = ref MemoryMarshal.GetReference(destPixels);
ref Argb32 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -77,7 +77,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <param name="destBytes">The <see cref="Span{T}"/> to the destination bytes.</param>
/// <param name="count">The number of pixels to convert.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void ToArgb32Bytes(Configuration configuration, ReadOnlySpan<TPixel> sourcePixels, Span<byte> destBytes, int count)
public void ToArgb32Bytes(Configuration configuration, ReadOnlySpan<TPixel> sourcePixels, Span<byte> destBytes, int count)
{
this.ToArgb32(configuration, sourcePixels.Slice(0, count), MemoryMarshal.Cast<byte, Argb32>(destBytes));
}
@ -87,13 +87,13 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations.</param>
/// <param name="source">The source <see cref="Span{T}"/> of <see cref="Bgr24"/> data.</param>
/// <param name="destPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
internal virtual void FromBgr24(Configuration configuration, ReadOnlySpan<Bgr24> source, Span<TPixel> destPixels)
/// <param name="destinationPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
public virtual void FromBgr24(Configuration configuration, ReadOnlySpan<Bgr24> source, Span<TPixel> destinationPixels)
{
Guard.DestinationShouldNotBeTooShort(source, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(source, destinationPixels, nameof(destinationPixels));
ref Bgr24 sourceBaseRef = ref MemoryMarshal.GetReference(source);
ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destPixels);
ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < source.Length; i++)
{
@ -110,12 +110,12 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations.</param>
/// <param name="sourceBytes">The <see cref="ReadOnlySpan{T}"/> to the source bytes.</param>
/// <param name="destPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
/// <param name="destinationPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
/// <param name="count">The number of pixels to convert.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void FromBgr24Bytes(Configuration configuration, ReadOnlySpan<byte> sourceBytes, Span<TPixel> destPixels, int count)
public void FromBgr24Bytes(Configuration configuration, ReadOnlySpan<byte> sourceBytes, Span<TPixel> destinationPixels, int count)
{
this.FromBgr24(configuration, MemoryMarshal.Cast<byte, Bgr24>(sourceBytes).Slice(0, count), destPixels);
this.FromBgr24(configuration, MemoryMarshal.Cast<byte, Bgr24>(sourceBytes).Slice(0, count), destinationPixels);
}
/// <summary>
@ -123,13 +123,13 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations</param>
/// <param name="sourcePixels">The span of source pixels</param>
/// <param name="destPixels">The destination span of <see cref="Bgr24"/> data.</param>
internal virtual void ToBgr24(Configuration configuration, ReadOnlySpan<TPixel> sourcePixels, Span<Bgr24> destPixels)
/// <param name="destinationPixels">The destination span of <see cref="Bgr24"/> data.</param>
public virtual void ToBgr24(Configuration configuration, ReadOnlySpan<TPixel> sourcePixels, Span<Bgr24> destinationPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Bgr24 destBaseRef = ref MemoryMarshal.GetReference(destPixels);
ref Bgr24 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -149,7 +149,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <param name="destBytes">The <see cref="Span{T}"/> to the destination bytes.</param>
/// <param name="count">The number of pixels to convert.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void ToBgr24Bytes(Configuration configuration, ReadOnlySpan<TPixel> sourcePixels, Span<byte> destBytes, int count)
public void ToBgr24Bytes(Configuration configuration, ReadOnlySpan<TPixel> sourcePixels, Span<byte> destBytes, int count)
{
this.ToBgr24(configuration, sourcePixels.Slice(0, count), MemoryMarshal.Cast<byte, Bgr24>(destBytes));
}
@ -159,13 +159,13 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations.</param>
/// <param name="source">The source <see cref="Span{T}"/> of <see cref="Bgra32"/> data.</param>
/// <param name="destPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
internal virtual void FromBgra32(Configuration configuration, ReadOnlySpan<Bgra32> source, Span<TPixel> destPixels)
/// <param name="destinationPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
public virtual void FromBgra32(Configuration configuration, ReadOnlySpan<Bgra32> source, Span<TPixel> destinationPixels)
{
Guard.DestinationShouldNotBeTooShort(source, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(source, destinationPixels, nameof(destinationPixels));
ref Bgra32 sourceBaseRef = ref MemoryMarshal.GetReference(source);
ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destPixels);
ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < source.Length; i++)
{
@ -182,12 +182,12 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations.</param>
/// <param name="sourceBytes">The <see cref="ReadOnlySpan{T}"/> to the source bytes.</param>
/// <param name="destPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
/// <param name="destinationPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
/// <param name="count">The number of pixels to convert.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void FromBgra32Bytes(Configuration configuration, ReadOnlySpan<byte> sourceBytes, Span<TPixel> destPixels, int count)
public void FromBgra32Bytes(Configuration configuration, ReadOnlySpan<byte> sourceBytes, Span<TPixel> destinationPixels, int count)
{
this.FromBgra32(configuration, MemoryMarshal.Cast<byte, Bgra32>(sourceBytes).Slice(0, count), destPixels);
this.FromBgra32(configuration, MemoryMarshal.Cast<byte, Bgra32>(sourceBytes).Slice(0, count), destinationPixels);
}
/// <summary>
@ -195,13 +195,13 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations</param>
/// <param name="sourcePixels">The span of source pixels</param>
/// <param name="destPixels">The destination span of <see cref="Bgra32"/> data.</param>
internal virtual void ToBgra32(Configuration configuration, ReadOnlySpan<TPixel> sourcePixels, Span<Bgra32> destPixels)
/// <param name="destinationPixels">The destination span of <see cref="Bgra32"/> data.</param>
public virtual void ToBgra32(Configuration configuration, ReadOnlySpan<TPixel> sourcePixels, Span<Bgra32> destinationPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Bgra32 destBaseRef = ref MemoryMarshal.GetReference(destPixels);
ref Bgra32 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -221,7 +221,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <param name="destBytes">The <see cref="Span{T}"/> to the destination bytes.</param>
/// <param name="count">The number of pixels to convert.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void ToBgra32Bytes(Configuration configuration, ReadOnlySpan<TPixel> sourcePixels, Span<byte> destBytes, int count)
public void ToBgra32Bytes(Configuration configuration, ReadOnlySpan<TPixel> sourcePixels, Span<byte> destBytes, int count)
{
this.ToBgra32(configuration, sourcePixels.Slice(0, count), MemoryMarshal.Cast<byte, Bgra32>(destBytes));
}
@ -231,13 +231,13 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations.</param>
/// <param name="source">The source <see cref="Span{T}"/> of <see cref="L8"/> data.</param>
/// <param name="destPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
internal virtual void FromL8(Configuration configuration, ReadOnlySpan<L8> source, Span<TPixel> destPixels)
/// <param name="destinationPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
public virtual void FromL8(Configuration configuration, ReadOnlySpan<L8> source, Span<TPixel> destinationPixels)
{
Guard.DestinationShouldNotBeTooShort(source, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(source, destinationPixels, nameof(destinationPixels));
ref L8 sourceBaseRef = ref MemoryMarshal.GetReference(source);
ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destPixels);
ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < source.Length; i++)
{
@ -254,12 +254,12 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations.</param>
/// <param name="sourceBytes">The <see cref="ReadOnlySpan{T}"/> to the source bytes.</param>
/// <param name="destPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
/// <param name="destinationPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
/// <param name="count">The number of pixels to convert.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void FromL8Bytes(Configuration configuration, ReadOnlySpan<byte> sourceBytes, Span<TPixel> destPixels, int count)
public void FromL8Bytes(Configuration configuration, ReadOnlySpan<byte> sourceBytes, Span<TPixel> destinationPixels, int count)
{
this.FromL8(configuration, MemoryMarshal.Cast<byte, L8>(sourceBytes).Slice(0, count), destPixels);
this.FromL8(configuration, MemoryMarshal.Cast<byte, L8>(sourceBytes).Slice(0, count), destinationPixels);
}
/// <summary>
@ -267,13 +267,13 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations</param>
/// <param name="sourcePixels">The span of source pixels</param>
/// <param name="destPixels">The destination span of <see cref="L8"/> data.</param>
internal virtual void ToL8(Configuration configuration, ReadOnlySpan<TPixel> sourcePixels, Span<L8> destPixels)
/// <param name="destinationPixels">The destination span of <see cref="L8"/> data.</param>
public virtual void ToL8(Configuration configuration, ReadOnlySpan<TPixel> sourcePixels, Span<L8> destinationPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels);
ref L8 destBaseRef = ref MemoryMarshal.GetReference(destPixels);
ref L8 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -293,7 +293,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <param name="destBytes">The <see cref="Span{T}"/> to the destination bytes.</param>
/// <param name="count">The number of pixels to convert.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void ToL8Bytes(Configuration configuration, ReadOnlySpan<TPixel> sourcePixels, Span<byte> destBytes, int count)
public void ToL8Bytes(Configuration configuration, ReadOnlySpan<TPixel> sourcePixels, Span<byte> destBytes, int count)
{
this.ToL8(configuration, sourcePixels.Slice(0, count), MemoryMarshal.Cast<byte, L8>(destBytes));
}
@ -303,13 +303,13 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations.</param>
/// <param name="source">The source <see cref="Span{T}"/> of <see cref="L16"/> data.</param>
/// <param name="destPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
internal virtual void FromL16(Configuration configuration, ReadOnlySpan<L16> source, Span<TPixel> destPixels)
/// <param name="destinationPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
public virtual void FromL16(Configuration configuration, ReadOnlySpan<L16> source, Span<TPixel> destinationPixels)
{
Guard.DestinationShouldNotBeTooShort(source, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(source, destinationPixels, nameof(destinationPixels));
ref L16 sourceBaseRef = ref MemoryMarshal.GetReference(source);
ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destPixels);
ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < source.Length; i++)
{
@ -326,12 +326,12 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations.</param>
/// <param name="sourceBytes">The <see cref="ReadOnlySpan{T}"/> to the source bytes.</param>
/// <param name="destPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
/// <param name="destinationPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
/// <param name="count">The number of pixels to convert.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void FromL16Bytes(Configuration configuration, ReadOnlySpan<byte> sourceBytes, Span<TPixel> destPixels, int count)
public void FromL16Bytes(Configuration configuration, ReadOnlySpan<byte> sourceBytes, Span<TPixel> destinationPixels, int count)
{
this.FromL16(configuration, MemoryMarshal.Cast<byte, L16>(sourceBytes).Slice(0, count), destPixels);
this.FromL16(configuration, MemoryMarshal.Cast<byte, L16>(sourceBytes).Slice(0, count), destinationPixels);
}
/// <summary>
@ -339,13 +339,13 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations</param>
/// <param name="sourcePixels">The span of source pixels</param>
/// <param name="destPixels">The destination span of <see cref="L16"/> data.</param>
internal virtual void ToL16(Configuration configuration, ReadOnlySpan<TPixel> sourcePixels, Span<L16> destPixels)
/// <param name="destinationPixels">The destination span of <see cref="L16"/> data.</param>
public virtual void ToL16(Configuration configuration, ReadOnlySpan<TPixel> sourcePixels, Span<L16> destinationPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels);
ref L16 destBaseRef = ref MemoryMarshal.GetReference(destPixels);
ref L16 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -365,7 +365,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <param name="destBytes">The <see cref="Span{T}"/> to the destination bytes.</param>
/// <param name="count">The number of pixels to convert.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void ToL16Bytes(Configuration configuration, ReadOnlySpan<TPixel> sourcePixels, Span<byte> destBytes, int count)
public void ToL16Bytes(Configuration configuration, ReadOnlySpan<TPixel> sourcePixels, Span<byte> destBytes, int count)
{
this.ToL16(configuration, sourcePixels.Slice(0, count), MemoryMarshal.Cast<byte, L16>(destBytes));
}
@ -375,13 +375,13 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations.</param>
/// <param name="source">The source <see cref="Span{T}"/> of <see cref="La16"/> data.</param>
/// <param name="destPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
internal virtual void FromLa16(Configuration configuration, ReadOnlySpan<La16> source, Span<TPixel> destPixels)
/// <param name="destinationPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
public virtual void FromLa16(Configuration configuration, ReadOnlySpan<La16> source, Span<TPixel> destinationPixels)
{
Guard.DestinationShouldNotBeTooShort(source, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(source, destinationPixels, nameof(destinationPixels));
ref La16 sourceBaseRef = ref MemoryMarshal.GetReference(source);
ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destPixels);
ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < source.Length; i++)
{
@ -398,12 +398,12 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations.</param>
/// <param name="sourceBytes">The <see cref="ReadOnlySpan{T}"/> to the source bytes.</param>
/// <param name="destPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
/// <param name="destinationPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
/// <param name="count">The number of pixels to convert.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void FromLa16Bytes(Configuration configuration, ReadOnlySpan<byte> sourceBytes, Span<TPixel> destPixels, int count)
public void FromLa16Bytes(Configuration configuration, ReadOnlySpan<byte> sourceBytes, Span<TPixel> destinationPixels, int count)
{
this.FromLa16(configuration, MemoryMarshal.Cast<byte, La16>(sourceBytes).Slice(0, count), destPixels);
this.FromLa16(configuration, MemoryMarshal.Cast<byte, La16>(sourceBytes).Slice(0, count), destinationPixels);
}
/// <summary>
@ -411,13 +411,13 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations</param>
/// <param name="sourcePixels">The span of source pixels</param>
/// <param name="destPixels">The destination span of <see cref="La16"/> data.</param>
internal virtual void ToLa16(Configuration configuration, ReadOnlySpan<TPixel> sourcePixels, Span<La16> destPixels)
/// <param name="destinationPixels">The destination span of <see cref="La16"/> data.</param>
public virtual void ToLa16(Configuration configuration, ReadOnlySpan<TPixel> sourcePixels, Span<La16> destinationPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels);
ref La16 destBaseRef = ref MemoryMarshal.GetReference(destPixels);
ref La16 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -437,7 +437,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <param name="destBytes">The <see cref="Span{T}"/> to the destination bytes.</param>
/// <param name="count">The number of pixels to convert.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void ToLa16Bytes(Configuration configuration, ReadOnlySpan<TPixel> sourcePixels, Span<byte> destBytes, int count)
public void ToLa16Bytes(Configuration configuration, ReadOnlySpan<TPixel> sourcePixels, Span<byte> destBytes, int count)
{
this.ToLa16(configuration, sourcePixels.Slice(0, count), MemoryMarshal.Cast<byte, La16>(destBytes));
}
@ -447,13 +447,13 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations.</param>
/// <param name="source">The source <see cref="Span{T}"/> of <see cref="La32"/> data.</param>
/// <param name="destPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
internal virtual void FromLa32(Configuration configuration, ReadOnlySpan<La32> source, Span<TPixel> destPixels)
/// <param name="destinationPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
public virtual void FromLa32(Configuration configuration, ReadOnlySpan<La32> source, Span<TPixel> destinationPixels)
{
Guard.DestinationShouldNotBeTooShort(source, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(source, destinationPixels, nameof(destinationPixels));
ref La32 sourceBaseRef = ref MemoryMarshal.GetReference(source);
ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destPixels);
ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < source.Length; i++)
{
@ -470,12 +470,12 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations.</param>
/// <param name="sourceBytes">The <see cref="ReadOnlySpan{T}"/> to the source bytes.</param>
/// <param name="destPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
/// <param name="destinationPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
/// <param name="count">The number of pixels to convert.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void FromLa32Bytes(Configuration configuration, ReadOnlySpan<byte> sourceBytes, Span<TPixel> destPixels, int count)
public void FromLa32Bytes(Configuration configuration, ReadOnlySpan<byte> sourceBytes, Span<TPixel> destinationPixels, int count)
{
this.FromLa32(configuration, MemoryMarshal.Cast<byte, La32>(sourceBytes).Slice(0, count), destPixels);
this.FromLa32(configuration, MemoryMarshal.Cast<byte, La32>(sourceBytes).Slice(0, count), destinationPixels);
}
/// <summary>
@ -483,13 +483,13 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations</param>
/// <param name="sourcePixels">The span of source pixels</param>
/// <param name="destPixels">The destination span of <see cref="La32"/> data.</param>
internal virtual void ToLa32(Configuration configuration, ReadOnlySpan<TPixel> sourcePixels, Span<La32> destPixels)
/// <param name="destinationPixels">The destination span of <see cref="La32"/> data.</param>
public virtual void ToLa32(Configuration configuration, ReadOnlySpan<TPixel> sourcePixels, Span<La32> destinationPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels);
ref La32 destBaseRef = ref MemoryMarshal.GetReference(destPixels);
ref La32 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -509,7 +509,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <param name="destBytes">The <see cref="Span{T}"/> to the destination bytes.</param>
/// <param name="count">The number of pixels to convert.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void ToLa32Bytes(Configuration configuration, ReadOnlySpan<TPixel> sourcePixels, Span<byte> destBytes, int count)
public void ToLa32Bytes(Configuration configuration, ReadOnlySpan<TPixel> sourcePixels, Span<byte> destBytes, int count)
{
this.ToLa32(configuration, sourcePixels.Slice(0, count), MemoryMarshal.Cast<byte, La32>(destBytes));
}
@ -519,13 +519,13 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations.</param>
/// <param name="source">The source <see cref="Span{T}"/> of <see cref="Rgb24"/> data.</param>
/// <param name="destPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
internal virtual void FromRgb24(Configuration configuration, ReadOnlySpan<Rgb24> source, Span<TPixel> destPixels)
/// <param name="destinationPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
public virtual void FromRgb24(Configuration configuration, ReadOnlySpan<Rgb24> source, Span<TPixel> destinationPixels)
{
Guard.DestinationShouldNotBeTooShort(source, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(source, destinationPixels, nameof(destinationPixels));
ref Rgb24 sourceBaseRef = ref MemoryMarshal.GetReference(source);
ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destPixels);
ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < source.Length; i++)
{
@ -542,12 +542,12 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations.</param>
/// <param name="sourceBytes">The <see cref="ReadOnlySpan{T}"/> to the source bytes.</param>
/// <param name="destPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
/// <param name="destinationPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
/// <param name="count">The number of pixels to convert.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void FromRgb24Bytes(Configuration configuration, ReadOnlySpan<byte> sourceBytes, Span<TPixel> destPixels, int count)
public void FromRgb24Bytes(Configuration configuration, ReadOnlySpan<byte> sourceBytes, Span<TPixel> destinationPixels, int count)
{
this.FromRgb24(configuration, MemoryMarshal.Cast<byte, Rgb24>(sourceBytes).Slice(0, count), destPixels);
this.FromRgb24(configuration, MemoryMarshal.Cast<byte, Rgb24>(sourceBytes).Slice(0, count), destinationPixels);
}
/// <summary>
@ -555,13 +555,13 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations</param>
/// <param name="sourcePixels">The span of source pixels</param>
/// <param name="destPixels">The destination span of <see cref="Rgb24"/> data.</param>
internal virtual void ToRgb24(Configuration configuration, ReadOnlySpan<TPixel> sourcePixels, Span<Rgb24> destPixels)
/// <param name="destinationPixels">The destination span of <see cref="Rgb24"/> data.</param>
public virtual void ToRgb24(Configuration configuration, ReadOnlySpan<TPixel> sourcePixels, Span<Rgb24> destinationPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgb24 destBaseRef = ref MemoryMarshal.GetReference(destPixels);
ref Rgb24 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -581,7 +581,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <param name="destBytes">The <see cref="Span{T}"/> to the destination bytes.</param>
/// <param name="count">The number of pixels to convert.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void ToRgb24Bytes(Configuration configuration, ReadOnlySpan<TPixel> sourcePixels, Span<byte> destBytes, int count)
public void ToRgb24Bytes(Configuration configuration, ReadOnlySpan<TPixel> sourcePixels, Span<byte> destBytes, int count)
{
this.ToRgb24(configuration, sourcePixels.Slice(0, count), MemoryMarshal.Cast<byte, Rgb24>(destBytes));
}
@ -591,13 +591,13 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations.</param>
/// <param name="source">The source <see cref="Span{T}"/> of <see cref="Rgba32"/> data.</param>
/// <param name="destPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
internal virtual void FromRgba32(Configuration configuration, ReadOnlySpan<Rgba32> source, Span<TPixel> destPixels)
/// <param name="destinationPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
public virtual void FromRgba32(Configuration configuration, ReadOnlySpan<Rgba32> source, Span<TPixel> destinationPixels)
{
Guard.DestinationShouldNotBeTooShort(source, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(source, destinationPixels, nameof(destinationPixels));
ref Rgba32 sourceBaseRef = ref MemoryMarshal.GetReference(source);
ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destPixels);
ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < source.Length; i++)
{
@ -614,12 +614,12 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations.</param>
/// <param name="sourceBytes">The <see cref="ReadOnlySpan{T}"/> to the source bytes.</param>
/// <param name="destPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
/// <param name="destinationPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
/// <param name="count">The number of pixels to convert.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void FromRgba32Bytes(Configuration configuration, ReadOnlySpan<byte> sourceBytes, Span<TPixel> destPixels, int count)
public void FromRgba32Bytes(Configuration configuration, ReadOnlySpan<byte> sourceBytes, Span<TPixel> destinationPixels, int count)
{
this.FromRgba32(configuration, MemoryMarshal.Cast<byte, Rgba32>(sourceBytes).Slice(0, count), destPixels);
this.FromRgba32(configuration, MemoryMarshal.Cast<byte, Rgba32>(sourceBytes).Slice(0, count), destinationPixels);
}
/// <summary>
@ -627,13 +627,13 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations</param>
/// <param name="sourcePixels">The span of source pixels</param>
/// <param name="destPixels">The destination span of <see cref="Rgba32"/> data.</param>
internal virtual void ToRgba32(Configuration configuration, ReadOnlySpan<TPixel> sourcePixels, Span<Rgba32> destPixels)
/// <param name="destinationPixels">The destination span of <see cref="Rgba32"/> data.</param>
public virtual void ToRgba32(Configuration configuration, ReadOnlySpan<TPixel> sourcePixels, Span<Rgba32> destinationPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgba32 destBaseRef = ref MemoryMarshal.GetReference(destPixels);
ref Rgba32 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -653,7 +653,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <param name="destBytes">The <see cref="Span{T}"/> to the destination bytes.</param>
/// <param name="count">The number of pixels to convert.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void ToRgba32Bytes(Configuration configuration, ReadOnlySpan<TPixel> sourcePixels, Span<byte> destBytes, int count)
public void ToRgba32Bytes(Configuration configuration, ReadOnlySpan<TPixel> sourcePixels, Span<byte> destBytes, int count)
{
this.ToRgba32(configuration, sourcePixels.Slice(0, count), MemoryMarshal.Cast<byte, Rgba32>(destBytes));
}
@ -663,13 +663,13 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations.</param>
/// <param name="source">The source <see cref="Span{T}"/> of <see cref="Rgb48"/> data.</param>
/// <param name="destPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
internal virtual void FromRgb48(Configuration configuration, ReadOnlySpan<Rgb48> source, Span<TPixel> destPixels)
/// <param name="destinationPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
public virtual void FromRgb48(Configuration configuration, ReadOnlySpan<Rgb48> source, Span<TPixel> destinationPixels)
{
Guard.DestinationShouldNotBeTooShort(source, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(source, destinationPixels, nameof(destinationPixels));
ref Rgb48 sourceBaseRef = ref MemoryMarshal.GetReference(source);
ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destPixels);
ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < source.Length; i++)
{
@ -686,12 +686,12 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations.</param>
/// <param name="sourceBytes">The <see cref="ReadOnlySpan{T}"/> to the source bytes.</param>
/// <param name="destPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
/// <param name="destinationPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
/// <param name="count">The number of pixels to convert.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void FromRgb48Bytes(Configuration configuration, ReadOnlySpan<byte> sourceBytes, Span<TPixel> destPixels, int count)
public void FromRgb48Bytes(Configuration configuration, ReadOnlySpan<byte> sourceBytes, Span<TPixel> destinationPixels, int count)
{
this.FromRgb48(configuration, MemoryMarshal.Cast<byte, Rgb48>(sourceBytes).Slice(0, count), destPixels);
this.FromRgb48(configuration, MemoryMarshal.Cast<byte, Rgb48>(sourceBytes).Slice(0, count), destinationPixels);
}
/// <summary>
@ -699,13 +699,13 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations</param>
/// <param name="sourcePixels">The span of source pixels</param>
/// <param name="destPixels">The destination span of <see cref="Rgb48"/> data.</param>
internal virtual void ToRgb48(Configuration configuration, ReadOnlySpan<TPixel> sourcePixels, Span<Rgb48> destPixels)
/// <param name="destinationPixels">The destination span of <see cref="Rgb48"/> data.</param>
public virtual void ToRgb48(Configuration configuration, ReadOnlySpan<TPixel> sourcePixels, Span<Rgb48> destinationPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgb48 destBaseRef = ref MemoryMarshal.GetReference(destPixels);
ref Rgb48 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -725,7 +725,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <param name="destBytes">The <see cref="Span{T}"/> to the destination bytes.</param>
/// <param name="count">The number of pixels to convert.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void ToRgb48Bytes(Configuration configuration, ReadOnlySpan<TPixel> sourcePixels, Span<byte> destBytes, int count)
public void ToRgb48Bytes(Configuration configuration, ReadOnlySpan<TPixel> sourcePixels, Span<byte> destBytes, int count)
{
this.ToRgb48(configuration, sourcePixels.Slice(0, count), MemoryMarshal.Cast<byte, Rgb48>(destBytes));
}
@ -735,13 +735,13 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations.</param>
/// <param name="source">The source <see cref="Span{T}"/> of <see cref="Rgba64"/> data.</param>
/// <param name="destPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
internal virtual void FromRgba64(Configuration configuration, ReadOnlySpan<Rgba64> source, Span<TPixel> destPixels)
/// <param name="destinationPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
public virtual void FromRgba64(Configuration configuration, ReadOnlySpan<Rgba64> source, Span<TPixel> destinationPixels)
{
Guard.DestinationShouldNotBeTooShort(source, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(source, destinationPixels, nameof(destinationPixels));
ref Rgba64 sourceBaseRef = ref MemoryMarshal.GetReference(source);
ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destPixels);
ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < source.Length; i++)
{
@ -758,12 +758,12 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations.</param>
/// <param name="sourceBytes">The <see cref="ReadOnlySpan{T}"/> to the source bytes.</param>
/// <param name="destPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
/// <param name="destinationPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
/// <param name="count">The number of pixels to convert.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void FromRgba64Bytes(Configuration configuration, ReadOnlySpan<byte> sourceBytes, Span<TPixel> destPixels, int count)
public void FromRgba64Bytes(Configuration configuration, ReadOnlySpan<byte> sourceBytes, Span<TPixel> destinationPixels, int count)
{
this.FromRgba64(configuration, MemoryMarshal.Cast<byte, Rgba64>(sourceBytes).Slice(0, count), destPixels);
this.FromRgba64(configuration, MemoryMarshal.Cast<byte, Rgba64>(sourceBytes).Slice(0, count), destinationPixels);
}
/// <summary>
@ -771,13 +771,13 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations</param>
/// <param name="sourcePixels">The span of source pixels</param>
/// <param name="destPixels">The destination span of <see cref="Rgba64"/> data.</param>
internal virtual void ToRgba64(Configuration configuration, ReadOnlySpan<TPixel> sourcePixels, Span<Rgba64> destPixels)
/// <param name="destinationPixels">The destination span of <see cref="Rgba64"/> data.</param>
public virtual void ToRgba64(Configuration configuration, ReadOnlySpan<TPixel> sourcePixels, Span<Rgba64> destinationPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgba64 destBaseRef = ref MemoryMarshal.GetReference(destPixels);
ref Rgba64 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -797,7 +797,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <param name="destBytes">The <see cref="Span{T}"/> to the destination bytes.</param>
/// <param name="count">The number of pixels to convert.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void ToRgba64Bytes(Configuration configuration, ReadOnlySpan<TPixel> sourcePixels, Span<byte> destBytes, int count)
public void ToRgba64Bytes(Configuration configuration, ReadOnlySpan<TPixel> sourcePixels, Span<byte> destBytes, int count)
{
this.ToRgba64(configuration, sourcePixels.Slice(0, count), MemoryMarshal.Cast<byte, Rgba64>(destBytes));
}
@ -807,13 +807,13 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations.</param>
/// <param name="source">The source <see cref="Span{T}"/> of <see cref="Bgra5551"/> data.</param>
/// <param name="destPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
internal virtual void FromBgra5551(Configuration configuration, ReadOnlySpan<Bgra5551> source, Span<TPixel> destPixels)
/// <param name="destinationPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
public virtual void FromBgra5551(Configuration configuration, ReadOnlySpan<Bgra5551> source, Span<TPixel> destinationPixels)
{
Guard.DestinationShouldNotBeTooShort(source, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(source, destinationPixels, nameof(destinationPixels));
ref Bgra5551 sourceBaseRef = ref MemoryMarshal.GetReference(source);
ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destPixels);
ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < source.Length; i++)
{
@ -830,12 +830,12 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations.</param>
/// <param name="sourceBytes">The <see cref="ReadOnlySpan{T}"/> to the source bytes.</param>
/// <param name="destPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
/// <param name="destinationPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
/// <param name="count">The number of pixels to convert.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void FromBgra5551Bytes(Configuration configuration, ReadOnlySpan<byte> sourceBytes, Span<TPixel> destPixels, int count)
public void FromBgra5551Bytes(Configuration configuration, ReadOnlySpan<byte> sourceBytes, Span<TPixel> destinationPixels, int count)
{
this.FromBgra5551(configuration, MemoryMarshal.Cast<byte, Bgra5551>(sourceBytes).Slice(0, count), destPixels);
this.FromBgra5551(configuration, MemoryMarshal.Cast<byte, Bgra5551>(sourceBytes).Slice(0, count), destinationPixels);
}
/// <summary>
@ -843,13 +843,13 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations</param>
/// <param name="sourcePixels">The span of source pixels</param>
/// <param name="destPixels">The destination span of <see cref="Bgra5551"/> data.</param>
internal virtual void ToBgra5551(Configuration configuration, ReadOnlySpan<TPixel> sourcePixels, Span<Bgra5551> destPixels)
/// <param name="destinationPixels">The destination span of <see cref="Bgra5551"/> data.</param>
public virtual void ToBgra5551(Configuration configuration, ReadOnlySpan<TPixel> sourcePixels, Span<Bgra5551> destinationPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Bgra5551 destBaseRef = ref MemoryMarshal.GetReference(destPixels);
ref Bgra5551 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -869,7 +869,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <param name="destBytes">The <see cref="Span{T}"/> to the destination bytes.</param>
/// <param name="count">The number of pixels to convert.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void ToBgra5551Bytes(Configuration configuration, ReadOnlySpan<TPixel> sourcePixels, Span<byte> destBytes, int count)
public void ToBgra5551Bytes(Configuration configuration, ReadOnlySpan<TPixel> sourcePixels, Span<byte> destBytes, int count)
{
this.ToBgra5551(configuration, sourcePixels.Slice(0, count), MemoryMarshal.Cast<byte, Bgra5551>(destBytes));
}

24
src/ImageSharp/PixelFormats/PixelOperations{TPixel}.Generated.tt

@ -20,13 +20,13 @@
/// </summary>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations.</param>
/// <param name="source">The source <see cref="Span{T}"/> of <see cref="<#=pixelType#>"/> data.</param>
/// <param name="destPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
internal virtual void From<#=pixelType#>(Configuration configuration, ReadOnlySpan<<#=pixelType#>> source, Span<TPixel> destPixels)
/// <param name="destinationPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
public virtual void From<#=pixelType#>(Configuration configuration, ReadOnlySpan<<#=pixelType#>> source, Span<TPixel> destinationPixels)
{
Guard.DestinationShouldNotBeTooShort(source, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(source, destinationPixels, nameof(destinationPixels));
ref <#=pixelType#> sourceBaseRef = ref MemoryMarshal.GetReference(source);
ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destPixels);
ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < source.Length; i++)
{
@ -43,12 +43,12 @@
/// </summary>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations.</param>
/// <param name="sourceBytes">The <see cref="ReadOnlySpan{T}"/> to the source bytes.</param>
/// <param name="destPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
/// <param name="destinationPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
/// <param name="count">The number of pixels to convert.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void From<#=pixelType#>Bytes(Configuration configuration, ReadOnlySpan<byte> sourceBytes, Span<TPixel> destPixels, int count)
public void From<#=pixelType#>Bytes(Configuration configuration, ReadOnlySpan<byte> sourceBytes, Span<TPixel> destinationPixels, int count)
{
this.From<#=pixelType#>(configuration, MemoryMarshal.Cast<byte, <#=pixelType#>>(sourceBytes).Slice(0, count), destPixels);
this.From<#=pixelType#>(configuration, MemoryMarshal.Cast<byte, <#=pixelType#>>(sourceBytes).Slice(0, count), destinationPixels);
}
<#
@ -62,13 +62,13 @@
/// </summary>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations</param>
/// <param name="sourcePixels">The span of source pixels</param>
/// <param name="destPixels">The destination span of <see cref="<#=pixelType#>"/> data.</param>
internal virtual void To<#=pixelType#>(Configuration configuration, ReadOnlySpan<TPixel> sourcePixels, Span<<#=pixelType#>> destPixels)
/// <param name="destinationPixels">The destination span of <see cref="<#=pixelType#>"/> data.</param>
public virtual void To<#=pixelType#>(Configuration configuration, ReadOnlySpan<TPixel> sourcePixels, Span<<#=pixelType#>> destinationPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels);
ref <#=pixelType#> destBaseRef = ref MemoryMarshal.GetReference(destPixels);
ref <#=pixelType#> destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
@ -88,7 +88,7 @@
/// <param name="destBytes">The <see cref="Span{T}"/> to the destination bytes.</param>
/// <param name="count">The number of pixels to convert.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void To<#=pixelType#>Bytes(Configuration configuration, ReadOnlySpan<TPixel> sourcePixels, Span<byte> destBytes, int count)
public void To<#=pixelType#>Bytes(Configuration configuration, ReadOnlySpan<TPixel> sourcePixels, Span<byte> destBytes, int count)
{
this.To<#=pixelType#>(configuration, sourcePixels.Slice(0, count), MemoryMarshal.Cast<byte, <#=pixelType#>>(destBytes));
}

43
src/ImageSharp/PixelFormats/PixelOperations{TPixel}.cs

@ -32,17 +32,17 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </remarks>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations</param>
/// <param name="sourceVectors">The <see cref="Span{T}"/> to the source vectors.</param>
/// <param name="destPixels">The <see cref="Span{T}"/> to the destination colors.</param>
/// <param name="destinationPixels">The <see cref="Span{T}"/> to the destination colors.</param>
/// <param name="modifiers">The <see cref="PixelConversionModifiers"/> to apply during the conversion</param>
public virtual void FromVector4Destructive(
Configuration configuration,
Span<Vector4> sourceVectors,
Span<TPixel> destPixels,
Span<TPixel> destinationPixels,
PixelConversionModifiers modifiers)
{
Guard.NotNull(configuration, nameof(configuration));
Utils.Vector4Converters.Default.FromVector4(sourceVectors, destPixels, modifiers);
Utils.Vector4Converters.Default.FromVector4(sourceVectors, destinationPixels, modifiers);
}
/// <summary>
@ -55,29 +55,29 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </remarks>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations</param>
/// <param name="sourceVectors">The <see cref="Span{T}"/> to the source vectors.</param>
/// <param name="destPixels">The <see cref="Span{T}"/> to the destination colors.</param>
/// <param name="destinationPixels">The <see cref="Span{T}"/> to the destination colors.</param>
public void FromVector4Destructive(
Configuration configuration,
Span<Vector4> sourceVectors,
Span<TPixel> destPixels)
=> this.FromVector4Destructive(configuration, sourceVectors, destPixels, PixelConversionModifiers.None);
Span<TPixel> destinationPixels)
=> this.FromVector4Destructive(configuration, sourceVectors, destinationPixels, PixelConversionModifiers.None);
/// <summary>
/// Bulk version of <see cref="IPixel.ToVector4()"/> converting 'sourceColors.Length' pixels into 'destinationVectors'.
/// </summary>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations</param>
/// <param name="sourcePixels">The <see cref="Span{T}"/> to the source colors.</param>
/// <param name="destVectors">The <see cref="Span{T}"/> to the destination vectors.</param>
/// <param name="destinationVectors">The <see cref="Span{T}"/> to the destination vectors.</param>
/// <param name="modifiers">The <see cref="PixelConversionModifiers"/> to apply during the conversion</param>
public virtual void ToVector4(
Configuration configuration,
ReadOnlySpan<TPixel> sourcePixels,
Span<Vector4> destVectors,
Span<Vector4> destinationVectors,
PixelConversionModifiers modifiers)
{
Guard.NotNull(configuration, nameof(configuration));
Utils.Vector4Converters.Default.ToVector4(sourcePixels, destVectors, modifiers);
Utils.Vector4Converters.Default.ToVector4(sourcePixels, destinationVectors, modifiers);
}
/// <summary>
@ -85,14 +85,22 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations</param>
/// <param name="sourcePixels">The <see cref="Span{T}"/> to the source colors.</param>
/// <param name="destVectors">The <see cref="Span{T}"/> to the destination vectors.</param>
/// <param name="destinationVectors">The <see cref="Span{T}"/> to the destination vectors.</param>
public void ToVector4(
Configuration configuration,
ReadOnlySpan<TPixel> sourcePixels,
Span<Vector4> destVectors)
=> this.ToVector4(configuration, sourcePixels, destVectors, PixelConversionModifiers.None);
Span<Vector4> destinationVectors)
=> this.ToVector4(configuration, sourcePixels, destinationVectors, PixelConversionModifiers.None);
internal virtual void From<TSourcePixel>(
/// <summary>
/// Bulk operation that copies the <paramref name="sourcePixels"/> to <paramref name="destinationPixels"/> in
/// <typeparamref name="TSourcePixel"/> format.
/// </summary>
/// <typeparam name="TSourcePixel">The destination pixel type.</typeparam>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations.</param>
/// <param name="sourcePixels">The <see cref="ReadOnlySpan{TSourcePixel}"/> to the source pixels.</param>
/// <param name="destinationPixels">The <see cref="Span{TPixel}"/> to the destination pixels.</param>
public virtual void From<TSourcePixel>(
Configuration configuration,
ReadOnlySpan<TSourcePixel> sourcePixels,
Span<TPixel> destinationPixels)
@ -126,13 +134,14 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <summary>
/// Converts 'sourcePixels.Length' pixels from 'sourcePixels' into 'destinationPixels'.
/// Bulk operation that copies the <paramref name="sourcePixels"/> to <paramref name="destinationPixels"/> in
/// <typeparamref name="TDestinationPixel"/> format.
/// </summary>
/// <typeparam name="TDestinationPixel">The destination pixel type.</typeparam>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations.</param>
/// <param name="sourcePixels">The <see cref="Span{T}"/> to the source pixels.</param>
/// <param name="destinationPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
internal virtual void To<TDestinationPixel>(
/// <param name="sourcePixels">The <see cref="ReadOnlySpan{TPixel}"/> to the source pixels.</param>
/// <param name="destinationPixels">The <see cref="Span{TDestinationPixel}"/> to the destination pixels.</param>
public virtual void To<TDestinationPixel>(
Configuration configuration,
ReadOnlySpan<TPixel> sourcePixels,
Span<TDestinationPixel> destinationPixels)

10
src/ImageSharp/Primitives/ColorMatrix.cs

@ -204,7 +204,7 @@ namespace SixLabors.ImageSharp
/// <returns>The resulting matrix.</returns>
public static ColorMatrix operator +(ColorMatrix value1, ColorMatrix value2)
{
ColorMatrix m;
var m = default(ColorMatrix);
m.M11 = value1.M11 + value2.M11;
m.M12 = value1.M12 + value2.M12;
@ -238,7 +238,7 @@ namespace SixLabors.ImageSharp
/// <returns>The result of the subtraction.</returns>
public static ColorMatrix operator -(ColorMatrix value1, ColorMatrix value2)
{
ColorMatrix m;
var m = default(ColorMatrix);
m.M11 = value1.M11 - value2.M11;
m.M12 = value1.M12 - value2.M12;
@ -271,7 +271,7 @@ namespace SixLabors.ImageSharp
/// <returns>The negated matrix.</returns>
public static ColorMatrix operator -(ColorMatrix value)
{
ColorMatrix m;
var m = default(ColorMatrix);
m.M11 = -value.M11;
m.M12 = -value.M12;
@ -305,7 +305,7 @@ namespace SixLabors.ImageSharp
/// <returns>The result of the multiplication.</returns>
public static ColorMatrix operator *(ColorMatrix value1, ColorMatrix value2)
{
ColorMatrix m;
var m = default(ColorMatrix);
// First row
m.M11 = (value1.M11 * value2.M11) + (value1.M12 * value2.M21) + (value1.M13 * value2.M31) + (value1.M14 * value2.M41);
@ -348,7 +348,7 @@ namespace SixLabors.ImageSharp
/// <returns>The scaled matrix.</returns>
public static ColorMatrix operator *(ColorMatrix value1, float value2)
{
ColorMatrix m;
var m = default(ColorMatrix);
m.M11 = value1.M11 * value2;
m.M12 = value1.M12 * value2;

102
src/ImageSharp/Processing/Extensions/Effects/PixelRowDelegateExtensions.cs

@ -0,0 +1,102 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing.Processors.Effects;
namespace SixLabors.ImageSharp.Processing
{
/// <summary>
/// Defines extension methods that allow the application of user defined processing delegate to an <see cref="Image"/>.
/// </summary>
public static class PixelRowDelegateExtensions
{
/// <summary>
/// Applies a user defined processing delegate to the image.
/// </summary>
/// <param name="source">The image this method extends.</param>
/// <param name="rowOperation">The user defined processing delegate to use to modify image rows.</param>
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
public static IImageProcessingContext ProcessPixelRowsAsVector4(this IImageProcessingContext source, PixelRowOperation rowOperation)
=> ProcessPixelRowsAsVector4(source, rowOperation, PixelConversionModifiers.None);
/// <summary>
/// Applies a user defined processing delegate to the image.
/// </summary>
/// <param name="source">The image this method extends.</param>
/// <param name="rowOperation">The user defined processing delegate to use to modify image rows.</param>
/// <param name="modifiers">The <see cref="PixelConversionModifiers"/> to apply during the pixel conversions.</param>
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
public static IImageProcessingContext ProcessPixelRowsAsVector4(this IImageProcessingContext source, PixelRowOperation rowOperation, PixelConversionModifiers modifiers)
=> source.ApplyProcessor(new PixelRowDelegateProcessor(rowOperation, modifiers));
/// <summary>
/// Applies a user defined processing delegate to the image.
/// </summary>
/// <param name="source">The image this method extends.</param>
/// <param name="rowOperation">The user defined processing delegate to use to modify image rows.</param>
/// <param name="rectangle">
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param>
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
public static IImageProcessingContext ProcessPixelRowsAsVector4(this IImageProcessingContext source, PixelRowOperation rowOperation, Rectangle rectangle)
=> ProcessPixelRowsAsVector4(source, rowOperation, rectangle, PixelConversionModifiers.None);
/// <summary>
/// Applies a user defined processing delegate to the image.
/// </summary>
/// <param name="source">The image this method extends.</param>
/// <param name="rowOperation">The user defined processing delegate to use to modify image rows.</param>
/// <param name="rectangle">
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param>
/// <param name="modifiers">The <see cref="PixelConversionModifiers"/> to apply during the pixel conversions.</param>
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
public static IImageProcessingContext ProcessPixelRowsAsVector4(this IImageProcessingContext source, PixelRowOperation rowOperation, Rectangle rectangle, PixelConversionModifiers modifiers)
=> source.ApplyProcessor(new PixelRowDelegateProcessor(rowOperation, modifiers), rectangle);
/// <summary>
/// Applies a user defined processing delegate to the image.
/// </summary>
/// <param name="source">The image this method extends.</param>
/// <param name="rowOperation">The user defined processing delegate to use to modify image rows.</param>
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
public static IImageProcessingContext ProcessPixelRowsAsVector4(this IImageProcessingContext source, PixelRowOperation<Point> rowOperation)
=> ProcessPixelRowsAsVector4(source, rowOperation, PixelConversionModifiers.None);
/// <summary>
/// Applies a user defined processing delegate to the image.
/// </summary>
/// <param name="source">The image this method extends.</param>
/// <param name="rowOperation">The user defined processing delegate to use to modify image rows.</param>
/// <param name="modifiers">The <see cref="PixelConversionModifiers"/> to apply during the pixel conversions.</param>
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
public static IImageProcessingContext ProcessPixelRowsAsVector4(this IImageProcessingContext source, PixelRowOperation<Point> rowOperation, PixelConversionModifiers modifiers)
=> source.ApplyProcessor(new PositionAwarePixelRowDelegateProcessor(rowOperation, modifiers));
/// <summary>
/// Applies a user defined processing delegate to the image.
/// </summary>
/// <param name="source">The image this method extends.</param>
/// <param name="rowOperation">The user defined processing delegate to use to modify image rows.</param>
/// <param name="rectangle">
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param>
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
public static IImageProcessingContext ProcessPixelRowsAsVector4(this IImageProcessingContext source, PixelRowOperation<Point> rowOperation, Rectangle rectangle)
=> ProcessPixelRowsAsVector4(source, rowOperation, rectangle, PixelConversionModifiers.None);
/// <summary>
/// Applies a user defined processing delegate to the image.
/// </summary>
/// <param name="source">The image this method extends.</param>
/// <param name="rowOperation">The user defined processing delegate to use to modify image rows.</param>
/// <param name="rectangle">
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param>
/// <param name="modifiers">The <see cref="PixelConversionModifiers"/> to apply during the pixel conversions.</param>
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
public static IImageProcessingContext ProcessPixelRowsAsVector4(this IImageProcessingContext source, PixelRowOperation<Point> rowOperation, Rectangle rectangle, PixelConversionModifiers modifiers)
=> source.ApplyProcessor(new PositionAwarePixelRowDelegateProcessor(rowOperation, modifiers), rectangle);
}
}

102
src/ImageSharp/Processing/Extensions/Effects/PixelShaderExtensions.cs

@ -1,102 +0,0 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing.Processors.Effects;
namespace SixLabors.ImageSharp.Processing
{
/// <summary>
/// Defines extension methods that allow the application of user defined pixel shaders to an <see cref="Image"/>.
/// </summary>
public static class PixelShaderExtensions
{
/// <summary>
/// Applies a user defined pixel shader to the image.
/// </summary>
/// <param name="source">The image this method extends.</param>
/// <param name="pixelShader">The user defined pixel shader to use to modify images.</param>
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
public static IImageProcessingContext ApplyPixelShaderProcessor(this IImageProcessingContext source, PixelShader pixelShader)
=> source.ApplyProcessor(new PixelShaderProcessor(pixelShader));
/// <summary>
/// Applies a user defined pixel shader to the image.
/// </summary>
/// <param name="source">The image this method extends.</param>
/// <param name="pixelShader">The user defined pixel shader to use to modify images.</param>
/// <param name="modifiers">The <see cref="PixelConversionModifiers"/> to apply during the pixel conversions.</param>
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
public static IImageProcessingContext ApplyPixelShaderProcessor(this IImageProcessingContext source, PixelShader pixelShader, PixelConversionModifiers modifiers)
=> source.ApplyProcessor(new PixelShaderProcessor(pixelShader, modifiers));
/// <summary>
/// Applies a user defined pixel shader to the image.
/// </summary>
/// <param name="source">The image this method extends.</param>
/// <param name="pixelShader">The user defined pixel shader to use to modify images.</param>
/// <param name="rectangle">
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param>
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
public static IImageProcessingContext ApplyPixelShaderProcessor(this IImageProcessingContext source, PixelShader pixelShader, Rectangle rectangle)
=> source.ApplyProcessor(new PixelShaderProcessor(pixelShader), rectangle);
/// <summary>
/// Applies a user defined pixel shader to the image.
/// </summary>
/// <param name="source">The image this method extends.</param>
/// <param name="pixelShader">The user defined pixel shader to use to modify images.</param>
/// <param name="rectangle">
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param>
/// <param name="modifiers">The <see cref="PixelConversionModifiers"/> to apply during the pixel conversions.</param>
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
public static IImageProcessingContext ApplyPixelShaderProcessor(this IImageProcessingContext source, PixelShader pixelShader, Rectangle rectangle, PixelConversionModifiers modifiers)
=> source.ApplyProcessor(new PixelShaderProcessor(pixelShader, modifiers), rectangle);
/// <summary>
/// Applies a user defined pixel shader to the image.
/// </summary>
/// <param name="source">The image this method extends.</param>
/// <param name="pixelShader">The user defined pixel shader to use to modify images.</param>
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
public static IImageProcessingContext ApplyPixelShaderProcessor(this IImageProcessingContext source, PositionAwarePixelShader pixelShader)
=> source.ApplyProcessor(new PositionAwarePixelShaderProcessor(pixelShader));
/// <summary>
/// Applies a user defined pixel shader to the image.
/// </summary>
/// <param name="source">The image this method extends.</param>
/// <param name="pixelShader">The user defined pixel shader to use to modify images.</param>
/// <param name="modifiers">The <see cref="PixelConversionModifiers"/> to apply during the pixel conversions.</param>
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
public static IImageProcessingContext ApplyPixelShaderProcessor(this IImageProcessingContext source, PositionAwarePixelShader pixelShader, PixelConversionModifiers modifiers)
=> source.ApplyProcessor(new PositionAwarePixelShaderProcessor(pixelShader, modifiers));
/// <summary>
/// Applies a user defined pixel shader to the image.
/// </summary>
/// <param name="source">The image this method extends.</param>
/// <param name="pixelShader">The user defined pixel shader to use to modify images.</param>
/// <param name="rectangle">
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param>
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
public static IImageProcessingContext ApplyPixelShaderProcessor(this IImageProcessingContext source, PositionAwarePixelShader pixelShader, Rectangle rectangle)
=> source.ApplyProcessor(new PositionAwarePixelShaderProcessor(pixelShader), rectangle);
/// <summary>
/// Applies a user defined pixel shader to the image.
/// </summary>
/// <param name="source">The image this method extends.</param>
/// <param name="pixelShader">The user defined pixel shader to use to modify images.</param>
/// <param name="rectangle">
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param>
/// <param name="modifiers">The <see cref="PixelConversionModifiers"/> to apply during the pixel conversions.</param>
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
public static IImageProcessingContext ApplyPixelShaderProcessor(this IImageProcessingContext source, PositionAwarePixelShader pixelShader, Rectangle rectangle, PixelConversionModifiers modifiers)
=> source.ApplyProcessor(new PositionAwarePixelShaderProcessor(pixelShader, modifiers), rectangle);
}
}

27
src/ImageSharp/Processing/PixelRowOperation.cs

@ -0,0 +1,27 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using System;
using System.Numerics;
namespace SixLabors.ImageSharp.Processing
{
/// <summary>
/// A <see langword="delegate"/> representing a user defined processing delegate to use to modify image rows.
/// </summary>
/// <param name="span">The target row of <see cref="Vector4"/> pixels to process.</param>
/// <remarks>The <see cref="Vector4.X"/>, <see cref="Vector4.Y"/>, <see cref="Vector4.Z"/>, and <see cref="Vector4.W"/> fields map the RGBA channels respectively.</remarks>
public delegate void PixelRowOperation(Span<Vector4> span);
/// <summary>
/// A <see langword="delegate"/> representing a user defined processing delegate to use to modify image rows.
/// </summary>
/// <typeparam name="T">
/// The type of the parameter of the method that this delegate encapsulates.
/// This type parameter is contravariant.That is, you can use either the type you specified or any type that is less derived.
/// </typeparam>
/// <param name="span">The target row of <see cref="Vector4"/> pixels to process.</param>
/// <param name="value">The parameter of the method that this delegate encapsulates.</param>
/// <remarks>The <see cref="Vector4.X"/>, <see cref="Vector4.Y"/>, <see cref="Vector4.Z"/>, and <see cref="Vector4.W"/> fields map the RGBA channels respectively.</remarks>
public delegate void PixelRowOperation<in T>(Span<Vector4> span, T value);
}

15
src/ImageSharp/Processing/PixelShader.cs

@ -1,15 +0,0 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using System;
using System.Numerics;
namespace SixLabors.ImageSharp.Processing
{
/// <summary>
/// A <see langword="delegate"/> representing a user defined pixel shader.
/// </summary>
/// <param name="span">The target row of <see cref="Vector4"/> pixels to process.</param>
/// <remarks>The <see cref="Vector4.X"/>, <see cref="Vector4.Y"/>, <see cref="Vector4.Z"/>, and <see cref="Vector4.W"/> fields map the RGBA channels respectively.</remarks>
public delegate void PixelShader(Span<Vector4> span);
}

16
src/ImageSharp/Processing/PositionAwarePixelShader.cs

@ -1,16 +0,0 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using System;
using System.Numerics;
namespace SixLabors.ImageSharp.Processing
{
/// <summary>
/// A <see langword="delegate"/> representing a user defined pixel shader.
/// </summary>
/// <param name="span">The target row of <see cref="Vector4"/> pixels to process.</param>
/// <param name="offset">The initial horizontal and vertical offset for the input pixels to process.</param>
/// <remarks>The <see cref="Vector4.X"/>, <see cref="Vector4.Y"/>, <see cref="Vector4.Z"/>, and <see cref="Vector4.W"/> fields map the RGBA channels respectively.</remarks>
public delegate void PositionAwarePixelShader(Span<Vector4> span, Point offset);
}

39
src/ImageSharp/Processing/Processors/Effects/PixelRowDelegateProcessor.cs

@ -0,0 +1,39 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
namespace SixLabors.ImageSharp.Processing.Processors.Effects
{
/// <summary>
/// Applies a user defined row processing delegate to the image.
/// </summary>
internal sealed class PixelRowDelegateProcessor : IImageProcessor
{
/// <summary>
/// Initializes a new instance of the <see cref="PixelRowDelegateProcessor"/> class.
/// </summary>
/// <param name="pixelRowOperation">The user defined, row processing delegate.</param>
/// <param name="modifiers">The <see cref="PixelConversionModifiers"/> to apply during the pixel conversions.</param>
public PixelRowDelegateProcessor(PixelRowOperation pixelRowOperation, PixelConversionModifiers modifiers)
{
this.PixelRowOperation = pixelRowOperation;
this.Modifiers = modifiers;
}
/// <summary>
/// Gets the user defined row processing delegate to the image.
/// </summary>
public PixelRowOperation PixelRowOperation { get; }
/// <summary>
/// Gets the <see cref="PixelConversionModifiers"/> to apply during the pixel conversions.
/// </summary>
public PixelConversionModifiers Modifiers { get; }
/// <inheritdoc />
public IImageProcessor<TPixel> CreatePixelSpecificProcessor<TPixel>(Configuration configuration, Image<TPixel> source, Rectangle sourceRectangle)
where TPixel : struct, IPixel<TPixel>
=> new PixelRowDelegateProcessor<TPixel>(configuration, this, source, sourceRectangle);
}
}

21
src/ImageSharp/Processing/Processors/Effects/PixelShaderProcessorBase.cs → src/ImageSharp/Processing/Processors/Effects/PixelRowDelegateProcessorBase{TPixel}.cs

@ -3,7 +3,6 @@
using System;
using System.Numerics;
using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.Advanced.ParallelUtils;
using SixLabors.ImageSharp.PixelFormats;
@ -11,10 +10,10 @@ using SixLabors.ImageSharp.PixelFormats;
namespace SixLabors.ImageSharp.Processing.Processors.Effects
{
/// <summary>
/// Applies a user defined pixel shader effect through a given delegate.
/// The base class for all processors that accept a user defined row processing delegate.
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
internal abstract class PixelShaderProcessorBase<TPixel> : ImageProcessor<TPixel>
internal abstract class PixelRowDelegateProcessorBase<TPixel> : ImageProcessor<TPixel>
where TPixel : struct, IPixel<TPixel>
{
/// <summary>
@ -23,17 +22,15 @@ namespace SixLabors.ImageSharp.Processing.Processors.Effects
private readonly PixelConversionModifiers modifiers;
/// <summary>
/// Initializes a new instance of the <see cref="PixelShaderProcessorBase{TPixel}"/> class.
/// Initializes a new instance of the <see cref="PixelRowDelegateProcessorBase{TPixel}"/> class.
/// </summary>
/// <param name="configuration">The configuration which allows altering default behaviour or extending the library.</param>
/// <param name="modifiers">The <see cref="PixelConversionModifiers"/> to apply during the pixel conversions.</param>
/// <param name="source">The source <see cref="Image{TPixel}"/> for the current processor instance.</param>
/// <param name="sourceRectangle">The source area to process for the current processor instance.</param>
protected PixelShaderProcessorBase(Configuration configuration, PixelConversionModifiers modifiers, Image<TPixel> source, Rectangle sourceRectangle)
protected PixelRowDelegateProcessorBase(Configuration configuration, PixelConversionModifiers modifiers, Image<TPixel> source, Rectangle sourceRectangle)
: base(configuration, source, sourceRectangle)
{
this.modifiers = modifiers;
}
=> this.modifiers = modifiers;
/// <inheritdoc/>
protected override void OnFrameApply(ImageFrame<TPixel> source)
@ -55,8 +52,8 @@ namespace SixLabors.ImageSharp.Processing.Processors.Effects
Span<TPixel> rowSpan = source.GetPixelRowSpan(y).Slice(startX, length);
PixelOperations<TPixel>.Instance.ToVector4(configuration, rowSpan, vectorSpan, modifiers);
// Run the user defined pixel shader on the current row of pixels
this.ApplyPixelShader(vectorSpan, new Point(startX, y));
// Run the user defined pixel shader to the current row of pixels
this.ApplyPixelRowDelegate(vectorSpan, new Point(startX, y));
PixelOperations<TPixel>.Instance.FromVector4Destructive(configuration, vectorSpan, rowSpan, modifiers);
}
@ -64,10 +61,10 @@ namespace SixLabors.ImageSharp.Processing.Processors.Effects
}
/// <summary>
/// Applies the current pixel shader effect on a target row of preprocessed pixels.
/// Applies the current pixel row delegate to a target row of preprocessed pixels.
/// </summary>
/// <param name="span">The target row of <see cref="Vector4"/> pixels to process.</param>
/// <param name="offset">The initial horizontal and vertical offset for the input pixels to process.</param>
protected abstract void ApplyPixelShader(Span<Vector4> span, Point offset);
protected abstract void ApplyPixelRowDelegate(Span<Vector4> span, Point offset);
}
}

18
src/ImageSharp/Processing/Processors/Effects/PixelShaderProcessor{TPixel}.cs → src/ImageSharp/Processing/Processors/Effects/PixelRowDelegateProcessor{TPixel}.cs

@ -9,31 +9,31 @@ using SixLabors.ImageSharp.PixelFormats;
namespace SixLabors.ImageSharp.Processing.Processors.Effects
{
/// <summary>
/// Applies a user defined pixel shader effect through a given delegate.
/// Applies a user defined row processing delegate to the image.
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
internal sealed class PixelShaderProcessor<TPixel> : PixelShaderProcessorBase<TPixel>
internal sealed class PixelRowDelegateProcessor<TPixel> : PixelRowDelegateProcessorBase<TPixel>
where TPixel : struct, IPixel<TPixel>
{
/// <summary>
/// The user defined pixel shader.
/// The user defined pixel row processing delegate.
/// </summary>
private readonly PixelShader pixelShader;
private readonly PixelRowOperation pixelRowOperation;
/// <summary>
/// Initializes a new instance of the <see cref="PixelShaderProcessor{TPixel}"/> class.
/// Initializes a new instance of the <see cref="PixelRowDelegateProcessor{TPixel}"/> class.
/// </summary>
/// <param name="configuration">The configuration which allows altering default behaviour or extending the library.</param>
/// <param name="definition">The <see cref="PixelShaderProcessor"/> defining the processor parameters.</param>
/// <param name="definition">The <see cref="PixelRowDelegateProcessor"/> defining the processor parameters.</param>
/// <param name="source">The source <see cref="Image{TPixel}"/> for the current processor instance.</param>
/// <param name="sourceRectangle">The source area to process for the current processor instance.</param>
public PixelShaderProcessor(Configuration configuration, PixelShaderProcessor definition, Image<TPixel> source, Rectangle sourceRectangle)
public PixelRowDelegateProcessor(Configuration configuration, PixelRowDelegateProcessor definition, Image<TPixel> source, Rectangle sourceRectangle)
: base(configuration, definition.Modifiers, source, sourceRectangle)
{
this.pixelShader = definition.PixelShader;
this.pixelRowOperation = definition.PixelRowOperation;
}
/// <inheritdoc/>
protected override void ApplyPixelShader(Span<Vector4> span, Point offset) => this.pixelShader(span);
protected override void ApplyPixelRowDelegate(Span<Vector4> span, Point offset) => this.pixelRowOperation(span);
}
}

58
src/ImageSharp/Processing/Processors/Effects/PixelShaderProcessor.cs

@ -1,58 +0,0 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
namespace SixLabors.ImageSharp.Processing.Processors.Effects
{
/// <summary>
/// Applies a user defined pixel shader effect through a given delegate.
/// </summary>
public sealed class PixelShaderProcessor : IImageProcessor
{
/// <summary>
/// The default <see cref="PixelConversionModifiers"/> to apply during the pixel conversions.
/// </summary>
public const PixelConversionModifiers DefaultModifiers = PixelConversionModifiers.None;
/// <summary>
/// Initializes a new instance of the <see cref="PixelShaderProcessor"/> class.
/// </summary>
/// <param name="pixelShader">
/// The user defined pixel shader to use to modify images.
/// </param>
public PixelShaderProcessor(PixelShader pixelShader)
{
this.PixelShader = pixelShader;
this.Modifiers = DefaultModifiers;
}
/// <summary>
/// Initializes a new instance of the <see cref="PixelShaderProcessor"/> class.
/// </summary>
/// <param name="pixelShader">
/// The user defined pixel shader to use to modify images.
/// </param>
/// <param name="modifiers">The <see cref="PixelConversionModifiers"/> to apply during the pixel conversions.</param>
public PixelShaderProcessor(PixelShader pixelShader, PixelConversionModifiers modifiers)
{
this.PixelShader = pixelShader;
this.Modifiers = modifiers;
}
/// <summary>
/// Gets the user defined pixel shader.
/// </summary>
public PixelShader PixelShader { get; }
/// <summary>
/// Gets the <see cref="PixelConversionModifiers"/> to apply during the pixel conversions.
/// </summary>
public PixelConversionModifiers Modifiers { get; }
/// <inheritdoc />
public IImageProcessor<TPixel> CreatePixelSpecificProcessor<TPixel>(Configuration configuration, Image<TPixel> source, Rectangle sourceRectangle)
where TPixel : struct, IPixel<TPixel>
=> new PixelShaderProcessor<TPixel>(configuration, this, source, sourceRectangle);
}
}

39
src/ImageSharp/Processing/Processors/Effects/PositionAwarePixelRowDelegateProcessor.cs

@ -0,0 +1,39 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
namespace SixLabors.ImageSharp.Processing.Processors.Effects
{
/// <summary>
/// Applies a user defined, position aware, row processing delegate to the image.
/// </summary>
internal sealed class PositionAwarePixelRowDelegateProcessor : IImageProcessor
{
/// <summary>
/// Initializes a new instance of the <see cref="PositionAwarePixelRowDelegateProcessor"/> class.
/// </summary>
/// <param name="pixelRowOperation">The user defined, position aware, row processing delegate.</param>
/// <param name="modifiers">The <see cref="PixelConversionModifiers"/> to apply during the pixel conversions.</param>
public PositionAwarePixelRowDelegateProcessor(PixelRowOperation<Point> pixelRowOperation, PixelConversionModifiers modifiers)
{
this.PixelRowOperation = pixelRowOperation;
this.Modifiers = modifiers;
}
/// <summary>
/// Gets the user defined, position aware, row processing delegate.
/// </summary>
public PixelRowOperation<Point> PixelRowOperation { get; }
/// <summary>
/// Gets the <see cref="PixelConversionModifiers"/> to apply during the pixel conversions.
/// </summary>
public PixelConversionModifiers Modifiers { get; }
/// <inheritdoc />
public IImageProcessor<TPixel> CreatePixelSpecificProcessor<TPixel>(Configuration configuration, Image<TPixel> source, Rectangle sourceRectangle)
where TPixel : struct, IPixel<TPixel>
=> new PositionAwarePixelRowDelegateProcessor<TPixel>(configuration, this, source, sourceRectangle);
}
}

19
src/ImageSharp/Processing/Processors/Effects/PositionAwarePixelShaderProcessor{TPixel}.cs → src/ImageSharp/Processing/Processors/Effects/PositionAwarePixelRowDelegateProcessor{TPixel}.cs

@ -9,31 +9,28 @@ using SixLabors.ImageSharp.PixelFormats;
namespace SixLabors.ImageSharp.Processing.Processors.Effects
{
/// <summary>
/// Applies a user defined pixel shader effect through a given delegate.
/// Applies a user defined, position aware, row processing delegate to the image.
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
internal sealed class PositionAwarePixelShaderProcessor<TPixel> : PixelShaderProcessorBase<TPixel>
internal sealed class PositionAwarePixelRowDelegateProcessor<TPixel> : PixelRowDelegateProcessorBase<TPixel>
where TPixel : struct, IPixel<TPixel>
{
/// <summary>
/// The user defined pixel shader.
/// </summary>
private readonly PositionAwarePixelShader pixelShader;
private readonly PixelRowOperation<Point> pixelRowOperation;
/// <summary>
/// Initializes a new instance of the <see cref="PositionAwarePixelShaderProcessor{TPixel}"/> class.
/// Initializes a new instance of the <see cref="PositionAwarePixelRowDelegateProcessor{TPixel}"/> class.
/// </summary>
/// <param name="configuration">The configuration which allows altering default behaviour or extending the library.</param>
/// <param name="definition">The <see cref="PositionAwarePixelShaderProcessor"/> defining the processor parameters.</param>
/// <param name="definition">The <see cref="PositionAwarePixelRowDelegateProcessor"/> defining the processor parameters.</param>
/// <param name="source">The source <see cref="Image{TPixel}"/> for the current processor instance.</param>
/// <param name="sourceRectangle">The source area to process for the current processor instance.</param>
public PositionAwarePixelShaderProcessor(Configuration configuration, PositionAwarePixelShaderProcessor definition, Image<TPixel> source, Rectangle sourceRectangle)
public PositionAwarePixelRowDelegateProcessor(Configuration configuration, PositionAwarePixelRowDelegateProcessor definition, Image<TPixel> source, Rectangle sourceRectangle)
: base(configuration, definition.Modifiers, source, sourceRectangle)
{
this.pixelShader = definition.PixelShader;
this.pixelRowOperation = definition.PixelRowOperation;
}
/// <inheritdoc/>
protected override void ApplyPixelShader(Span<Vector4> span, Point offset) => this.pixelShader(span, offset);
protected override void ApplyPixelRowDelegate(Span<Vector4> span, Point offset) => this.pixelRowOperation(span, offset);
}
}

58
src/ImageSharp/Processing/Processors/Effects/PositionAwarePixelShaderProcessor.cs

@ -1,58 +0,0 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
namespace SixLabors.ImageSharp.Processing.Processors.Effects
{
/// <summary>
/// Applies a user defined pixel shader effect through a given delegate.
/// </summary>
public sealed class PositionAwarePixelShaderProcessor : IImageProcessor
{
/// <summary>
/// The default <see cref="PixelConversionModifiers"/> to apply during the pixel conversions.
/// </summary>
public const PixelConversionModifiers DefaultModifiers = PixelConversionModifiers.None;
/// <summary>
/// Initializes a new instance of the <see cref="PositionAwarePixelShaderProcessor"/> class.
/// </summary>
/// <param name="pixelShader">
/// The user defined pixel shader to use to modify images.
/// </param>
public PositionAwarePixelShaderProcessor(PositionAwarePixelShader pixelShader)
{
this.PixelShader = pixelShader;
this.Modifiers = DefaultModifiers;
}
/// <summary>
/// Initializes a new instance of the <see cref="PositionAwarePixelShaderProcessor"/> class.
/// </summary>
/// <param name="pixelShader">
/// The user defined pixel shader to use to modify images.
/// </param>
/// <param name="modifiers">The <see cref="PixelConversionModifiers"/> to apply during the pixel conversions.</param>
public PositionAwarePixelShaderProcessor(PositionAwarePixelShader pixelShader, PixelConversionModifiers modifiers)
{
this.PixelShader = pixelShader;
this.Modifiers = modifiers;
}
/// <summary>
/// Gets the user defined pixel shader.
/// </summary>
public PositionAwarePixelShader PixelShader { get; }
/// <summary>
/// Gets the <see cref="PixelConversionModifiers"/> to apply during the pixel conversions.
/// </summary>
public PixelConversionModifiers Modifiers { get; }
/// <inheritdoc />
public IImageProcessor<TPixel> CreatePixelSpecificProcessor<TPixel>(Configuration configuration, Image<TPixel> source, Rectangle sourceRectangle)
where TPixel : struct, IPixel<TPixel>
=> new PositionAwarePixelShaderProcessor<TPixel>(configuration, this, source, sourceRectangle);
}
}

10
src/ImageSharp/Processing/Processors/Overlays/BackgroundColorProcessor{TPixel}.cs

@ -64,9 +64,11 @@ namespace SixLabors.ImageSharp.Processing.Processors.Overlays
int width = maxX - minX;
var workingRect = Rectangle.FromLTRB(minX, minY, maxX, maxY);
Configuration configuration = this.Configuration;
MemoryAllocator memoryAllocator = configuration.MemoryAllocator;
using (IMemoryOwner<TPixel> colors = source.MemoryAllocator.Allocate<TPixel>(width))
using (IMemoryOwner<float> amount = source.MemoryAllocator.Allocate<float>(width))
using (IMemoryOwner<TPixel> colors = memoryAllocator.Allocate<TPixel>(width))
using (IMemoryOwner<float> amount = memoryAllocator.Allocate<float>(width))
{
// Be careful! Do not capture colorSpan & amountSpan in the lambda below!
Span<TPixel> colorSpan = colors.GetSpan();
@ -79,7 +81,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Overlays
ParallelHelper.IterateRows(
workingRect,
this.Configuration,
configuration,
rows =>
{
for (int y = rows.Min; y < rows.Max; y++)
@ -89,7 +91,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Overlays
// This switched color & destination in the 2nd and 3rd places because we are applying the target color under the current one
blender.Blend(
source.Configuration,
configuration,
destination,
colors.GetSpan(),
destination,

8
src/ImageSharp/Processing/Processors/Overlays/GlowProcessor{TPixel}.cs

@ -76,14 +76,16 @@ namespace SixLabors.ImageSharp.Processing.Processors.Overlays
var workingRect = Rectangle.FromLTRB(minX, minY, maxX, maxY);
float blendPercentage = this.definition.GraphicsOptions.BlendPercentage;
Configuration configuration = this.Configuration;
MemoryAllocator memoryAllocator = configuration.MemoryAllocator;
using (IMemoryOwner<TPixel> rowColors = source.MemoryAllocator.Allocate<TPixel>(width))
using (IMemoryOwner<TPixel> rowColors = memoryAllocator.Allocate<TPixel>(width))
{
rowColors.GetSpan().Fill(glowColor);
ParallelHelper.IterateRowsWithTempBuffer<float>(
workingRect,
this.Configuration,
configuration,
(rows, amounts) =>
{
Span<float> amountsSpan = amounts.Span;
@ -102,7 +104,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Overlays
Span<TPixel> destination = source.GetPixelRowSpan(offsetY).Slice(offsetX, width);
this.blender.Blend(
source.Configuration,
configuration,
destination,
destination,
rowColors.GetSpan(),

8
src/ImageSharp/Processing/Processors/Overlays/VignetteProcessor{TPixel}.cs

@ -80,14 +80,16 @@ namespace SixLabors.ImageSharp.Processing.Processors.Overlays
var workingRect = Rectangle.FromLTRB(minX, minY, maxX, maxY);
float blendPercentage = this.definition.GraphicsOptions.BlendPercentage;
Configuration configuration = this.Configuration;
MemoryAllocator memoryAllocator = configuration.MemoryAllocator;
using (IMemoryOwner<TPixel> rowColors = source.MemoryAllocator.Allocate<TPixel>(width))
using (IMemoryOwner<TPixel> rowColors = memoryAllocator.Allocate<TPixel>(width))
{
rowColors.GetSpan().Fill(vignetteColor);
ParallelHelper.IterateRowsWithTempBuffer<float>(
workingRect,
this.Configuration,
configuration,
(rows, amounts) =>
{
Span<float> amountsSpan = amounts.Span;
@ -105,7 +107,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Overlays
Span<TPixel> destination = source.GetPixelRowSpan(offsetY).Slice(offsetX, width);
this.blender.Blend(
source.Configuration,
configuration,
destination,
destination,
rowColors.GetSpan(),

22
src/ImageSharp/Processing/Processors/Quantization/FrameQuantizer{TPixel}.cs

@ -7,6 +7,7 @@ using System.Collections.Generic;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using SixLabors.ImageSharp.Memory;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing.Processors.Dithering;
@ -39,6 +40,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization
/// <summary>
/// Initializes a new instance of the <see cref="FrameQuantizer{TPixel}"/> class.
/// </summary>
/// <param name="configuration">The configuration which allows altering default behaviour or extending the library.</param>
/// <param name="quantizer">The quantizer</param>
/// <param name="singlePass">
/// If true, the quantization process only needs to loop through the source pixels once
@ -48,10 +50,11 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization
/// only call the <see cref="SecondPass(ImageFrame{TPixel}, Span{byte}, ReadOnlySpan{TPixel}, int, int)"/> method.
/// If two passes are required, the code will also call <see cref="FirstPass(ImageFrame{TPixel}, int, int)"/>.
/// </remarks>
protected FrameQuantizer(IQuantizer quantizer, bool singlePass)
protected FrameQuantizer(Configuration configuration, IQuantizer quantizer, bool singlePass)
{
Guard.NotNull(quantizer, nameof(quantizer));
this.Configuration = configuration;
this.Diffuser = quantizer.Diffuser;
this.Dither = this.Diffuser != null;
this.singlePass = singlePass;
@ -60,6 +63,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization
/// <summary>
/// Initializes a new instance of the <see cref="FrameQuantizer{TPixel}"/> class.
/// </summary>
/// <param name="configuration">The configuration which allows altering default behaviour or extending the library.</param>
/// <param name="diffuser">The diffuser</param>
/// <param name="singlePass">
/// If true, the quantization process only needs to loop through the source pixels once
@ -69,8 +73,9 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization
/// only call the <see cref="SecondPass(ImageFrame{TPixel}, Span{byte}, ReadOnlySpan{TPixel}, int, int)"/> method.
/// If two passes are required, the code will also call <see cref="FirstPass(ImageFrame{TPixel}, int, int)"/>.
/// </remarks>
protected FrameQuantizer(IErrorDiffuser diffuser, bool singlePass)
protected FrameQuantizer(Configuration configuration, IErrorDiffuser diffuser, bool singlePass)
{
this.Configuration = configuration;
this.Diffuser = diffuser;
this.Dither = this.Diffuser != null;
this.singlePass = singlePass;
@ -82,6 +87,11 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization
/// <inheritdoc />
public bool Dither { get; }
/// <summary>
/// Gets the configuration which allows altering default behaviour or extending the library.
/// </summary>
protected Configuration Configuration { get; }
/// <inheritdoc/>
public void Dispose()
{
@ -108,14 +118,16 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization
// Collect the palette. Required before the second pass runs.
ReadOnlyMemory<TPixel> palette = this.GetPalette();
this.paletteVector = image.Configuration.MemoryAllocator.Allocate<Vector4>(palette.Length);
MemoryAllocator memoryAllocator = this.Configuration.MemoryAllocator;
this.paletteVector = memoryAllocator.Allocate<Vector4>(palette.Length);
PixelOperations<TPixel>.Instance.ToVector4(
image.Configuration,
this.Configuration,
palette.Span,
this.paletteVector.Memory.Span,
PixelConversionModifiers.Scale);
var quantizedFrame = new QuantizedFrame<TPixel>(image.MemoryAllocator, width, height, palette);
var quantizedFrame = new QuantizedFrame<TPixel>(memoryAllocator, width, height, palette);
Span<byte> pixelSpan = quantizedFrame.GetWritablePixelSpan();
if (this.Dither)

10
src/ImageSharp/Processing/Processors/Quantization/OctreeFrameQuantizer{TPixel}.cs

@ -37,27 +37,29 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization
/// <summary>
/// Initializes a new instance of the <see cref="OctreeFrameQuantizer{TPixel}"/> class.
/// </summary>
/// <param name="configuration">The configuration which allows altering default behaviour or extending the library.</param>
/// <param name="quantizer">The octree quantizer</param>
/// <remarks>
/// The Octree quantizer is a two pass algorithm. The initial pass sets up the Octree,
/// the second pass quantizes a color based on the nodes in the tree
/// </remarks>
public OctreeFrameQuantizer(OctreeQuantizer quantizer)
: this(quantizer, quantizer.MaxColors)
public OctreeFrameQuantizer(Configuration configuration, OctreeQuantizer quantizer)
: this(configuration, quantizer, quantizer.MaxColors)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="OctreeFrameQuantizer{TPixel}"/> class.
/// </summary>
/// <param name="configuration">The configuration which allows altering default behaviour or extending the library.</param>
/// <param name="quantizer">The octree quantizer.</param>
/// <param name="maxColors">The maximum number of colors to hold in the color palette.</param>
/// <remarks>
/// The Octree quantizer is a two pass algorithm. The initial pass sets up the Octree,
/// the second pass quantizes a color based on the nodes in the tree
/// </remarks>
public OctreeFrameQuantizer(OctreeQuantizer quantizer, int maxColors)
: base(quantizer, false)
public OctreeFrameQuantizer(Configuration configuration, OctreeQuantizer quantizer, int maxColors)
: base(configuration, quantizer, false)
{
this.colors = maxColors;
this.octree = new Octree(ImageMaths.GetBitsNeededForColorDepth(this.colors).Clamp(1, 8));

8
src/ImageSharp/Processing/Processors/Quantization/OctreeQuantizer.cs

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
@ -83,16 +83,16 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization
/// <inheritdoc />
public IFrameQuantizer<TPixel> CreateFrameQuantizer<TPixel>(Configuration configuration)
where TPixel : struct, IPixel<TPixel>
=> new OctreeFrameQuantizer<TPixel>(this);
=> new OctreeFrameQuantizer<TPixel>(configuration, this);
/// <inheritdoc/>
public IFrameQuantizer<TPixel> CreateFrameQuantizer<TPixel>(Configuration configuration, int maxColors)
where TPixel : struct, IPixel<TPixel>
{
maxColors = maxColors.Clamp(QuantizerConstants.MinColors, QuantizerConstants.MaxColors);
return new OctreeFrameQuantizer<TPixel>(this, maxColors);
return new OctreeFrameQuantizer<TPixel>(configuration, this, maxColors);
}
private static IErrorDiffuser GetDiffuser(bool dither) => dither ? KnownDiffusers.FloydSteinberg : null;
}
}
}

5
src/ImageSharp/Processing/Processors/Quantization/PaletteFrameQuantizer{TPixel}.cs

@ -26,10 +26,11 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization
/// <summary>
/// Initializes a new instance of the <see cref="PaletteFrameQuantizer{TPixel}"/> class.
/// </summary>
/// <param name="configuration">The configuration which allows altering default behaviour or extending the library.</param>
/// <param name="diffuser">The palette quantizer.</param>
/// <param name="colors">An array of all colors in the palette.</param>
public PaletteFrameQuantizer(IErrorDiffuser diffuser, ReadOnlyMemory<TPixel> colors)
: base(diffuser, true) => this.palette = colors;
public PaletteFrameQuantizer(Configuration configuration, IErrorDiffuser diffuser, ReadOnlyMemory<TPixel> colors)
: base(configuration, diffuser, true) => this.palette = colors;
/// <inheritdoc/>
protected override void SecondPass(

4
src/ImageSharp/Processing/Processors/Quantization/PaletteQuantizer.cs

@ -61,7 +61,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization
{
var palette = new TPixel[this.Palette.Length];
Color.ToPixel(configuration, this.Palette.Span, palette.AsSpan());
return new PaletteFrameQuantizer<TPixel>(this.Diffuser, palette);
return new PaletteFrameQuantizer<TPixel>(configuration, this.Diffuser, palette);
}
/// <inheritdoc/>
@ -73,7 +73,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization
var palette = new TPixel[max];
Color.ToPixel(configuration, this.Palette.Span.Slice(0, max), palette.AsSpan());
return new PaletteFrameQuantizer<TPixel>(this.Diffuser, palette);
return new PaletteFrameQuantizer<TPixel>(configuration, this.Diffuser, palette);
}
private static IErrorDiffuser GetDiffuser(bool dither) => dither ? KnownDiffusers.FloydSteinberg : null;

42
src/ImageSharp/Processing/Processors/Quantization/WuFrameQuantizer{TPixel}.cs

@ -37,6 +37,8 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization
internal sealed class WuFrameQuantizer<TPixel> : FrameQuantizer<TPixel>
where TPixel : struct, IPixel<TPixel>
{
private readonly MemoryAllocator memoryAllocator;
// The following two variables determine the amount of bits to preserve when calculating the histogram.
// Reducing the value of these numbers the granularity of the color maps produced, making it much faster
// and using much less memory but potentially less accurate. Current results are very good though!
@ -121,39 +123,39 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization
/// <summary>
/// Initializes a new instance of the <see cref="WuFrameQuantizer{TPixel}"/> class.
/// </summary>
/// <param name="memoryAllocator">The <see cref="MemoryAllocator"/>.</param>
/// <param name="quantizer">The wu quantizer</param>
/// <param name="configuration">The configuration which allows altering default behaviour or extending the library.</param>
/// <param name="quantizer">The Wu quantizer</param>
/// <remarks>
/// The Wu quantizer is a two pass algorithm. The initial pass sets up the 3-D color histogram,
/// the second pass quantizes a color based on the position in the histogram.
/// </remarks>
public WuFrameQuantizer(MemoryAllocator memoryAllocator, WuQuantizer quantizer)
: this(memoryAllocator, quantizer, quantizer.MaxColors)
public WuFrameQuantizer(Configuration configuration, WuQuantizer quantizer)
: this(configuration, quantizer, quantizer.MaxColors)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="WuFrameQuantizer{TPixel}"/> class.
/// </summary>
/// <param name="memoryAllocator">The <see cref="MemoryAllocator"/>.</param>
/// <param name="quantizer">The wu quantizer.</param>
/// <param name="configuration">The configuration which allows altering default behaviour or extending the library.</param>
/// <param name="quantizer">The Wu quantizer.</param>
/// <param name="maxColors">The maximum number of colors to hold in the color palette.</param>
/// <remarks>
/// The Wu quantizer is a two pass algorithm. The initial pass sets up the 3-D color histogram,
/// the second pass quantizes a color based on the position in the histogram.
/// </remarks>
public WuFrameQuantizer(MemoryAllocator memoryAllocator, WuQuantizer quantizer, int maxColors)
: base(quantizer, false)
public WuFrameQuantizer(Configuration configuration, WuQuantizer quantizer, int maxColors)
: base(configuration, quantizer, false)
{
Guard.NotNull(memoryAllocator, nameof(memoryAllocator));
this.memoryAllocator = this.Configuration.MemoryAllocator;
this.vwt = memoryAllocator.Allocate<long>(TableLength, AllocationOptions.Clean);
this.vmr = memoryAllocator.Allocate<long>(TableLength, AllocationOptions.Clean);
this.vmg = memoryAllocator.Allocate<long>(TableLength, AllocationOptions.Clean);
this.vmb = memoryAllocator.Allocate<long>(TableLength, AllocationOptions.Clean);
this.vma = memoryAllocator.Allocate<long>(TableLength, AllocationOptions.Clean);
this.m2 = memoryAllocator.Allocate<double>(TableLength, AllocationOptions.Clean);
this.tag = memoryAllocator.Allocate<byte>(TableLength, AllocationOptions.Clean);
this.vwt = this.memoryAllocator.Allocate<long>(TableLength, AllocationOptions.Clean);
this.vmr = this.memoryAllocator.Allocate<long>(TableLength, AllocationOptions.Clean);
this.vmg = this.memoryAllocator.Allocate<long>(TableLength, AllocationOptions.Clean);
this.vmb = this.memoryAllocator.Allocate<long>(TableLength, AllocationOptions.Clean);
this.vma = this.memoryAllocator.Allocate<long>(TableLength, AllocationOptions.Clean);
this.m2 = this.memoryAllocator.Allocate<double>(TableLength, AllocationOptions.Clean);
this.tag = this.memoryAllocator.Allocate<byte>(TableLength, AllocationOptions.Clean);
this.colors = maxColors;
}
@ -229,7 +231,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization
protected override void FirstPass(ImageFrame<TPixel> source, int width, int height)
{
this.Build3DHistogram(source, width, height);
this.Get3DMoments(source.MemoryAllocator);
this.Get3DMoments(this.memoryAllocator);
this.BuildCube();
}
@ -465,13 +467,13 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization
// Build up the 3-D color histogram
// Loop through each row
using (IMemoryOwner<Rgba32> rgbaBuffer = source.MemoryAllocator.Allocate<Rgba32>(source.Width))
using (IMemoryOwner<Rgba32> rgbaBuffer = this.memoryAllocator.Allocate<Rgba32>(source.Width))
{
for (int y = 0; y < height; y++)
{
Span<TPixel> row = source.GetPixelRowSpan(y);
Span<Rgba32> rgbaSpan = rgbaBuffer.GetSpan();
PixelOperations<TPixel>.Instance.ToRgba32(source.Configuration, row, rgbaSpan);
PixelOperations<TPixel>.Instance.ToRgba32(source.GetConfiguration(), row, rgbaSpan);
ref Rgba32 scanBaseRef = ref MemoryMarshal.GetReference(rgbaSpan);
// And loop through each column
@ -840,7 +842,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization
private void BuildCube()
{
this.colorCube = new Box[this.colors];
var vv = new double[this.colors];
Span<double> vv = stackalloc double[this.colors];
ref Box cube = ref this.colorCube[0];
cube.RMin = cube.GMin = cube.BMin = cube.AMin = 0;

9
src/ImageSharp/Processing/Processors/Quantization/WuQuantizer.cs

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
@ -68,13 +68,12 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization
/// </summary>
public int MaxColors { get; }
/// <param name="configuration"></param>
/// <inheritdoc />
public IFrameQuantizer<TPixel> CreateFrameQuantizer<TPixel>(Configuration configuration)
where TPixel : struct, IPixel<TPixel>
{
Guard.NotNull(configuration, nameof(configuration));
return new WuFrameQuantizer<TPixel>(configuration.MemoryAllocator, this);
return new WuFrameQuantizer<TPixel>(configuration, this);
}
/// <inheritdoc/>
@ -83,9 +82,9 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization
{
Guard.NotNull(configuration, nameof(configuration));
maxColors = maxColors.Clamp(QuantizerConstants.MinColors, QuantizerConstants.MaxColors);
return new WuFrameQuantizer<TPixel>(configuration.MemoryAllocator, this, maxColors);
return new WuFrameQuantizer<TPixel>(configuration, this, maxColors);
}
private static IErrorDiffuser GetDiffuser(bool dither) => dither ? KnownDiffusers.FloydSteinberg : null;
}
}
}

23
tests/ImageSharp.Benchmarks/Codecs/DecodeTga.cs

@ -18,7 +18,9 @@ namespace SixLabors.ImageSharp.Benchmarks.Codecs
public class DecodeTga : BenchmarkBase
{
private string TestImageFullPath => Path.Combine(TestEnvironment.InputImagesDirectoryFullPath, this.TestImage);
private readonly PfimConfig pfimConfig = new PfimConfig(allocator: new PfimAllocator());
private byte[] data;
[Params(TestImages.Tga.Bit24)]
@ -77,15 +79,16 @@ namespace SixLabors.ImageSharp.Benchmarks.Codecs
public int Rented => this.rented;
}
// RESULTS (07/01/2020)
//| Method | Runtime | TestImage | Mean | Error | StdDev | Ratio | Gen 0 | Gen 1 | Gen 2 | Allocated |
//|------------------ |-------------- |-------------------- |-------------:|-------------:|-----------:|------:|-------:|------:|------:|----------:|
//| 'ImageMagick Tga' | .NET 4.7.2 | Tga/targa_24bit.tga | 1,778.965 us | 1,711.088 us | 93.7905 us | 1.000 | 1.9531 | - | - | 13668 B |
//| 'ImageSharp Tga' | .NET 4.7.2 | Tga/targa_24bit.tga | 38.659 us | 6.886 us | 0.3774 us | 0.022 | 0.3052 | - | - | 1316 B |
//| 'Pfim Tga' | .NET 4.7.2 | Tga/targa_24bit.tga | 6.752 us | 10.268 us | 0.5628 us | 0.004 | 0.0687 | - | - | 313 B |
//| | | | | | | | | | | |
//| 'ImageMagick Tga' | .NET Core 2.1 | Tga/targa_24bit.tga | 1,407.585 us | 124.215 us | 6.8087 us | 1.000 | 1.9531 | - | - | 13307 B |
//| 'ImageSharp Tga' | .NET Core 2.1 | Tga/targa_24bit.tga | 17.958 us | 9.352 us | 0.5126 us | 0.013 | 0.2747 | - | - | 1256 B |
//| 'Pfim Tga' | .NET Core 2.1 | Tga/targa_24bit.tga | 5.645 us | 2.279 us | 0.1249 us | 0.004 | 0.0610 | - | - | 280 B |
/* RESULTS (07/01/2020)
| Method | Runtime | TestImage | Mean | Error | StdDev | Ratio | Gen 0 | Gen 1 | Gen 2 | Allocated |
|------------------ |-------------- |-------------------- |-------------:|-------------:|-----------:|------:|-------:|------:|------:|----------:|
| 'ImageMagick Tga' | .NET 4.7.2 | Tga/targa_24bit.tga | 1,778.965 us | 1,711.088 us | 93.7905 us | 1.000 | 1.9531 | - | - | 13668 B |
| 'ImageSharp Tga' | .NET 4.7.2 | Tga/targa_24bit.tga | 38.659 us | 6.886 us | 0.3774 us | 0.022 | 0.3052 | - | - | 1316 B |
| 'Pfim Tga' | .NET 4.7.2 | Tga/targa_24bit.tga | 6.752 us | 10.268 us | 0.5628 us | 0.004 | 0.0687 | - | - | 313 B |
| | | | | | | | | | | |
| 'ImageMagick Tga' | .NET Core 2.1 | Tga/targa_24bit.tga | 1,407.585 us | 124.215 us | 6.8087 us | 1.000 | 1.9531 | - | - | 13307 B |
| 'ImageSharp Tga' | .NET Core 2.1 | Tga/targa_24bit.tga | 17.958 us | 9.352 us | 0.5126 us | 0.013 | 0.2747 | - | - | 1256 B |
| 'Pfim Tga' | .NET Core 2.1 | Tga/targa_24bit.tga | 5.645 us | 2.279 us | 0.1249 us | 0.004 | 0.0610 | - | - | 280 B |
*/
}
}

16
tests/ImageSharp.Benchmarks/Codecs/EncodeBmpMultiple.cs

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using System.Collections.Generic;
@ -16,13 +16,21 @@ namespace SixLabors.ImageSharp.Benchmarks.Codecs
[Benchmark(Description = "EncodeBmpMultiple - ImageSharp")]
public void EncodeBmpImageSharp()
{
this.ForEachImageSharpImage((img, ms) => { img.Save(ms, new BmpEncoder()); return null; });
this.ForEachImageSharpImage((img, ms) =>
{
img.Save(ms, new BmpEncoder());
return null;
});
}
[Benchmark(Baseline = true, Description = "EncodeBmpMultiple - System.Drawing")]
public void EncodeBmpSystemDrawing()
{
this.ForEachSystemDrawingImage((img, ms) => { img.Save(ms, ImageFormat.Bmp); return null; });
this.ForEachSystemDrawingImage((img, ms) =>
{
img.Save(ms, ImageFormat.Bmp);
return null;
});
}
}
}
}

13
tests/ImageSharp.Benchmarks/Codecs/EncodeGifMultiple.cs

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using System.Collections.Generic;
@ -24,14 +24,19 @@ namespace SixLabors.ImageSharp.Benchmarks.Codecs
{
// Try to get as close to System.Drawing's output as possible
var options = new GifEncoder { Quantizer = new WebSafePaletteQuantizer(false) };
img.Save(ms, options); return null;
img.Save(ms, options);
return null;
});
}
[Benchmark(Baseline = true, Description = "EncodeGifMultiple - System.Drawing")]
public void EncodeGifSystemDrawing()
{
this.ForEachSystemDrawingImage((img, ms) => { img.Save(ms, ImageFormat.Gif); return null; });
this.ForEachSystemDrawingImage((img, ms) =>
{
img.Save(ms, ImageFormat.Gif);
return null;
});
}
}
}
}

2
tests/ImageSharp.Benchmarks/Codecs/EncodeTga.cs

@ -28,7 +28,7 @@ namespace SixLabors.ImageSharp.Benchmarks.Codecs
{
if (this.tgaCore == null)
{
this.tgaCore = Image.Load<Rgba32>(TestImageFullPath);
this.tgaCore = Image.Load<Rgba32>(this.TestImageFullPath);
this.tgaMagick = new MagickImage(this.TestImageFullPath);
}
}

5
tests/ImageSharp.Benchmarks/Codecs/ImageBenchmarkTests.cs

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
// This file contains small, cheap and "unit test" benchmarks to test MultiImageBenchmarkBase.
@ -6,7 +6,6 @@
// Uncomment this to enable benchmark testing
// #define TEST
#if TEST
// ReSharper disable InconsistentNaming
@ -76,4 +75,4 @@ namespace SixLabors.ImageSharp.Benchmarks.Codecs
}
}
#endif
#endif

6
tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_CopyTo1x1.cs

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using System;
@ -9,8 +9,8 @@ using BenchmarkDotNet.Attributes;
using SixLabors.ImageSharp.Formats.Jpeg.Components;
using SixLabors.ImageSharp.Memory;
// ReSharper disable InconsistentNaming
// ReSharper disable InconsistentNaming
namespace SixLabors.ImageSharp.Benchmarks.Codecs.Jpeg.BlockOperations
{
public class Block8x8F_CopyTo1x1
@ -130,4 +130,4 @@ namespace SixLabors.ImageSharp.Benchmarks.Codecs.Jpeg.BlockOperations
// Conclusion:
// Doesn't worth to bother with this
}
}
}

7
tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_CopyTo2x2.cs

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using System.Numerics;
@ -8,8 +8,8 @@ using BenchmarkDotNet.Attributes;
using SixLabors.ImageSharp.Formats.Jpeg.Components;
using SixLabors.ImageSharp.Memory;
// ReSharper disable InconsistentNaming
// ReSharper disable InconsistentNaming
namespace SixLabors.ImageSharp.Benchmarks.Codecs.Jpeg.BlockOperations
{
public class Block8x8F_CopyTo2x2
@ -335,7 +335,6 @@ namespace SixLabors.ImageSharp.Benchmarks.Codecs.Jpeg.BlockOperations
Unsafe.Add(ref dBottomLeft, 7) = wRight;
}
[Benchmark]
public void UseVector4_V2()
{
@ -409,4 +408,4 @@ namespace SixLabors.ImageSharp.Benchmarks.Codecs.Jpeg.BlockOperations
// UseVector4_SafeRightCorner | 58.97 ns | 0.4152 ns | 0.3884 ns | 0.64 | 0.02 |
// UseVector4_V2 | 41.88 ns | 0.3531 ns | 0.3303 ns | 0.45 | 0.01 |
}
}
}

19
tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_DivideRound.cs

@ -9,7 +9,6 @@ using BenchmarkDotNet.Attributes;
using SixLabors.ImageSharp.Formats.Jpeg.Components;
// ReSharper disable InconsistentNaming
namespace SixLabors.ImageSharp.Benchmarks.Codecs.Jpeg.BlockOperations
{
/// <summary>
@ -32,7 +31,7 @@ namespace SixLabors.ImageSharp.Benchmarks.Codecs.Jpeg.BlockOperations
{
for (int i = 0; i < Block8x8F.Size; i++)
{
this.inputDividend[i] = i*44.8f;
this.inputDividend[i] = i * 44.8f;
this.inputDivisor[i] = 100 - i;
}
}
@ -54,10 +53,11 @@ namespace SixLabors.ImageSharp.Benchmarks.Codecs.Jpeg.BlockOperations
sum = 0;
for (int i = 0; i < Block8x8F.Size; i++)
{
int a = (int) pDividend[i];
int b = (int) pDivisor;
int a = (int)pDividend[i];
int b = (int)pDivisor;
result[i] = RationalRound(a, b);
}
for (int i = 0; i < Block8x8F.Size; i++)
{
sum += result[i];
@ -83,13 +83,15 @@ namespace SixLabors.ImageSharp.Benchmarks.Codecs.Jpeg.BlockOperations
for (int i = 0; i < Block8x8F.Size; i++)
{
double value = pDividend[i] / pDivisor[i];
pDividend[i] = (float) System.Math.Round(value);
pDividend[i] = (float)System.Math.Round(value);
}
for (int i = 0; i < Block8x8F.Size; i++)
{
sum += (int) pDividend[i];
sum += (int)pDividend[i];
}
}
return sum;
}
@ -111,6 +113,7 @@ namespace SixLabors.ImageSharp.Benchmarks.Codecs.Jpeg.BlockOperations
sum += (int)pDividend[i];
}
}
return sum;
}
@ -138,10 +141,10 @@ namespace SixLabors.ImageSharp.Benchmarks.Codecs.Jpeg.BlockOperations
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static Vector4 DivideRound(Vector4 dividend, Vector4 divisor)
{
Vector4 sign = Vector4.Min(dividend, Vector4.One);
var sign = Vector4.Min(dividend, Vector4.One);
sign = Vector4.Max(sign, MinusOne);
return dividend / divisor + sign * Half;
return (dividend / divisor) + (sign * Half);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]

7
tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_LoadFromInt16.cs

@ -1,8 +1,6 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
// ReSharper disable InconsistentNaming
using System;
using System.Numerics;
@ -10,6 +8,7 @@ using BenchmarkDotNet.Attributes;
using SixLabors.ImageSharp.Formats.Jpeg.Components;
// ReSharper disable InconsistentNaming
namespace SixLabors.ImageSharp.Benchmarks.Codecs.Jpeg.BlockOperations
{
public class Block8x8F_LoadFromInt16
@ -50,4 +49,4 @@ namespace SixLabors.ImageSharp.Benchmarks.Codecs.Jpeg.BlockOperations
// Scalar | 34.88 ns | 0.3296 ns | 0.3083 ns | 1.00 |
// ExtendedAvx2 | 21.58 ns | 0.2125 ns | 0.1884 ns | 0.62 |
}
}
}

3
tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_Round.cs

@ -1,8 +1,6 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
// ReSharper disable InconsistentNaming
using System;
using System.Numerics;
using System.Runtime.CompilerServices;
@ -11,6 +9,7 @@ using BenchmarkDotNet.Attributes;
using SixLabors.ImageSharp.Formats.Jpeg.Components;
// ReSharper disable InconsistentNaming
namespace SixLabors.ImageSharp.Benchmarks.Codecs.Jpeg.BlockOperations
{
public class Block8x8F_Round

2
tests/ImageSharp.Benchmarks/Codecs/Jpeg/DecodeJpegParseStreamOnly.cs

@ -1,8 +1,10 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using System.Drawing;
using System.IO;
using BenchmarkDotNet.Attributes;
using SixLabors.ImageSharp.Formats.Jpeg;
using SixLabors.ImageSharp.Tests;
using SDSize = System.Drawing.Size;

6
tests/ImageSharp.Benchmarks/Codecs/Jpeg/DecodeJpeg_Aggregate.cs

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using System.Collections.Generic;
@ -10,8 +10,8 @@ using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Tests;
using SDImage = System.Drawing.Image;
// ReSharper disable InconsistentNaming
// ReSharper disable InconsistentNaming
namespace SixLabors.ImageSharp.Benchmarks.Codecs.Jpeg
{
/// <summary>
@ -45,4 +45,4 @@ namespace SixLabors.ImageSharp.Benchmarks.Codecs.Jpeg
this.ForEachStream(SDImage.FromStream);
}
}
}
}

41
tests/ImageSharp.Benchmarks/Codecs/Jpeg/DecodeJpeg_ImageSpecific.cs

@ -13,8 +13,8 @@ using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Tests;
using SDImage = System.Drawing.Image;
using SDSize = System.Drawing.Size;
// ReSharper disable InconsistentNaming
// ReSharper disable InconsistentNaming
namespace SixLabors.ImageSharp.Benchmarks.Codecs.Jpeg
{
/// <summary>
@ -34,10 +34,8 @@ namespace SixLabors.ImageSharp.Benchmarks.Codecs.Jpeg
{
public ShortClr()
{
this.Add(
// Job.Default.With(ClrRuntime.Net472).WithLaunchCount(1).WithWarmupCount(2).WithIterationCount(3),
Job.Default.With(CoreRuntime.Core21).WithLaunchCount(1).WithWarmupCount(2).WithIterationCount(3)
);
// Job.Default.With(ClrRuntime.Net472).WithLaunchCount(1).WithWarmupCount(2).WithIterationCount(3),
this.Add(Job.Default.With(CoreRuntime.Core21).WithLaunchCount(1).WithWarmupCount(2).WithIterationCount(3));
}
}
}
@ -53,14 +51,11 @@ namespace SixLabors.ImageSharp.Benchmarks.Codecs.Jpeg
// The scaled result for the large image "ExifGetString750Transform_Huge420YCbCr"
// is almost the same as the result for Jpeg420Exif,
// which proves that the execution time for the most common YCbCr 420 path scales linearly.
//
// TestImages.Jpeg.BenchmarkSuite.ExifGetString750Transform_Huge420YCbCr,
TestImages.Jpeg.BenchmarkSuite.Jpeg420Exif_MidSizeYCbCr)]
TestImages.Jpeg.BenchmarkSuite.Jpeg420Exif_MidSizeYCbCr
)]
public string TestImage { get; set; }
[GlobalSetup]
public void ReadImages()
{
@ -101,7 +96,7 @@ namespace SixLabors.ImageSharp.Benchmarks.Codecs.Jpeg
// Frequency=2742191 Hz, Resolution=364.6719 ns, Timer=TSC
// .NET Core SDK=2.1.403
// [Host] : .NET Core 2.1.5 (CoreCLR 4.6.26919.02, CoreFX 4.6.26919.02), 64bit RyuJIT
//
//
// Method | TestImage | Mean | Error | StdDev | Scaled | ScaledSD | Gen 0 | Gen 1 | Gen 2 | Allocated |
// ------------------------------- |-------------------------------------------- |-----------:|-----------:|----------:|-------:|---------:|----------:|---------:|---------:|------------:|
// 'Decode Jpeg - System.Drawing' | Jpg/baseline/Lake.jpg | 6.117 ms | 0.3923 ms | 0.0222 ms | 1.00 | 0.00 | 62.5000 | - | - | 205.83 KB |
@ -118,21 +113,21 @@ namespace SixLabors.ImageSharp.Benchmarks.Codecs.Jpeg
// RESULTS (2019 April 23):
//
//BenchmarkDotNet=v0.11.5, OS=Windows 10.0.17763.437 (1809/October2018Update/Redstone5)
//Intel Core i7-6600U CPU 2.60GHz (Skylake), 1 CPU, 4 logical and 2 physical cores
//.NET Core SDK=2.2.202
// BenchmarkDotNet=v0.11.5, OS=Windows 10.0.17763.437 (1809/October2018Update/Redstone5)
// Intel Core i7-6600U CPU 2.60GHz (Skylake), 1 CPU, 4 logical and 2 physical cores
// .NET Core SDK=2.2.202
// [Host] : .NET Core 2.1.9 (CoreCLR 4.6.27414.06, CoreFX 4.6.27415.01), 64bit RyuJIT
// Core : .NET Core 2.1.9 (CoreCLR 4.6.27414.06, CoreFX 4.6.27415.01), 64bit RyuJIT
//
//| Method | TestImage | Mean | Error | StdDev | Ratio | RatioSD | Gen 0 | Gen 1 | Gen 2 | Allocated |
//|------------------------------- |--------------------- |-----------:|-----------:|-----------:|------:|--------:|----------:|------:|------:|------------:|
//| 'Decode Jpeg - System.Drawing' | Jpg/b(...)e.jpg [21] | 6.957 ms | 9.618 ms | 0.5272 ms | 1.00 | 0.00 | 93.7500 | - | - | 205.83 KB |
//| 'Decode Jpeg - ImageSharp' | Jpg/b(...)e.jpg [21] | 18.348 ms | 8.876 ms | 0.4865 ms | 2.65 | 0.23 | - | - | - | 14.49 KB |
//| | | | | | | | | | | |
//| 'Decode Jpeg - System.Drawing' | Jpg/b(...)f.jpg [28] | 18.687 ms | 11.632 ms | 0.6376 ms | 1.00 | 0.00 | 343.7500 | - | - | 757.04 KB |
//| 'Decode Jpeg - ImageSharp' | Jpg/b(...)f.jpg [28] | 41.990 ms | 25.514 ms | 1.3985 ms | 2.25 | 0.10 | - | - | - | 15.48 KB |
//| | | | | | | | | | | |
//| 'Decode Jpeg - System.Drawing' | Jpg/i(...)e.jpg [43] | 477.265 ms | 732.126 ms | 40.1303 ms | 1.00 | 0.00 | 3000.0000 | - | - | 7403.76 KB |
//| 'Decode Jpeg - ImageSharp' | Jpg/i(...)e.jpg [43] | 348.545 ms | 91.480 ms | 5.0143 ms | 0.73 | 0.06 | - | - | - | 35177.21 KB |
// | Method | TestImage | Mean | Error | StdDev | Ratio | RatioSD | Gen 0 | Gen 1 | Gen 2 | Allocated |
// |------------------------------- |--------------------- |-----------:|-----------:|-----------:|------:|--------:|----------:|------:|------:|------------:|
// | 'Decode Jpeg - System.Drawing' | Jpg/b(...)e.jpg [21] | 6.957 ms | 9.618 ms | 0.5272 ms | 1.00 | 0.00 | 93.7500 | - | - | 205.83 KB |
// | 'Decode Jpeg - ImageSharp' | Jpg/b(...)e.jpg [21] | 18.348 ms | 8.876 ms | 0.4865 ms | 2.65 | 0.23 | - | - | - | 14.49 KB |
// | | | | | | | | | | | |
// | 'Decode Jpeg - System.Drawing' | Jpg/b(...)f.jpg [28] | 18.687 ms | 11.632 ms | 0.6376 ms | 1.00 | 0.00 | 343.7500 | - | - | 757.04 KB |
// | 'Decode Jpeg - ImageSharp' | Jpg/b(...)f.jpg [28] | 41.990 ms | 25.514 ms | 1.3985 ms | 2.25 | 0.10 | - | - | - | 15.48 KB |
// | | | | | | | | | | | |
// | 'Decode Jpeg - System.Drawing' | Jpg/i(...)e.jpg [43] | 477.265 ms | 732.126 ms | 40.1303 ms | 1.00 | 0.00 | 3000.0000 | - | - | 7403.76 KB |
// | 'Decode Jpeg - ImageSharp' | Jpg/i(...)e.jpg [43] | 348.545 ms | 91.480 ms | 5.0143 ms | 0.73 | 0.06 | - | - | - | 35177.21 KB |
}
}

49
tests/ImageSharp.Benchmarks/Codecs/Jpeg/DoubleBufferedStreams.cs

@ -125,28 +125,29 @@ namespace SixLabors.ImageSharp.Benchmarks.Codecs.Jpeg
}
}
// RESULTS (2019 April 24):
//
//BenchmarkDotNet=v0.11.5, OS=Windows 10.0.17763.437 (1809/October2018Update/Redstone5)
//Intel Core i7-6600U CPU 2.60GHz (Skylake), 1 CPU, 4 logical and 2 physical cores
//.NET Core SDK=2.2.202
// [Host] : .NET Core 2.1.9 (CoreCLR 4.6.27414.06, CoreFX 4.6.27415.01), 64bit RyuJIT
// Clr : .NET Framework 4.7.2 (CLR 4.0.30319.42000), 64bit RyuJIT-v4.7.3362.0
// Core : .NET Core 2.1.9 (CoreCLR 4.6.27414.06, CoreFX 4.6.27415.01), 64bit RyuJIT
//
//IterationCount=3 LaunchCount=1 WarmupCount=3
//
//| Method | Job | Runtime | Mean | Error | StdDev | Ratio | RatioSD | Gen 0 | Gen 1 | Gen 2 | Allocated |
//|----------------------------- |----- |-------- |---------:|-----------:|----------:|------:|--------:|------:|------:|------:|----------:|
//| StandardStreamReadByte | Clr | Clr | 96.71 us | 5.9950 us | 0.3286 us | 1.00 | 0.00 | - | - | - | - |
//| StandardStreamRead | Clr | Clr | 77.73 us | 5.2284 us | 0.2866 us | 0.80 | 0.00 | - | - | - | - |
//| DoubleBufferedStreamReadByte | Clr | Clr | 23.17 us | 26.2354 us | 1.4381 us | 0.24 | 0.01 | - | - | - | - |
//| DoubleBufferedStreamRead | Clr | Clr | 33.35 us | 3.4071 us | 0.1868 us | 0.34 | 0.00 | - | - | - | - |
//| SimpleReadByte | Clr | Clr | 10.85 us | 0.4927 us | 0.0270 us | 0.11 | 0.00 | - | - | - | - |
//| | | | | | | | | | | | |
//| StandardStreamReadByte | Core | Core | 75.35 us | 12.9789 us | 0.7114 us | 1.00 | 0.00 | - | - | - | - |
//| StandardStreamRead | Core | Core | 55.36 us | 1.4432 us | 0.0791 us | 0.73 | 0.01 | - | - | - | - |
//| DoubleBufferedStreamReadByte | Core | Core | 21.47 us | 29.7076 us | 1.6284 us | 0.28 | 0.02 | - | - | - | - |
//| DoubleBufferedStreamRead | Core | Core | 29.67 us | 2.5988 us | 0.1424 us | 0.39 | 0.00 | - | - | - | - |
//| SimpleReadByte | Core | Core | 10.84 us | 0.7567 us | 0.0415 us | 0.14 | 0.00 | - | - | - | - |
/* RESULTS (2019 April 24):
BenchmarkDotNet=v0.11.5, OS=Windows 10.0.17763.437 (1809/October2018Update/Redstone5)
Intel Core i7-6600U CPU 2.60GHz (Skylake), 1 CPU, 4 logical and 2 physical cores
.NET Core SDK=2.2.202
[Host] : .NET Core 2.1.9 (CoreCLR 4.6.27414.06, CoreFX 4.6.27415.01), 64bit RyuJIT
Clr : .NET Framework 4.7.2 (CLR 4.0.30319.42000), 64bit RyuJIT-v4.7.3362.0
Core : .NET Core 2.1.9 (CoreCLR 4.6.27414.06, CoreFX 4.6.27415.01), 64bit RyuJIT
IterationCount=3 LaunchCount=1 WarmupCount=3
| Method | Job | Runtime | Mean | Error | StdDev | Ratio | RatioSD | Gen 0 | Gen 1 | Gen 2 | Allocated |
|----------------------------- |----- |-------- |---------:|-----------:|----------:|------:|--------:|------:|------:|------:|----------:|
| StandardStreamReadByte | Clr | Clr | 96.71 us | 5.9950 us | 0.3286 us | 1.00 | 0.00 | - | - | - | - |
| StandardStreamRead | Clr | Clr | 77.73 us | 5.2284 us | 0.2866 us | 0.80 | 0.00 | - | - | - | - |
| DoubleBufferedStreamReadByte | Clr | Clr | 23.17 us | 26.2354 us | 1.4381 us | 0.24 | 0.01 | - | - | - | - |
| DoubleBufferedStreamRead | Clr | Clr | 33.35 us | 3.4071 us | 0.1868 us | 0.34 | 0.00 | - | - | - | - |
| SimpleReadByte | Clr | Clr | 10.85 us | 0.4927 us | 0.0270 us | 0.11 | 0.00 | - | - | - | - |
| | | | | | | | | | | | |
| StandardStreamReadByte | Core | Core | 75.35 us | 12.9789 us | 0.7114 us | 1.00 | 0.00 | - | - | - | - |
| StandardStreamRead | Core | Core | 55.36 us | 1.4432 us | 0.0791 us | 0.73 | 0.01 | - | - | - | - |
| DoubleBufferedStreamReadByte | Core | Core | 21.47 us | 29.7076 us | 1.6284 us | 0.28 | 0.02 | - | - | - | - |
| DoubleBufferedStreamRead | Core | Core | 29.67 us | 2.5988 us | 0.1424 us | 0.39 | 0.00 | - | - | - | - |
| SimpleReadByte | Core | Core | 10.84 us | 0.7567 us | 0.0415 us | 0.14 | 0.00 | - | - | - | - |
*/
}

9
tests/ImageSharp.Benchmarks/Codecs/Jpeg/EncodeJpeg.cs

@ -1,16 +1,15 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
using BenchmarkDotNet.Attributes;
using SixLabors.ImageSharp.PixelFormats;
namespace SixLabors.ImageSharp.Benchmarks.Codecs.Jpeg
{
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using CoreImage = SixLabors.ImageSharp.Image;
public class EncodeJpeg : BenchmarkBase
@ -58,4 +57,4 @@ namespace SixLabors.ImageSharp.Benchmarks.Codecs.Jpeg
}
}
}
}
}

16
tests/ImageSharp.Benchmarks/Codecs/Jpeg/EncodeJpegMultiple.cs

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using System.Collections.Generic;
@ -18,13 +18,21 @@ namespace SixLabors.ImageSharp.Benchmarks.Codecs.Jpeg
[Benchmark(Description = "EncodeJpegMultiple - ImageSharp")]
public void EncodeJpegImageSharp()
{
this.ForEachImageSharpImage((img, ms) => { img.Save(ms, new JpegEncoder()); return null; });
this.ForEachImageSharpImage((img, ms) =>
{
img.Save(ms, new JpegEncoder());
return null;
});
}
[Benchmark(Baseline = true, Description = "EncodeJpegMultiple - System.Drawing")]
public void EncodeJpegSystemDrawing()
{
this.ForEachSystemDrawingImage((img, ms) => { img.Save(ms, ImageFormat.Jpeg); return null; });
this.ForEachSystemDrawingImage((img, ms) =>
{
img.Save(ms, ImageFormat.Jpeg);
return null;
});
}
}
}
}

6
tests/ImageSharp.Benchmarks/Codecs/Jpeg/LoadResizeSave_Aggregate.cs

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using System.Collections.Generic;
@ -13,8 +13,8 @@ using SixLabors.ImageSharp.Formats.Jpeg;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Tests;
// ReSharper disable InconsistentNaming
// ReSharper disable InconsistentNaming
namespace SixLabors.ImageSharp.Benchmarks.Codecs.Jpeg
{
[Config(typeof(MultiImageBenchmarkBase.Config))]
@ -93,4 +93,4 @@ namespace SixLabors.ImageSharp.Benchmarks.Codecs.Jpeg
});
}
}
}
}

22
tests/ImageSharp.Benchmarks/Codecs/Jpeg/LoadResizeSave_ImageSpecific.cs

@ -1,18 +1,20 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using BenchmarkDotNet.Attributes;
using System;
using System.IO;
using SixLabors.ImageSharp.Tests;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.IO;
using BenchmarkDotNet.Attributes;
using SixLabors.ImageSharp.Formats.Jpeg;
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Tests;
using SDImage = System.Drawing.Image;
using SixLabors.ImageSharp.Formats.Jpeg;
// ReSharper disable InconsistentNaming
// ReSharper disable InconsistentNaming
namespace SixLabors.ImageSharp.Benchmarks.Codecs.Jpeg
{
[Config(typeof(Config.ShortClr))]
@ -29,9 +31,7 @@ namespace SixLabors.ImageSharp.Benchmarks.Codecs.Jpeg
[Params(
TestImages.Jpeg.BenchmarkSuite.Lake_Small444YCbCr,
TestImages.Jpeg.BenchmarkSuite.BadRstProgressive518_Large444YCbCr,
TestImages.Jpeg.BenchmarkSuite.Jpeg420Exif_MidSizeYCbCr
)]
TestImages.Jpeg.BenchmarkSuite.Jpeg420Exif_MidSizeYCbCr)]
public string TestImage { get; set; }
[Params(false, true)]
@ -89,7 +89,7 @@ namespace SixLabors.ImageSharp.Benchmarks.Codecs.Jpeg
// [Host] : .NET Core 2.1.5 (CoreCLR 4.6.26919.02, CoreFX 4.6.26919.02), 64bit RyuJIT
// Job-ZPEZGV : .NET Framework 4.7.1 (CLR 4.0.30319.42000), 64bit RyuJIT-v4.7.3190.0
// Job-SGOCJT : .NET Core 2.1.5 (CoreCLR 4.6.26919.02, CoreFX 4.6.26919.02), 64bit RyuJIT
//
//
// Method | Runtime | TestImage | ParallelExec | Mean | Error | StdDev | Scaled | ScaledSD | Gen 0 | Allocated |
// -------------- |-------- |----------------------------- |------------- |----------:|----------:|----------:|-------:|---------:|---------:|----------:|
// SystemDrawing | Clr | Jpg/baseline/jpeg420exif.jpg | False | 64.88 ms | 3.735 ms | 0.2110 ms | 1.00 | 0.00 | 250.0000 | 791.07 KB |
@ -104,4 +104,4 @@ namespace SixLabors.ImageSharp.Benchmarks.Codecs.Jpeg
// SystemDrawing | Core | Jpg/baseline/jpeg420exif.jpg | True | 64.20 ms | 6.560 ms | 0.3707 ms | 1.00 | 0.00 | 250.0000 | 789.79 KB |
// ImageSharp | Core | Jpg/baseline/jpeg420exif.jpg | True | 68.08 ms | 18.376 ms | 1.0383 ms | 1.06 | 0.01 | - | 50.49 KB |
}
}
}

2
tests/ImageSharp.Benchmarks/Codecs/Jpeg/YCbCrColorConversion.cs

@ -74,7 +74,7 @@ namespace SixLabors.ImageSharp.Benchmarks.Codecs.Jpeg
for (int j = 0; j < inputBufferLength; j++)
{
values[j] = (float)rnd.NextDouble() * (maxVal - minVal) + minVal;
values[j] = ((float)rnd.NextDouble() * (maxVal - minVal)) + minVal;
}
// no need to dispose when buffer is not array owner

55
tests/ImageSharp.Benchmarks/Codecs/MultiImageBenchmarkBase.cs

@ -20,7 +20,7 @@ namespace SixLabors.ImageSharp.Benchmarks.Codecs
using BenchmarkDotNet.Environments;
using SixLabors.ImageSharp.Tests;
using CoreImage = ImageSharp.Image;
using CoreImage = SixLabors.ImageSharp.Image;
public abstract class MultiImageBenchmarkBase
{
@ -36,27 +36,33 @@ namespace SixLabors.ImageSharp.Benchmarks.Codecs
{
public ShortClr()
{
this.Add(
Job.Default.With(CoreRuntime.Core21).WithLaunchCount(1).WithWarmupCount(1).WithIterationCount(2)
);
this.Add(Job.Default.With(CoreRuntime.Core21).WithLaunchCount(1).WithWarmupCount(1).WithIterationCount(2));
}
}
}
protected Dictionary<string, byte[]> FileNamesToBytes = new Dictionary<string, byte[]>();
protected Dictionary<string, Image<Rgba32>> FileNamesToImageSharpImages = new Dictionary<string, Image<Rgba32>>();
protected Dictionary<string, Bitmap> FileNamesToSystemDrawingImages = new Dictionary<string, System.Drawing.Bitmap>();
protected Dictionary<string, byte[]> fileNamesToBytes = new Dictionary<string, byte[]>();
protected Dictionary<string, Image<Rgba32>> fileNamesToImageSharpImages = new Dictionary<string, Image<Rgba32>>();
protected Dictionary<string, Bitmap> fileNamesToSystemDrawingImages = new Dictionary<string, System.Drawing.Bitmap>();
/// <summary>
/// The values of this enum separate input files into categories
/// The values of this enum separate input files into categories.
/// </summary>
public enum InputImageCategory
{
/// <summary>
/// Use all images.
/// </summary>
AllImages,
/// <summary>
/// Use small images only.
/// </summary>
SmallImagesOnly,
/// <summary>
/// Use large images only.
/// </summary>
LargeImagesOnly
}
@ -73,12 +79,13 @@ namespace SixLabors.ImageSharp.Benchmarks.Codecs
protected virtual IEnumerable<string> ExcludeSubstringsInFileNames => new[] { "badeof", "BadEof", "CriticalEOF" };
/// <summary>
/// Enumerates folders containing files OR files to be processed by the benchmark.
/// Gets folders containing files OR files to be processed by the benchmark.
/// </summary>
protected IEnumerable<string> AllFoldersOrFiles => this.InputImageSubfoldersOrFiles.Select(f => Path.Combine(this.BaseFolder, f));
/// <summary>
/// The images sized above this threshold will be included in
/// Gets the large image threshold.
/// The images sized above this threshold will be included in.
/// </summary>
protected virtual int LargeImageThresholdInBytes => 100000;
@ -102,7 +109,7 @@ namespace SixLabors.ImageSharp.Benchmarks.Codecs
protected IEnumerable<KeyValuePair<string, byte[]>> FileNames2Bytes
=>
this.EnumeratePairsByBenchmarkSettings(
this.FileNamesToBytes,
this.fileNamesToBytes,
arr => arr.Length < this.LargeImageThresholdInBytes);
protected abstract IEnumerable<string> InputImageSubfoldersOrFiles { get; }
@ -114,6 +121,7 @@ namespace SixLabors.ImageSharp.Benchmarks.Codecs
{
throw new Exception("Vector.IsHardwareAccelerated == false! Check your build settings!");
}
// Console.WriteLine("Vector.IsHardwareAccelerated: " + Vector.IsHardwareAccelerated);
this.ReadFilesImpl();
}
@ -124,7 +132,7 @@ namespace SixLabors.ImageSharp.Benchmarks.Codecs
{
if (File.Exists(path))
{
this.FileNamesToBytes[path] = File.ReadAllBytes(path);
this.fileNamesToBytes[path] = File.ReadAllBytes(path);
continue;
}
@ -138,7 +146,7 @@ namespace SixLabors.ImageSharp.Benchmarks.Codecs
foreach (string fn in allFiles)
{
this.FileNamesToBytes[fn] = File.ReadAllBytes(fn);
this.fileNamesToBytes[fn] = File.ReadAllBytes(fn);
}
}
}
@ -157,7 +165,6 @@ namespace SixLabors.ImageSharp.Benchmarks.Codecs
{
object obj = operation(memoryStream);
(obj as IDisposable)?.Dispose();
}
catch (Exception ex)
{
@ -173,31 +180,30 @@ namespace SixLabors.ImageSharp.Benchmarks.Codecs
{
base.ReadFilesImpl();
foreach (KeyValuePair<string, byte[]> kv in this.FileNamesToBytes)
foreach (KeyValuePair<string, byte[]> kv in this.fileNamesToBytes)
{
byte[] bytes = kv.Value;
string fn = kv.Key;
using (var ms1 = new MemoryStream(bytes))
{
this.FileNamesToImageSharpImages[fn] = CoreImage.Load<Rgba32>(ms1);
this.fileNamesToImageSharpImages[fn] = CoreImage.Load<Rgba32>(ms1);
}
this.FileNamesToSystemDrawingImages[fn] = new Bitmap(new MemoryStream(bytes));
this.fileNamesToSystemDrawingImages[fn] = new Bitmap(new MemoryStream(bytes));
}
}
protected IEnumerable<KeyValuePair<string, Image<Rgba32>>> FileNames2ImageSharpImages
=>
this.EnumeratePairsByBenchmarkSettings(
this.FileNamesToImageSharpImages,
this.fileNamesToImageSharpImages,
img => img.Width * img.Height < this.LargeImageThresholdInPixels);
protected IEnumerable<KeyValuePair<string, System.Drawing.Bitmap>> FileNames2SystemDrawingImages
=>
this.EnumeratePairsByBenchmarkSettings(
this.FileNamesToSystemDrawingImages,
this.fileNamesToSystemDrawingImages,
img => img.Width * img.Height < this.LargeImageThresholdInPixels);
protected virtual int LargeImageThresholdInPixels => 700000;
@ -210,13 +216,11 @@ namespace SixLabors.ImageSharp.Benchmarks.Codecs
{
object obj = operation(kv.Value);
(obj as IDisposable)?.Dispose();
}
catch (Exception ex)
{
Console.WriteLine($"Operation on {kv.Key} failed with {ex.Message}");
}
}
}
@ -224,13 +228,13 @@ namespace SixLabors.ImageSharp.Benchmarks.Codecs
{
using (var workStream = new MemoryStream())
{
this.ForEachImageSharpImage(
img =>
{
// ReSharper disable AccessToDisposedClosure
object result = operation(img, workStream);
workStream.Seek(0, SeekOrigin.Begin);
// ReSharper restore AccessToDisposedClosure
return result;
});
@ -257,18 +261,17 @@ namespace SixLabors.ImageSharp.Benchmarks.Codecs
{
using (var workStream = new MemoryStream())
{
this.ForEachSystemDrawingImage(
img =>
{
// ReSharper disable AccessToDisposedClosure
object result = operation(img, workStream);
workStream.Seek(0, SeekOrigin.Begin);
// ReSharper restore AccessToDisposedClosure
return result;
});
}
}
}
}

14
tests/ImageSharp.Benchmarks/Color/Bulk/FromRgba32Bytes.cs

@ -1,16 +1,14 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
// ReSharper disable InconsistentNaming
using System.Buffers;
using System;
using System.Buffers;
using BenchmarkDotNet.Attributes;
using SixLabors.ImageSharp.Memory;
using SixLabors.ImageSharp.PixelFormats;
// ReSharper disable InconsistentNaming
namespace SixLabors.ImageSharp.Benchmarks.ColorSpaces.Bulk
{
public abstract class FromRgba32Bytes<TPixel>
@ -23,7 +21,7 @@ namespace SixLabors.ImageSharp.Benchmarks.ColorSpaces.Bulk
private Configuration configuration;
[Params(
128,
128,
1024,
2048)]
public int Count { get; set; }
@ -43,12 +41,12 @@ namespace SixLabors.ImageSharp.Benchmarks.ColorSpaces.Bulk
this.source.Dispose();
}
//[Benchmark]
// [Benchmark]
public void Naive()
{
Span<byte> s = this.source.GetSpan();
Span<TPixel> d = this.destination.GetSpan();
for (int i = 0; i < this.Count; i++)
{
int i4 = i * 4;
@ -89,4 +87,4 @@ namespace SixLabors.ImageSharp.Benchmarks.ColorSpaces.Bulk
// CommonBulk | 2048 | 2,625.4 ns | 30.143 ns | 26.721 ns | 1.00 |
// OptimizedBulk | 2048 | 1,843.0 ns | 20.505 ns | 18.177 ns | 0.70 |
}
}
}

13
tests/ImageSharp.Benchmarks/Color/Bulk/FromVector4.cs

@ -1,8 +1,6 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
// ReSharper disable InconsistentNaming
using System;
using System.Buffers;
using System.Numerics;
@ -14,6 +12,7 @@ using BenchmarkDotNet.Attributes;
using SixLabors.ImageSharp.Memory;
using SixLabors.ImageSharp.PixelFormats;
// ReSharper disable InconsistentNaming
namespace SixLabors.ImageSharp.Benchmarks.ColorSpaces.Bulk
{
[Config(typeof(Config.ShortClr))]
@ -26,10 +25,7 @@ namespace SixLabors.ImageSharp.Benchmarks.ColorSpaces.Bulk
protected Configuration Configuration => Configuration.Default;
[Params(
64,
2048
)]
[Params(64, 2048)]
public int Count { get; set; }
[GlobalSetup]
@ -46,12 +42,11 @@ namespace SixLabors.ImageSharp.Benchmarks.ColorSpaces.Bulk
this.source.Dispose();
}
//[Benchmark]
// [Benchmark]
public void PerElement()
{
ref Vector4 s = ref MemoryMarshal.GetReference(this.source.GetSpan());
ref TPixel d = ref MemoryMarshal.GetReference(this.destination.GetSpan());
for (int i = 0; i < this.Count; i++)
{
Unsafe.Add(ref d, i).FromVector4(Unsafe.Add(ref s, i));
@ -127,4 +122,4 @@ namespace SixLabors.ImageSharp.Benchmarks.ColorSpaces.Bulk
// PixelOperations_Base | Core | 2048 | 16,875.73 ns | 1,271.957 ns | 71.8679 ns | 4.30 | 0.10 | - | 24 B |
// PixelOperations_Specialized | Core | 2048 | 2,129.92 ns | 262.888 ns | 14.8537 ns |!! 0.54 | 0.01 | - | 0 B | <--- ExtendedIntrinsics rock!
}
}
}

5
tests/ImageSharp.Benchmarks/Color/Bulk/Rgb24Bytes.cs

@ -1,13 +1,12 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
// ReSharper disable InconsistentNaming
using System.Buffers;
using BenchmarkDotNet.Attributes;
using SixLabors.ImageSharp.Memory;
using SixLabors.ImageSharp.PixelFormats;
// ReSharper disable InconsistentNaming
namespace SixLabors.ImageSharp.Benchmarks.ColorSpaces.Bulk
{
public abstract class Rgb24Bytes<TPixel>
@ -57,4 +56,4 @@ namespace SixLabors.ImageSharp.Benchmarks.ColorSpaces.Bulk
public class Rgb24Bytes_Rgba32 : Rgb24Bytes<Rgba32>
{
}
}
}

5
tests/ImageSharp.Benchmarks/Color/Bulk/ToRgba32Bytes.cs

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using System;
@ -9,7 +9,6 @@ using SixLabors.ImageSharp.Memory;
using SixLabors.ImageSharp.PixelFormats;
// ReSharper disable InconsistentNaming
namespace SixLabors.ImageSharp.Benchmarks.ColorSpaces.Bulk
{
public abstract class ToRgba32Bytes<TPixel>
@ -39,7 +38,7 @@ namespace SixLabors.ImageSharp.Benchmarks.ColorSpaces.Bulk
this.destination.Dispose();
}
//[Benchmark]
// [Benchmark]
public void Naive()
{
Span<TPixel> s = this.source.GetSpan();

18
tests/ImageSharp.Benchmarks/Color/Bulk/ToVector4.cs

@ -1,17 +1,15 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
// ReSharper disable InconsistentNaming
using System.Buffers;
using System;
using System.Buffers;
using System.Numerics;
using BenchmarkDotNet.Attributes;
using SixLabors.ImageSharp.Memory;
using SixLabors.ImageSharp.PixelFormats;
// ReSharper disable InconsistentNaming
namespace SixLabors.ImageSharp.Benchmarks.ColorSpaces.Bulk
{
public abstract class ToVector4<TPixel>
@ -23,12 +21,7 @@ namespace SixLabors.ImageSharp.Benchmarks.ColorSpaces.Bulk
protected Configuration Configuration => Configuration.Default;
[Params(
64,
256,
//512,
//1024,
2048)]
[Params(64, 256, 2048)] // 512, 1024
public int Count { get; set; }
[GlobalSetup]
@ -45,7 +38,7 @@ namespace SixLabors.ImageSharp.Benchmarks.ColorSpaces.Bulk
this.destination.Dispose();
}
//[Benchmark]
// [Benchmark]
public void Naive()
{
Span<TPixel> s = this.source.GetSpan();
@ -56,7 +49,6 @@ namespace SixLabors.ImageSharp.Benchmarks.ColorSpaces.Bulk
d[i] = s[i].ToVector4();
}
}
[Benchmark]
public void PixelOperations_Specialized()
@ -67,4 +59,4 @@ namespace SixLabors.ImageSharp.Benchmarks.ColorSpaces.Bulk
this.destination.GetSpan());
}
}
}
}

5
tests/ImageSharp.Benchmarks/Color/Bulk/ToVector4_Bgra32.cs

@ -1,3 +1,6 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using BenchmarkDotNet.Attributes;
using SixLabors.ImageSharp.Memory;
@ -38,4 +41,4 @@ namespace SixLabors.ImageSharp.Benchmarks.ColorSpaces.Bulk
// PixelOperations_Base | Core | 2048 | 6,937.5 ns | 1,692.19 ns | 95.6121 ns | 1.00 | 0.00 | - | 24 B |
// PixelOperations_Specialized | Core | 2048 | 2,994.5 ns | 1,126.65 ns | 63.6578 ns | 0.43 | 0.01 | - | 0 B |
}
}
}

68
tests/ImageSharp.Benchmarks/Color/Bulk/ToVector4_Rgba32.cs

@ -1,3 +1,6 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using System;
using System.Numerics;
using System.Runtime.CompilerServices;
@ -49,7 +52,7 @@ namespace SixLabors.ImageSharp.Benchmarks.ColorSpaces.Bulk
SimdUtils.ExtendedIntrinsics.BulkConvertByteToNormalizedFloat(sBytes, dFloats);
}
//[Benchmark]
// [Benchmark]
public void ExtendedIntrinsics_BulkConvertByteToNormalizedFloat_2Loops()
{
Span<byte> sBytes = MemoryMarshal.Cast<Rgba32, byte>(this.source.GetSpan());
@ -91,7 +94,7 @@ namespace SixLabors.ImageSharp.Benchmarks.ColorSpaces.Bulk
}
}
//[Benchmark]
// [Benchmark]
public void ExtendedIntrinsics_BulkConvertByteToNormalizedFloat_ConvertInSameLoop()
{
Span<byte> sBytes = MemoryMarshal.Cast<Rgba32, byte>(this.source.GetSpan());
@ -127,38 +130,39 @@ namespace SixLabors.ImageSharp.Benchmarks.ColorSpaces.Bulk
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static Vector<float> ConvertToNormalizedSingle(Vector<uint> u, Vector<float> scale)
{
Vector<int> vi = Vector.AsVectorInt32(u);
Vector<float> v = Vector.ConvertToSingle(vi);
var vi = Vector.AsVectorInt32(u);
var v = Vector.ConvertToSingle(vi);
v *= scale;
return v;
}
// RESULTS (2018 October):
//
// Method | Runtime | Count | Mean | Error | StdDev | Scaled | ScaledSD | Gen 0 | Allocated |
// ---------------------------- |-------- |------ |------------:|-------------:|------------:|-------:|---------:|-------:|----------:|
// FallbackIntrinsics128 | Clr | 64 | 287.62 ns | 6.026 ns | 0.3405 ns | 1.19 | 0.00 | - | 0 B |
// BasicIntrinsics256 | Clr | 64 | 240.83 ns | 10.585 ns | 0.5981 ns | 1.00 | 0.00 | - | 0 B |
// ExtendedIntrinsics | Clr | 64 | 168.28 ns | 11.478 ns | 0.6485 ns | 0.70 | 0.00 | - | 0 B |
// PixelOperations_Base | Clr | 64 | 334.08 ns | 38.048 ns | 2.1498 ns | 1.39 | 0.01 | 0.0072 | 24 B |
// PixelOperations_Specialized | Clr | 64 | 255.41 ns | 10.939 ns | 0.6181 ns | 1.06 | 0.00 | - | 0 B | <--- ceremonial overhead has been minimized!
// | | | | | | | | | |
// FallbackIntrinsics128 | Core | 64 | 183.29 ns | 8.931 ns | 0.5046 ns | 1.32 | 0.00 | - | 0 B |
// BasicIntrinsics256 | Core | 64 | 139.18 ns | 7.633 ns | 0.4313 ns | 1.00 | 0.00 | - | 0 B |
// ExtendedIntrinsics | Core | 64 | 66.29 ns | 16.366 ns | 0.9247 ns | 0.48 | 0.01 | - | 0 B |
// PixelOperations_Base | Core | 64 | 257.75 ns | 16.959 ns | 0.9582 ns | 1.85 | 0.01 | 0.0072 | 24 B |
// PixelOperations_Specialized | Core | 64 | 90.14 ns | 9.955 ns | 0.5625 ns | 0.65 | 0.00 | - | 0 B |
// | | | | | | | | | |
// FallbackIntrinsics128 | Clr | 2048 | 5,011.84 ns | 347.991 ns | 19.6621 ns | 1.22 | 0.01 | - | 0 B |
// BasicIntrinsics256 | Clr | 2048 | 4,119.35 ns | 720.153 ns | 40.6900 ns | 1.00 | 0.00 | - | 0 B |
// ExtendedIntrinsics | Clr | 2048 | 1,195.29 ns | 164.389 ns | 9.2883 ns |!! 0.29 | 0.00 | - | 0 B | <--- ExtendedIntrinsics rock!
// PixelOperations_Base | Clr | 2048 | 6,820.58 ns | 823.433 ns | 46.5255 ns | 1.66 | 0.02 | - | 24 B |
// PixelOperations_Specialized | Clr | 2048 | 4,203.53 ns | 176.714 ns | 9.9847 ns | 1.02 | 0.01 | - | 0 B | <--- can't yet detect whether ExtendedIntrinsics are available :(
// | | | | | | | | | |
// FallbackIntrinsics128 | Core | 2048 | 5,017.89 ns | 4,021.533 ns | 227.2241 ns | 1.24 | 0.05 | - | 0 B |
// BasicIntrinsics256 | Core | 2048 | 4,046.51 ns | 1,150.390 ns | 64.9992 ns | 1.00 | 0.00 | - | 0 B |
// ExtendedIntrinsics | Core | 2048 | 1,130.59 ns | 832.588 ns | 47.0427 ns |!! 0.28 | 0.01 | - | 0 B | <--- ExtendedIntrinsics rock!
// PixelOperations_Base | Core | 2048 | 6,752.68 ns | 272.820 ns | 15.4148 ns | 1.67 | 0.02 | - | 24 B |
// PixelOperations_Specialized | Core | 2048 | 1,126.13 ns | 79.192 ns | 4.4745 ns |!! 0.28 | 0.00 | - | 0 B | <--- ExtendedIntrinsics rock!
/*RESULTS (2018 October):
Method | Runtime | Count | Mean | Error | StdDev | Scaled | ScaledSD | Gen 0 | Allocated |
---------------------------- |-------- |------ |------------:|-------------:|------------:|-------:|---------:|-------:|----------:|
FallbackIntrinsics128 | Clr | 64 | 287.62 ns | 6.026 ns | 0.3405 ns | 1.19 | 0.00 | - | 0 B |
BasicIntrinsics256 | Clr | 64 | 240.83 ns | 10.585 ns | 0.5981 ns | 1.00 | 0.00 | - | 0 B |
ExtendedIntrinsics | Clr | 64 | 168.28 ns | 11.478 ns | 0.6485 ns | 0.70 | 0.00 | - | 0 B |
PixelOperations_Base | Clr | 64 | 334.08 ns | 38.048 ns | 2.1498 ns | 1.39 | 0.01 | 0.0072 | 24 B |
PixelOperations_Specialized | Clr | 64 | 255.41 ns | 10.939 ns | 0.6181 ns | 1.06 | 0.00 | - | 0 B | <--- ceremonial overhead has been minimized!
| | | | | | | | | |
FallbackIntrinsics128 | Core | 64 | 183.29 ns | 8.931 ns | 0.5046 ns | 1.32 | 0.00 | - | 0 B |
BasicIntrinsics256 | Core | 64 | 139.18 ns | 7.633 ns | 0.4313 ns | 1.00 | 0.00 | - | 0 B |
ExtendedIntrinsics | Core | 64 | 66.29 ns | 16.366 ns | 0.9247 ns | 0.48 | 0.01 | - | 0 B |
PixelOperations_Base | Core | 64 | 257.75 ns | 16.959 ns | 0.9582 ns | 1.85 | 0.01 | 0.0072 | 24 B |
PixelOperations_Specialized | Core | 64 | 90.14 ns | 9.955 ns | 0.5625 ns | 0.65 | 0.00 | - | 0 B |
| | | | | | | | | |
FallbackIntrinsics128 | Clr | 2048 | 5,011.84 ns | 347.991 ns | 19.6621 ns | 1.22 | 0.01 | - | 0 B |
BasicIntrinsics256 | Clr | 2048 | 4,119.35 ns | 720.153 ns | 40.6900 ns | 1.00 | 0.00 | - | 0 B |
ExtendedIntrinsics | Clr | 2048 | 1,195.29 ns | 164.389 ns | 9.2883 ns |!! 0.29 | 0.00 | - | 0 B | <--- ExtendedIntrinsics rock!
PixelOperations_Base | Clr | 2048 | 6,820.58 ns | 823.433 ns | 46.5255 ns | 1.66 | 0.02 | - | 24 B |
PixelOperations_Specialized | Clr | 2048 | 4,203.53 ns | 176.714 ns | 9.9847 ns | 1.02 | 0.01 | - | 0 B | <--- can't yet detect whether ExtendedIntrinsics are available :(
| | | | | | | | | |
FallbackIntrinsics128 | Core | 2048 | 5,017.89 ns | 4,021.533 ns | 227.2241 ns | 1.24 | 0.05 | - | 0 B |
BasicIntrinsics256 | Core | 2048 | 4,046.51 ns | 1,150.390 ns | 64.9992 ns | 1.00 | 0.00 | - | 0 B |
ExtendedIntrinsics | Core | 2048 | 1,130.59 ns | 832.588 ns | 47.0427 ns |!! 0.28 | 0.01 | - | 0 B | <--- ExtendedIntrinsics rock!
PixelOperations_Base | Core | 2048 | 6,752.68 ns | 272.820 ns | 15.4148 ns | 1.67 | 0.02 | - | 24 B |
PixelOperations_Specialized | Core | 2048 | 1,126.13 ns | 79.192 ns | 4.4745 ns |!! 0.28 | 0.00 | - | 0 B | <--- ExtendedIntrinsics rock!
*/
}
}
}

8
tests/ImageSharp.Benchmarks/Color/ColorspaceCieXyzToCieLabConvert.cs

@ -1,4 +1,7 @@
using BenchmarkDotNet.Attributes;
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using BenchmarkDotNet.Attributes;
using Colourful;
using Colourful.Conversion;
@ -18,7 +21,6 @@ namespace SixLabors.ImageSharp.Benchmarks.ColorSpaces
private static readonly ColourfulConverter ColourfulConverter = new ColourfulConverter();
[Benchmark(Baseline = true, Description = "Colourful Convert")]
public double ColourfulConvert()
{
@ -31,4 +33,4 @@ namespace SixLabors.ImageSharp.Benchmarks.ColorSpaces
return ColorSpaceConverter.ToCieLab(CieXyz).L;
}
}
}
}

7
tests/ImageSharp.Benchmarks/Color/ColorspaceCieXyzToHunterLabConvert.cs

@ -1,4 +1,7 @@
using BenchmarkDotNet.Attributes;
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using BenchmarkDotNet.Attributes;
using Colourful;
using Colourful.Conversion;
@ -30,4 +33,4 @@ namespace SixLabors.ImageSharp.Benchmarks.ColorSpaces
return ColorSpaceConverter.ToHunterLab(CieXyz).L;
}
}
}
}

5
tests/ImageSharp.Benchmarks/Color/ColorspaceCieXyzToLmsConvert.cs

@ -1,4 +1,7 @@
using BenchmarkDotNet.Attributes;
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using BenchmarkDotNet.Attributes;
using Colourful;
using Colourful.Conversion;

10
tests/ImageSharp.Benchmarks/Color/ColorspaceCieXyzToRgbConvert.cs

@ -1,11 +1,14 @@
using BenchmarkDotNet.Attributes;
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using BenchmarkDotNet.Attributes;
using Colourful;
using Colourful.Conversion;
using SixLabors.ImageSharp.ColorSpaces;
using SixLabors.ImageSharp.ColorSpaces.Conversion;
namespace SixLabors.ImageSharp.Benchmarks.ColorSpaces
{
public class ColorspaceCieXyzToRgbConvert
@ -18,7 +21,6 @@ namespace SixLabors.ImageSharp.Benchmarks.ColorSpaces
private static readonly ColourfulConverter ColourfulConverter = new ColourfulConverter();
[Benchmark(Baseline = true, Description = "Colourful Convert")]
public double ColourfulConvert()
{
@ -31,4 +33,4 @@ namespace SixLabors.ImageSharp.Benchmarks.ColorSpaces
return ColorSpaceConverter.ToRgb(CieXyz).R;
}
}
}
}

7
tests/ImageSharp.Benchmarks/Color/RgbToYCbCr.LookupTables.cs

@ -1,4 +1,7 @@
namespace SixLabors.ImageSharp.Benchmarks
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
namespace SixLabors.ImageSharp.Benchmarks
{
public partial class RgbToYCbCr
{
@ -234,4 +237,4 @@
};
}
}
}
}

11
tests/ImageSharp.Benchmarks/Color/RgbToYCbCr.cs

@ -98,6 +98,7 @@ namespace SixLabors.ImageSharp.Benchmarks
{
result.Data[i] = data[i];
}
return result;
}
}
@ -125,6 +126,7 @@ namespace SixLabors.ImageSharp.Benchmarks
{
this.inputSourceRGB[i] = (byte)(42 + i);
}
this.inputSourceRGBAsInteger = new int[InputByteCount + Vector<int>.Count]; // Filling this should be part of the measured operation
}
@ -139,7 +141,6 @@ namespace SixLabors.ImageSharp.Benchmarks
var yPtr = (float*)&result.Y;
var cbPtr = (float*)&result.Cb;
var crPtr = (float*)&result.Cr;
// end of code-bloat block :)
for (int i = 0; i < InputColorCount; i++)
{
@ -165,7 +166,6 @@ namespace SixLabors.ImageSharp.Benchmarks
var yPtr = (float*)&result.Y;
var cbPtr = (float*)&result.Cb;
var crPtr = (float*)&result.Cr;
// end of code-bloat block :)
for (int i = 0; i < InputColorCount; i++)
{
@ -174,8 +174,7 @@ namespace SixLabors.ImageSharp.Benchmarks
var vectorRgb = new Vector3(
input.Data[i3 + 0],
input.Data[i3 + 1],
input.Data[i3 + 2]
);
input.Data[i3 + 2]);
Vector3 vectorY = VectorY * vectorRgb;
Vector3 vectorCb = VectorCb * vectorRgb;
@ -197,7 +196,6 @@ namespace SixLabors.ImageSharp.Benchmarks
var yPtr = (float*)&result.Y;
var cbPtr = (float*)&result.Cb;
var crPtr = (float*)&result.Cr;
// end of code-bloat block :)
var yCoeffs = new Vector<int>(ScaledCoeffs.Y);
var cbCoeffs = new Vector<int>(ScaledCoeffs.Cb);
@ -243,7 +241,6 @@ namespace SixLabors.ImageSharp.Benchmarks
float* yPtr = (float*)&result.Y;
float* cbPtr = (float*)&result.Cb;
float* crPtr = (float*)&result.Cr;
// end of code-bloat block :)
var yCoeffs = new Vector<int>(ScaledCoeffs.Y);
var cbCoeffs = new Vector<int>(ScaledCoeffs.Cb);
@ -306,7 +303,6 @@ namespace SixLabors.ImageSharp.Benchmarks
float* yPtr = (float*)&result.Y;
float* cbPtr = (float*)&result.Cb;
float* crPtr = (float*)&result.Cr;
// end of code-bloat block :)
for (int i = 0; i < InputColorCount; i++)
{
@ -345,7 +341,6 @@ namespace SixLabors.ImageSharp.Benchmarks
float* yPtr = (float*)&result.Y;
float* cbPtr = (float*)&result.Cb;
float* crPtr = (float*)&result.Cr;
// end of code-bloat block :)
for (int i = 0; i < InputColorCount; i++)
{

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save