Browse Source

Revised Unsafe.Add to avoid the sign-extending move

pull/2401/head
Günther Foidl 3 years ago
parent
commit
1920e28ed0
  1. 4
      src/ImageSharp/ColorSpaces/Companding/SRgbCompanding.cs
  2. 26
      src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLab.cs
  3. 26
      src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLch.cs
  4. 26
      src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLchuv.cs
  5. 26
      src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLuv.cs
  6. 26
      src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieXyy.cs
  7. 26
      src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieXyz.cs
  8. 26
      src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Cmyk.cs
  9. 26
      src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Hsl.cs
  10. 26
      src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Hsv.cs
  11. 26
      src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.HunterLab.cs
  12. 26
      src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.LinearRgb.cs
  13. 28
      src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Lms.cs
  14. 26
      src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Rgb.cs
  15. 24
      src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.YCbCr.cs
  16. 2
      src/ImageSharp/ColorSpaces/Conversion/Implementation/VonKriesChromaticAdaptation.cs
  17. 24
      src/ImageSharp/Common/Helpers/Numerics.cs
  18. 20
      src/ImageSharp/Common/Helpers/Shuffle/IComponentShuffle.cs
  19. 12
      src/ImageSharp/Common/Helpers/Shuffle/IPad3Shuffle4.cs
  20. 8
      src/ImageSharp/Common/Helpers/Shuffle/IShuffle3.cs
  21. 14
      src/ImageSharp/Common/Helpers/Shuffle/IShuffle4Slice3.cs
  22. 4
      src/ImageSharp/Common/Helpers/SimdUtils.FallbackIntrinsics128.cs
  23. 4
      src/ImageSharp/Common/Helpers/SimdUtils.HwIntrinsics.cs
  24. 18
      src/ImageSharp/Common/Helpers/SimdUtils.Pack.cs
  25. 18
      src/ImageSharp/Common/Helpers/SimdUtils.Shuffle.cs
  26. 2
      src/ImageSharp/Compression/Zlib/Crc32.cs
  27. 94
      src/ImageSharp/Compression/Zlib/DeflaterHuffman.cs
  28. 8
      src/ImageSharp/Formats/Gif/GifDecoderCore.cs
  29. 2
      src/ImageSharp/Formats/Gif/GifEncoderCore.cs
  30. 38
      src/ImageSharp/Formats/Gif/LzwDecoder.cs
  31. 22
      src/ImageSharp/Formats/Gif/LzwEncoder.cs
  32. 10
      src/ImageSharp/Formats/Jpeg/Components/Block8x8.cs
  33. 18
      src/ImageSharp/Formats/Jpeg/Components/Block8x8F.Generated.cs
  34. 6
      src/ImageSharp/Formats/Jpeg/Components/Block8x8F.Intrinsic.cs
  35. 12
      src/ImageSharp/Formats/Jpeg/Components/Block8x8F.ScaledCopy.cs
  36. 2
      src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.GrayScaleScalar.cs
  37. 4
      src/ImageSharp/Formats/Jpeg/Components/Decoder/ArithmeticScanDecoder.cs
  38. 12
      src/ImageSharp/Formats/Jpeg/Components/Decoder/HuffmanScanDecoder.cs
  39. 12
      src/ImageSharp/Formats/Jpeg/Components/Encoder/ComponentProcessor.cs
  40. 4
      src/ImageSharp/Formats/Jpeg/Components/Encoder/HuffmanScanEncoder.cs
  41. 16
      src/ImageSharp/Formats/Png/Filters/AverageFilter.cs
  42. 12
      src/ImageSharp/Formats/Png/Filters/PaethFilter.cs
  43. 14
      src/ImageSharp/Formats/Png/Filters/SubFilter.cs
  44. 14
      src/ImageSharp/Formats/Png/Filters/UpFilter.cs
  45. 4
      src/ImageSharp/Formats/Png/PngDecoderCore.cs
  46. 14
      src/ImageSharp/Formats/Png/PngEncoderCore.cs
  47. 6
      src/ImageSharp/Formats/Png/PngEncoderHelpers.cs
  48. 110
      src/ImageSharp/Formats/Png/PngScanlineProcessor.cs
  49. 2
      src/ImageSharp/Formats/Tiff/Compression/Decompressors/T6TiffCompression.cs
  50. 6
      src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZero1TiffColor{TPixel}.cs
  51. 6
      src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero1TiffColor{TPixel}.cs
  52. 11
      src/ImageSharp/Formats/Webp/AlphaDecoder.cs
  53. 22
      src/ImageSharp/Formats/Webp/Lossless/LosslessUtils.cs
  54. 29
      src/ImageSharp/Formats/Webp/Lossless/Vp8LHistogram.cs
  55. 114
      src/ImageSharp/Formats/Webp/Lossy/LossyUtils.cs
  56. 2
      src/ImageSharp/Formats/Webp/Lossy/QuantEnc.cs
  57. 8
      src/ImageSharp/Formats/Webp/Lossy/YuvConversion.cs
  58. 2
      src/ImageSharp/Memory/Allocators/Internals/ManagedBufferBase.cs
  59. 2
      src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroup{T}.cs
  60. 432
      src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.cs
  61. 4
      src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.tt
  62. 2
      src/ImageSharp/PixelFormats/PixelImplementations/Abgr32.cs
  63. 2
      src/ImageSharp/PixelFormats/PixelImplementations/Bgr24.cs
  64. 14
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Abgr32.PixelOperations.Generated.cs
  65. 14
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Argb32.PixelOperations.Generated.cs
  66. 14
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Bgr24.PixelOperations.Generated.cs
  67. 14
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Bgra32.PixelOperations.Generated.cs
  68. 24
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Bgra5551.PixelOperations.Generated.cs
  69. 24
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/L16.PixelOperations.Generated.cs
  70. 24
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/L8.PixelOperations.Generated.cs
  71. 6
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/La16.PixelOperations.Generated.cs
  72. 14
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Rgb24.PixelOperations.Generated.cs
  73. 24
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Rgb48.PixelOperations.Generated.cs
  74. 2
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/_Common.ttinclude
  75. 4
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/RgbaVector.PixelOperations.cs
  76. 52
      src/ImageSharp/PixelFormats/PixelOperations{TPixel}.Generated.cs
  77. 4
      src/ImageSharp/PixelFormats/PixelOperations{TPixel}.Generated.tt
  78. 4
      src/ImageSharp/PixelFormats/PixelOperations{TPixel}.cs
  79. 10
      src/ImageSharp/PixelFormats/Utils/Vector4Converters.Default.cs
  80. 6
      src/ImageSharp/Processing/Processors/Convolution/BokehBlurProcessor.cs
  81. 16
      src/ImageSharp/Processing/Processors/Convolution/BokehBlurProcessor{TPixel}.cs
  82. 30
      src/ImageSharp/Processing/Processors/Convolution/Convolution2DRowOperation{TPixel}.cs
  83. 4
      src/ImageSharp/Processing/Processors/Convolution/Convolution2DState.cs
  84. 30
      src/ImageSharp/Processing/Processors/Convolution/Convolution2PassProcessor{TPixel}.cs
  85. 20
      src/ImageSharp/Processing/Processors/Convolution/ConvolutionProcessor{TPixel}.cs
  86. 4
      src/ImageSharp/Processing/Processors/Convolution/ConvolutionState.cs
  87. 4
      src/ImageSharp/Processing/Processors/Convolution/EdgeDetectorCompassProcessor{TPixel}.cs
  88. 6
      src/ImageSharp/Processing/Processors/Convolution/Kernel.cs
  89. 2
      src/ImageSharp/Processing/Processors/Convolution/KernelSamplingMap.cs
  90. 4
      src/ImageSharp/Processing/Processors/Convolution/MedianConvolutionState.cs
  91. 14
      src/ImageSharp/Processing/Processors/Convolution/MedianRowOperation{TPixel}.cs
  92. 16
      src/ImageSharp/Processing/Processors/Convolution/Parameters/BokehBlurKernelDataProvider.cs
  93. 2
      src/ImageSharp/Processing/Processors/Convolution/ReadOnlyKernel.cs
  94. 6
      src/ImageSharp/Processing/Processors/Dithering/ErrorDither.cs
  95. 24
      src/ImageSharp/Processing/Processors/Effects/OilPaintingProcessor{TPixel}.cs
  96. 2
      src/ImageSharp/Processing/Processors/Filters/OpaqueProcessor{TPixel}.cs
  97. 10
      src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationSlidingWindowProcessor{TPixel}.cs
  98. 10
      src/ImageSharp/Processing/Processors/Normalization/AutoLevelProcessor{TPixel}.cs
  99. 6
      src/ImageSharp/Processing/Processors/Normalization/GlobalHistogramEqualizationProcessor{TPixel}.cs
  100. 4
      src/ImageSharp/Processing/Processors/Normalization/GrayscaleLevelsRowOperation{TPixel}.cs

4
src/ImageSharp/ColorSpaces/Companding/SRgbCompanding.cs

@ -175,7 +175,7 @@ public static class SRgbCompanding
// Divide by 2 as 4 elements per Vector4 and 8 per Vector256<float>
ref Vector256<float> vectorsBase = ref Unsafe.As<Vector4, Vector256<float>>(ref MemoryMarshal.GetReference(vectors));
ref Vector256<float> vectorsLast = ref Unsafe.Add(ref vectorsBase, (IntPtr)((uint)vectors.Length / 2u));
ref Vector256<float> vectorsLast = ref Unsafe.Add(ref vectorsBase, (uint)vectors.Length / 2u);
while (Unsafe.IsAddressLessThan(ref vectorsBase, ref vectorsLast))
{
@ -204,7 +204,7 @@ public static class SRgbCompanding
Vector4 zero = Vector4.Zero;
var scale = new Vector4(Scale);
ref Vector4 vectorsBase = ref MemoryMarshal.GetReference(vectors);
ref Vector4 vectorsLast = ref Unsafe.Add(ref vectorsBase, vectors.Length);
ref Vector4 vectorsLast = ref Unsafe.Add(ref vectorsBase, (uint)vectors.Length);
while (Unsafe.IsAddressLessThan(ref vectorsBase, ref vectorsLast))
{

26
src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLab.cs

@ -37,7 +37,7 @@ public partial class ColorSpaceConverter
ref CieLch sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLab destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref CieLch sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLab dp = ref Unsafe.Add(ref destRef, i);
@ -70,7 +70,7 @@ public partial class ColorSpaceConverter
ref CieLchuv sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLab destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref CieLchuv sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLab dp = ref Unsafe.Add(ref destRef, i);
@ -103,7 +103,7 @@ public partial class ColorSpaceConverter
ref CieLuv sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLab destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref CieLuv sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLab dp = ref Unsafe.Add(ref destRef, i);
@ -136,7 +136,7 @@ public partial class ColorSpaceConverter
ref CieXyy sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLab destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref CieXyy sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLab dp = ref Unsafe.Add(ref destRef, i);
@ -169,7 +169,7 @@ public partial class ColorSpaceConverter
ref CieXyz sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLab destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref CieXyz sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLab dp = ref Unsafe.Add(ref destRef, i);
@ -201,7 +201,7 @@ public partial class ColorSpaceConverter
ref Cmyk sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLab destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref Cmyk sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLab dp = ref Unsafe.Add(ref destRef, i);
@ -234,7 +234,7 @@ public partial class ColorSpaceConverter
ref Hsl sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLab destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref Hsl sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLab dp = ref Unsafe.Add(ref destRef, i);
@ -266,7 +266,7 @@ public partial class ColorSpaceConverter
ref Hsv sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLab destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref Hsv sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLab dp = ref Unsafe.Add(ref destRef, i);
@ -299,7 +299,7 @@ public partial class ColorSpaceConverter
ref HunterLab sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLab destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref HunterLab sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLab dp = ref Unsafe.Add(ref destRef, i);
@ -332,7 +332,7 @@ public partial class ColorSpaceConverter
ref Lms sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLab destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref Lms sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLab dp = ref Unsafe.Add(ref destRef, i);
@ -365,7 +365,7 @@ public partial class ColorSpaceConverter
ref LinearRgb sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLab destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref LinearRgb sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLab dp = ref Unsafe.Add(ref destRef, i);
@ -398,7 +398,7 @@ public partial class ColorSpaceConverter
ref Rgb sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLab destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref Rgb sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLab dp = ref Unsafe.Add(ref destRef, i);
@ -431,7 +431,7 @@ public partial class ColorSpaceConverter
ref YCbCr sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLab destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref YCbCr sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLab dp = ref Unsafe.Add(ref destRef, i);

26
src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLch.cs

@ -36,7 +36,7 @@ public partial class ColorSpaceConverter
ref CieLab sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLch destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref CieLab sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLch dp = ref Unsafe.Add(ref destRef, i);
@ -69,7 +69,7 @@ public partial class ColorSpaceConverter
ref CieLchuv sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLch destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref CieLchuv sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLch dp = ref Unsafe.Add(ref destRef, i);
@ -102,7 +102,7 @@ public partial class ColorSpaceConverter
ref CieLuv sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLch destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref CieLuv sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLch dp = ref Unsafe.Add(ref destRef, i);
@ -135,7 +135,7 @@ public partial class ColorSpaceConverter
ref CieXyy sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLch destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref CieXyy sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLch dp = ref Unsafe.Add(ref destRef, i);
@ -168,7 +168,7 @@ public partial class ColorSpaceConverter
ref CieXyz sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLch destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref CieXyz sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLch dp = ref Unsafe.Add(ref destRef, i);
@ -200,7 +200,7 @@ public partial class ColorSpaceConverter
ref Cmyk sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLch destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref Cmyk sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLch dp = ref Unsafe.Add(ref destRef, i);
@ -233,7 +233,7 @@ public partial class ColorSpaceConverter
ref Hsl sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLch destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref Hsl sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLch dp = ref Unsafe.Add(ref destRef, i);
@ -266,7 +266,7 @@ public partial class ColorSpaceConverter
ref Hsv sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLch destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref Hsv sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLch dp = ref Unsafe.Add(ref destRef, i);
@ -299,7 +299,7 @@ public partial class ColorSpaceConverter
ref HunterLab sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLch destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref HunterLab sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLch dp = ref Unsafe.Add(ref destRef, i);
@ -332,7 +332,7 @@ public partial class ColorSpaceConverter
ref LinearRgb sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLch destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref LinearRgb sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLch dp = ref Unsafe.Add(ref destRef, i);
@ -365,7 +365,7 @@ public partial class ColorSpaceConverter
ref Lms sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLch destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref Lms sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLch dp = ref Unsafe.Add(ref destRef, i);
@ -398,7 +398,7 @@ public partial class ColorSpaceConverter
ref Rgb sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLch destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref Rgb sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLch dp = ref Unsafe.Add(ref destRef, i);
@ -431,7 +431,7 @@ public partial class ColorSpaceConverter
ref YCbCr sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLch destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref YCbCr sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLch dp = ref Unsafe.Add(ref destRef, i);

26
src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLchuv.cs

@ -36,7 +36,7 @@ public partial class ColorSpaceConverter
ref CieLab sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref CieLab sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLchuv dp = ref Unsafe.Add(ref destRef, i);
@ -69,7 +69,7 @@ public partial class ColorSpaceConverter
ref CieLch sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref CieLch sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLchuv dp = ref Unsafe.Add(ref destRef, i);
@ -102,7 +102,7 @@ public partial class ColorSpaceConverter
ref CieLuv sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref CieLuv sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLchuv dp = ref Unsafe.Add(ref destRef, i);
@ -135,7 +135,7 @@ public partial class ColorSpaceConverter
ref CieXyy sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref CieXyy sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLchuv dp = ref Unsafe.Add(ref destRef, i);
@ -168,7 +168,7 @@ public partial class ColorSpaceConverter
ref CieXyz sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref CieXyz sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLchuv dp = ref Unsafe.Add(ref destRef, i);
@ -201,7 +201,7 @@ public partial class ColorSpaceConverter
ref Cmyk sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref Cmyk sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLchuv dp = ref Unsafe.Add(ref destRef, i);
@ -234,7 +234,7 @@ public partial class ColorSpaceConverter
ref Hsl sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref Hsl sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLchuv dp = ref Unsafe.Add(ref destRef, i);
@ -267,7 +267,7 @@ public partial class ColorSpaceConverter
ref Hsv sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref Hsv sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLchuv dp = ref Unsafe.Add(ref destRef, i);
@ -300,7 +300,7 @@ public partial class ColorSpaceConverter
ref HunterLab sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref HunterLab sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLchuv dp = ref Unsafe.Add(ref destRef, i);
@ -333,7 +333,7 @@ public partial class ColorSpaceConverter
ref LinearRgb sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref LinearRgb sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLchuv dp = ref Unsafe.Add(ref destRef, i);
@ -366,7 +366,7 @@ public partial class ColorSpaceConverter
ref Lms sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref Lms sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLchuv dp = ref Unsafe.Add(ref destRef, i);
@ -399,7 +399,7 @@ public partial class ColorSpaceConverter
ref Rgb sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref Rgb sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLchuv dp = ref Unsafe.Add(ref destRef, i);
@ -431,7 +431,7 @@ public partial class ColorSpaceConverter
ref YCbCr sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref YCbCr sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLchuv dp = ref Unsafe.Add(ref destRef, i);

26
src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLuv.cs

@ -35,7 +35,7 @@ public partial class ColorSpaceConverter
ref CieLab sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLuv destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref CieLab sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLuv dp = ref Unsafe.Add(ref destRef, i);
@ -67,7 +67,7 @@ public partial class ColorSpaceConverter
ref CieLch sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLuv destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref CieLch sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLuv dp = ref Unsafe.Add(ref destRef, i);
@ -102,7 +102,7 @@ public partial class ColorSpaceConverter
ref CieLchuv sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLuv destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref CieLchuv sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLuv dp = ref Unsafe.Add(ref destRef, i);
@ -134,7 +134,7 @@ public partial class ColorSpaceConverter
ref CieXyy sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLuv destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref CieXyy sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLuv dp = ref Unsafe.Add(ref destRef, i);
@ -169,7 +169,7 @@ public partial class ColorSpaceConverter
ref CieXyz sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLuv destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref CieXyz sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLuv dp = ref Unsafe.Add(ref destRef, i);
@ -201,7 +201,7 @@ public partial class ColorSpaceConverter
ref Cmyk sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLuv destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref Cmyk sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLuv dp = ref Unsafe.Add(ref destRef, i);
@ -233,7 +233,7 @@ public partial class ColorSpaceConverter
ref Hsl sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLuv destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref Hsl sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLuv dp = ref Unsafe.Add(ref destRef, i);
@ -265,7 +265,7 @@ public partial class ColorSpaceConverter
ref Hsv sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLuv destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref Hsv sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLuv dp = ref Unsafe.Add(ref destRef, i);
@ -297,7 +297,7 @@ public partial class ColorSpaceConverter
ref HunterLab sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLuv destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref HunterLab sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLuv dp = ref Unsafe.Add(ref destRef, i);
@ -329,7 +329,7 @@ public partial class ColorSpaceConverter
ref Lms sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLuv destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref Lms sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLuv dp = ref Unsafe.Add(ref destRef, i);
@ -361,7 +361,7 @@ public partial class ColorSpaceConverter
ref LinearRgb sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLuv destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref LinearRgb sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLuv dp = ref Unsafe.Add(ref destRef, i);
@ -393,7 +393,7 @@ public partial class ColorSpaceConverter
ref Rgb sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLuv destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref Rgb sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLuv dp = ref Unsafe.Add(ref destRef, i);
@ -425,7 +425,7 @@ public partial class ColorSpaceConverter
ref YCbCr sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLuv destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref YCbCr sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLuv dp = ref Unsafe.Add(ref destRef, i);

26
src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieXyy.cs

@ -36,7 +36,7 @@ public partial class ColorSpaceConverter
ref CieLab sourceRef = ref MemoryMarshal.GetReference(source);
ref CieXyy destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref CieLab sp = ref Unsafe.Add(ref sourceRef, i);
ref CieXyy dp = ref Unsafe.Add(ref destRef, i);
@ -69,7 +69,7 @@ public partial class ColorSpaceConverter
ref CieLch sourceRef = ref MemoryMarshal.GetReference(source);
ref CieXyy destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref CieLch sp = ref Unsafe.Add(ref sourceRef, i);
ref CieXyy dp = ref Unsafe.Add(ref destRef, i);
@ -102,7 +102,7 @@ public partial class ColorSpaceConverter
ref CieLchuv sourceRef = ref MemoryMarshal.GetReference(source);
ref CieXyy destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref CieLchuv sp = ref Unsafe.Add(ref sourceRef, i);
ref CieXyy dp = ref Unsafe.Add(ref destRef, i);
@ -135,7 +135,7 @@ public partial class ColorSpaceConverter
ref CieLuv sourceRef = ref MemoryMarshal.GetReference(source);
ref CieXyy destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref CieLuv sp = ref Unsafe.Add(ref sourceRef, i);
ref CieXyy dp = ref Unsafe.Add(ref destRef, i);
@ -163,7 +163,7 @@ public partial class ColorSpaceConverter
ref CieXyz sourceRef = ref MemoryMarshal.GetReference(source);
ref CieXyy destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref CieXyz sp = ref Unsafe.Add(ref sourceRef, i);
ref CieXyy dp = ref Unsafe.Add(ref destRef, i);
@ -196,7 +196,7 @@ public partial class ColorSpaceConverter
ref Cmyk sourceRef = ref MemoryMarshal.GetReference(source);
ref CieXyy destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref Cmyk sp = ref Unsafe.Add(ref sourceRef, i);
ref CieXyy dp = ref Unsafe.Add(ref destRef, i);
@ -229,7 +229,7 @@ public partial class ColorSpaceConverter
ref Hsl sourceRef = ref MemoryMarshal.GetReference(source);
ref CieXyy destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref Hsl sp = ref Unsafe.Add(ref sourceRef, i);
ref CieXyy dp = ref Unsafe.Add(ref destRef, i);
@ -262,7 +262,7 @@ public partial class ColorSpaceConverter
ref Hsv sourceRef = ref MemoryMarshal.GetReference(source);
ref CieXyy destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref Hsv sp = ref Unsafe.Add(ref sourceRef, i);
ref CieXyy dp = ref Unsafe.Add(ref destRef, i);
@ -295,7 +295,7 @@ public partial class ColorSpaceConverter
ref HunterLab sourceRef = ref MemoryMarshal.GetReference(source);
ref CieXyy destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref HunterLab sp = ref Unsafe.Add(ref sourceRef, i);
ref CieXyy dp = ref Unsafe.Add(ref destRef, i);
@ -328,7 +328,7 @@ public partial class ColorSpaceConverter
ref LinearRgb sourceRef = ref MemoryMarshal.GetReference(source);
ref CieXyy destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref LinearRgb sp = ref Unsafe.Add(ref sourceRef, i);
ref CieXyy dp = ref Unsafe.Add(ref destRef, i);
@ -361,7 +361,7 @@ public partial class ColorSpaceConverter
ref Lms sourceRef = ref MemoryMarshal.GetReference(source);
ref CieXyy destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref Lms sp = ref Unsafe.Add(ref sourceRef, i);
ref CieXyy dp = ref Unsafe.Add(ref destRef, i);
@ -394,7 +394,7 @@ public partial class ColorSpaceConverter
ref Rgb sourceRef = ref MemoryMarshal.GetReference(source);
ref CieXyy destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref Rgb sp = ref Unsafe.Add(ref sourceRef, i);
ref CieXyy dp = ref Unsafe.Add(ref destRef, i);
@ -427,7 +427,7 @@ public partial class ColorSpaceConverter
ref YCbCr sourceRef = ref MemoryMarshal.GetReference(source);
ref CieXyy destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref YCbCr sp = ref Unsafe.Add(ref sourceRef, i);
ref CieXyy dp = ref Unsafe.Add(ref destRef, i);

26
src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieXyz.cs

@ -41,7 +41,7 @@ public partial class ColorSpaceConverter
ref CieLab sourceRef = ref MemoryMarshal.GetReference(source);
ref CieXyz destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref CieLab sp = ref Unsafe.Add(ref sourceRef, i);
ref CieXyz dp = ref Unsafe.Add(ref destRef, i);
@ -76,7 +76,7 @@ public partial class ColorSpaceConverter
ref CieLch sourceRef = ref MemoryMarshal.GetReference(source);
ref CieXyz destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref CieLch sp = ref Unsafe.Add(ref sourceRef, i);
ref CieXyz dp = ref Unsafe.Add(ref destRef, i);
@ -111,7 +111,7 @@ public partial class ColorSpaceConverter
ref CieLchuv sourceRef = ref MemoryMarshal.GetReference(source);
ref CieXyz destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref CieLchuv sp = ref Unsafe.Add(ref sourceRef, i);
ref CieXyz dp = ref Unsafe.Add(ref destRef, i);
@ -146,7 +146,7 @@ public partial class ColorSpaceConverter
ref CieLuv sourceRef = ref MemoryMarshal.GetReference(source);
ref CieXyz destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref CieLuv sp = ref Unsafe.Add(ref sourceRef, i);
ref CieXyz dp = ref Unsafe.Add(ref destRef, i);
@ -177,7 +177,7 @@ public partial class ColorSpaceConverter
ref CieXyy sourceRef = ref MemoryMarshal.GetReference(source);
ref CieXyz destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref CieXyy sp = ref Unsafe.Add(ref sourceRef, i);
ref CieXyz dp = ref Unsafe.Add(ref destRef, i);
@ -210,7 +210,7 @@ public partial class ColorSpaceConverter
ref Cmyk sourceRef = ref MemoryMarshal.GetReference(source);
ref CieXyz destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref Cmyk sp = ref Unsafe.Add(ref sourceRef, i);
ref CieXyz dp = ref Unsafe.Add(ref destRef, i);
@ -243,7 +243,7 @@ public partial class ColorSpaceConverter
ref Hsl sourceRef = ref MemoryMarshal.GetReference(source);
ref CieXyz destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref Hsl sp = ref Unsafe.Add(ref sourceRef, i);
ref CieXyz dp = ref Unsafe.Add(ref destRef, i);
@ -277,7 +277,7 @@ public partial class ColorSpaceConverter
ref Hsv sourceRef = ref MemoryMarshal.GetReference(source);
ref CieXyz destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref Hsv sp = ref Unsafe.Add(ref sourceRef, i);
ref CieXyz dp = ref Unsafe.Add(ref destRef, i);
@ -310,7 +310,7 @@ public partial class ColorSpaceConverter
ref HunterLab sourceRef = ref MemoryMarshal.GetReference(source);
ref CieXyz destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref HunterLab sp = ref Unsafe.Add(ref sourceRef, i);
ref CieXyz dp = ref Unsafe.Add(ref destRef, i);
@ -345,7 +345,7 @@ public partial class ColorSpaceConverter
ref LinearRgb sourceRef = ref MemoryMarshal.GetReference(source);
ref CieXyz destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref LinearRgb sp = ref Unsafe.Add(ref sourceRef, i);
ref CieXyz dp = ref Unsafe.Add(ref destRef, i);
@ -374,7 +374,7 @@ public partial class ColorSpaceConverter
ref Lms sourceRef = ref MemoryMarshal.GetReference(source);
ref CieXyz destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref Lms sp = ref Unsafe.Add(ref sourceRef, i);
ref CieXyz dp = ref Unsafe.Add(ref destRef, i);
@ -407,7 +407,7 @@ public partial class ColorSpaceConverter
ref Rgb sourceRef = ref MemoryMarshal.GetReference(source);
ref CieXyz destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref Rgb sp = ref Unsafe.Add(ref sourceRef, i);
ref CieXyz dp = ref Unsafe.Add(ref destRef, i);
@ -440,7 +440,7 @@ public partial class ColorSpaceConverter
ref YCbCr sourceRef = ref MemoryMarshal.GetReference(source);
ref CieXyz destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref YCbCr sp = ref Unsafe.Add(ref sourceRef, i);
ref CieXyz dp = ref Unsafe.Add(ref destRef, i);

26
src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Cmyk.cs

@ -36,7 +36,7 @@ public partial class ColorSpaceConverter
ref CieLab sourceRef = ref MemoryMarshal.GetReference(source);
ref Cmyk destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref CieLab sp = ref Unsafe.Add(ref sourceRef, i);
ref Cmyk dp = ref Unsafe.Add(ref destRef, i);
@ -69,7 +69,7 @@ public partial class ColorSpaceConverter
ref CieLch sourceRef = ref MemoryMarshal.GetReference(source);
ref Cmyk destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref CieLch sp = ref Unsafe.Add(ref sourceRef, i);
ref Cmyk dp = ref Unsafe.Add(ref destRef, i);
@ -102,7 +102,7 @@ public partial class ColorSpaceConverter
ref CieLchuv sourceRef = ref MemoryMarshal.GetReference(source);
ref Cmyk destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref CieLchuv sp = ref Unsafe.Add(ref sourceRef, i);
ref Cmyk dp = ref Unsafe.Add(ref destRef, i);
@ -135,7 +135,7 @@ public partial class ColorSpaceConverter
ref CieLuv sourceRef = ref MemoryMarshal.GetReference(source);
ref Cmyk destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref CieLuv sp = ref Unsafe.Add(ref sourceRef, i);
ref Cmyk dp = ref Unsafe.Add(ref destRef, i);
@ -168,7 +168,7 @@ public partial class ColorSpaceConverter
ref CieXyy sourceRef = ref MemoryMarshal.GetReference(source);
ref Cmyk destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref CieXyy sp = ref Unsafe.Add(ref sourceRef, i);
ref Cmyk dp = ref Unsafe.Add(ref destRef, i);
@ -201,7 +201,7 @@ public partial class ColorSpaceConverter
ref CieXyz sourceRef = ref MemoryMarshal.GetReference(source);
ref Cmyk destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref CieXyz sp = ref Unsafe.Add(ref sourceRef, i);
ref Cmyk dp = ref Unsafe.Add(ref destRef, i);
@ -234,7 +234,7 @@ public partial class ColorSpaceConverter
ref Hsl sourceRef = ref MemoryMarshal.GetReference(source);
ref Cmyk destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref Hsl sp = ref Unsafe.Add(ref sourceRef, i);
ref Cmyk dp = ref Unsafe.Add(ref destRef, i);
@ -267,7 +267,7 @@ public partial class ColorSpaceConverter
ref Hsv sourceRef = ref MemoryMarshal.GetReference(source);
ref Cmyk destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref Hsv sp = ref Unsafe.Add(ref sourceRef, i);
ref Cmyk dp = ref Unsafe.Add(ref destRef, i);
@ -300,7 +300,7 @@ public partial class ColorSpaceConverter
ref HunterLab sourceRef = ref MemoryMarshal.GetReference(source);
ref Cmyk destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref HunterLab sp = ref Unsafe.Add(ref sourceRef, i);
ref Cmyk dp = ref Unsafe.Add(ref destRef, i);
@ -333,7 +333,7 @@ public partial class ColorSpaceConverter
ref LinearRgb sourceRef = ref MemoryMarshal.GetReference(source);
ref Cmyk destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref LinearRgb sp = ref Unsafe.Add(ref sourceRef, i);
ref Cmyk dp = ref Unsafe.Add(ref destRef, i);
@ -366,7 +366,7 @@ public partial class ColorSpaceConverter
ref Lms sourceRef = ref MemoryMarshal.GetReference(source);
ref Cmyk destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref Lms sp = ref Unsafe.Add(ref sourceRef, i);
ref Cmyk dp = ref Unsafe.Add(ref destRef, i);
@ -394,7 +394,7 @@ public partial class ColorSpaceConverter
ref Rgb sourceRef = ref MemoryMarshal.GetReference(source);
ref Cmyk destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref Rgb sp = ref Unsafe.Add(ref sourceRef, i);
ref Cmyk dp = ref Unsafe.Add(ref destRef, i);
@ -427,7 +427,7 @@ public partial class ColorSpaceConverter
ref YCbCr sourceRef = ref MemoryMarshal.GetReference(source);
ref Cmyk destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref YCbCr sp = ref Unsafe.Add(ref sourceRef, i);
ref Cmyk dp = ref Unsafe.Add(ref destRef, i);

26
src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Hsl.cs

@ -36,7 +36,7 @@ public partial class ColorSpaceConverter
ref CieLab sourceRef = ref MemoryMarshal.GetReference(source);
ref Hsl destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref CieLab sp = ref Unsafe.Add(ref sourceRef, i);
ref Hsl dp = ref Unsafe.Add(ref destRef, i);
@ -69,7 +69,7 @@ public partial class ColorSpaceConverter
ref CieLch sourceRef = ref MemoryMarshal.GetReference(source);
ref Hsl destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref CieLch sp = ref Unsafe.Add(ref sourceRef, i);
ref Hsl dp = ref Unsafe.Add(ref destRef, i);
@ -102,7 +102,7 @@ public partial class ColorSpaceConverter
ref CieLchuv sourceRef = ref MemoryMarshal.GetReference(source);
ref Hsl destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref CieLchuv sp = ref Unsafe.Add(ref sourceRef, i);
ref Hsl dp = ref Unsafe.Add(ref destRef, i);
@ -135,7 +135,7 @@ public partial class ColorSpaceConverter
ref CieLuv sourceRef = ref MemoryMarshal.GetReference(source);
ref Hsl destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref CieLuv sp = ref Unsafe.Add(ref sourceRef, i);
ref Hsl dp = ref Unsafe.Add(ref destRef, i);
@ -168,7 +168,7 @@ public partial class ColorSpaceConverter
ref CieXyy sourceRef = ref MemoryMarshal.GetReference(source);
ref Hsl destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref CieXyy sp = ref Unsafe.Add(ref sourceRef, i);
ref Hsl dp = ref Unsafe.Add(ref destRef, i);
@ -201,7 +201,7 @@ public partial class ColorSpaceConverter
ref CieXyz sourceRef = ref MemoryMarshal.GetReference(source);
ref Hsl destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref CieXyz sp = ref Unsafe.Add(ref sourceRef, i);
ref Hsl dp = ref Unsafe.Add(ref destRef, i);
@ -234,7 +234,7 @@ public partial class ColorSpaceConverter
ref Cmyk sourceRef = ref MemoryMarshal.GetReference(source);
ref Hsl destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref Cmyk sp = ref Unsafe.Add(ref sourceRef, i);
ref Hsl dp = ref Unsafe.Add(ref destRef, i);
@ -267,7 +267,7 @@ public partial class ColorSpaceConverter
ref Hsv sourceRef = ref MemoryMarshal.GetReference(source);
ref Hsl destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref Hsv sp = ref Unsafe.Add(ref sourceRef, i);
ref Hsl dp = ref Unsafe.Add(ref destRef, i);
@ -300,7 +300,7 @@ public partial class ColorSpaceConverter
ref HunterLab sourceRef = ref MemoryMarshal.GetReference(source);
ref Hsl destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref HunterLab sp = ref Unsafe.Add(ref sourceRef, i);
ref Hsl dp = ref Unsafe.Add(ref destRef, i);
@ -333,7 +333,7 @@ public partial class ColorSpaceConverter
ref LinearRgb sourceRef = ref MemoryMarshal.GetReference(source);
ref Hsl destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref LinearRgb sp = ref Unsafe.Add(ref sourceRef, i);
ref Hsl dp = ref Unsafe.Add(ref destRef, i);
@ -366,7 +366,7 @@ public partial class ColorSpaceConverter
ref Lms sourceRef = ref MemoryMarshal.GetReference(source);
ref Hsl destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref Lms sp = ref Unsafe.Add(ref sourceRef, i);
ref Hsl dp = ref Unsafe.Add(ref destRef, i);
@ -394,7 +394,7 @@ public partial class ColorSpaceConverter
ref Rgb sourceRef = ref MemoryMarshal.GetReference(source);
ref Hsl destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref Rgb sp = ref Unsafe.Add(ref sourceRef, i);
ref Hsl dp = ref Unsafe.Add(ref destRef, i);
@ -427,7 +427,7 @@ public partial class ColorSpaceConverter
ref YCbCr sourceRef = ref MemoryMarshal.GetReference(source);
ref Hsl destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref YCbCr sp = ref Unsafe.Add(ref sourceRef, i);
ref Hsl dp = ref Unsafe.Add(ref destRef, i);

26
src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Hsv.cs

@ -36,7 +36,7 @@ public partial class ColorSpaceConverter
ref CieLab sourceRef = ref MemoryMarshal.GetReference(source);
ref Hsv destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref CieLab sp = ref Unsafe.Add(ref sourceRef, i);
ref Hsv dp = ref Unsafe.Add(ref destRef, i);
@ -69,7 +69,7 @@ public partial class ColorSpaceConverter
ref CieLch sourceRef = ref MemoryMarshal.GetReference(source);
ref Hsv destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref CieLch sp = ref Unsafe.Add(ref sourceRef, i);
ref Hsv dp = ref Unsafe.Add(ref destRef, i);
@ -102,7 +102,7 @@ public partial class ColorSpaceConverter
ref CieLchuv sourceRef = ref MemoryMarshal.GetReference(source);
ref Hsv destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref CieLchuv sp = ref Unsafe.Add(ref sourceRef, i);
ref Hsv dp = ref Unsafe.Add(ref destRef, i);
@ -135,7 +135,7 @@ public partial class ColorSpaceConverter
ref CieLuv sourceRef = ref MemoryMarshal.GetReference(source);
ref Hsv destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref CieLuv sp = ref Unsafe.Add(ref sourceRef, i);
ref Hsv dp = ref Unsafe.Add(ref destRef, i);
@ -168,7 +168,7 @@ public partial class ColorSpaceConverter
ref CieXyy sourceRef = ref MemoryMarshal.GetReference(source);
ref Hsv destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref CieXyy sp = ref Unsafe.Add(ref sourceRef, i);
ref Hsv dp = ref Unsafe.Add(ref destRef, i);
@ -201,7 +201,7 @@ public partial class ColorSpaceConverter
ref CieXyz sourceRef = ref MemoryMarshal.GetReference(source);
ref Hsv destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref CieXyz sp = ref Unsafe.Add(ref sourceRef, i);
ref Hsv dp = ref Unsafe.Add(ref destRef, i);
@ -234,7 +234,7 @@ public partial class ColorSpaceConverter
ref Cmyk sourceRef = ref MemoryMarshal.GetReference(source);
ref Hsv destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref Cmyk sp = ref Unsafe.Add(ref sourceRef, i);
ref Hsv dp = ref Unsafe.Add(ref destRef, i);
@ -267,7 +267,7 @@ public partial class ColorSpaceConverter
ref Hsl sourceRef = ref MemoryMarshal.GetReference(source);
ref Hsv destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref Hsl sp = ref Unsafe.Add(ref sourceRef, i);
ref Hsv dp = ref Unsafe.Add(ref destRef, i);
@ -300,7 +300,7 @@ public partial class ColorSpaceConverter
ref HunterLab sourceRef = ref MemoryMarshal.GetReference(source);
ref Hsv destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref HunterLab sp = ref Unsafe.Add(ref sourceRef, i);
ref Hsv dp = ref Unsafe.Add(ref destRef, i);
@ -333,7 +333,7 @@ public partial class ColorSpaceConverter
ref LinearRgb sourceRef = ref MemoryMarshal.GetReference(source);
ref Hsv destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref LinearRgb sp = ref Unsafe.Add(ref sourceRef, i);
ref Hsv dp = ref Unsafe.Add(ref destRef, i);
@ -366,7 +366,7 @@ public partial class ColorSpaceConverter
ref Lms sourceRef = ref MemoryMarshal.GetReference(source);
ref Hsv destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref Lms sp = ref Unsafe.Add(ref sourceRef, i);
ref Hsv dp = ref Unsafe.Add(ref destRef, i);
@ -394,7 +394,7 @@ public partial class ColorSpaceConverter
ref Rgb sourceRef = ref MemoryMarshal.GetReference(source);
ref Hsv destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref Rgb sp = ref Unsafe.Add(ref sourceRef, i);
ref Hsv dp = ref Unsafe.Add(ref destRef, i);
@ -427,7 +427,7 @@ public partial class ColorSpaceConverter
ref YCbCr sourceRef = ref MemoryMarshal.GetReference(source);
ref Hsv destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref YCbCr sp = ref Unsafe.Add(ref sourceRef, i);
ref Hsv dp = ref Unsafe.Add(ref destRef, i);

26
src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.HunterLab.cs

@ -24,7 +24,7 @@ public partial class ColorSpaceConverter
ref CieLab sourceRef = ref MemoryMarshal.GetReference(source);
ref HunterLab destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref CieLab sp = ref Unsafe.Add(ref sourceRef, i);
ref HunterLab dp = ref Unsafe.Add(ref destRef, i);
@ -45,7 +45,7 @@ public partial class ColorSpaceConverter
ref CieLch sourceRef = ref MemoryMarshal.GetReference(source);
ref HunterLab destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref CieLch sp = ref Unsafe.Add(ref sourceRef, i);
ref HunterLab dp = ref Unsafe.Add(ref destRef, i);
@ -66,7 +66,7 @@ public partial class ColorSpaceConverter
ref CieLchuv sourceRef = ref MemoryMarshal.GetReference(source);
ref HunterLab destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref CieLchuv sp = ref Unsafe.Add(ref sourceRef, i);
ref HunterLab dp = ref Unsafe.Add(ref destRef, i);
@ -87,7 +87,7 @@ public partial class ColorSpaceConverter
ref CieLuv sourceRef = ref MemoryMarshal.GetReference(source);
ref HunterLab destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref CieLuv sp = ref Unsafe.Add(ref sourceRef, i);
ref HunterLab dp = ref Unsafe.Add(ref destRef, i);
@ -108,7 +108,7 @@ public partial class ColorSpaceConverter
ref CieXyy sourceRef = ref MemoryMarshal.GetReference(source);
ref HunterLab destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref CieXyy sp = ref Unsafe.Add(ref sourceRef, i);
ref HunterLab dp = ref Unsafe.Add(ref destRef, i);
@ -129,7 +129,7 @@ public partial class ColorSpaceConverter
ref CieXyz sourceRef = ref MemoryMarshal.GetReference(source);
ref HunterLab destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref CieXyz sp = ref Unsafe.Add(ref sourceRef, i);
ref HunterLab dp = ref Unsafe.Add(ref destRef, i);
@ -150,7 +150,7 @@ public partial class ColorSpaceConverter
ref Cmyk sourceRef = ref MemoryMarshal.GetReference(source);
ref HunterLab destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref Cmyk sp = ref Unsafe.Add(ref sourceRef, i);
ref HunterLab dp = ref Unsafe.Add(ref destRef, i);
@ -171,7 +171,7 @@ public partial class ColorSpaceConverter
ref Hsl sourceRef = ref MemoryMarshal.GetReference(source);
ref HunterLab destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref Hsl sp = ref Unsafe.Add(ref sourceRef, i);
ref HunterLab dp = ref Unsafe.Add(ref destRef, i);
@ -192,7 +192,7 @@ public partial class ColorSpaceConverter
ref Hsv sourceRef = ref MemoryMarshal.GetReference(source);
ref HunterLab destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref Hsv sp = ref Unsafe.Add(ref sourceRef, i);
ref HunterLab dp = ref Unsafe.Add(ref destRef, i);
@ -213,7 +213,7 @@ public partial class ColorSpaceConverter
ref LinearRgb sourceRef = ref MemoryMarshal.GetReference(source);
ref HunterLab destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref LinearRgb sp = ref Unsafe.Add(ref sourceRef, i);
ref HunterLab dp = ref Unsafe.Add(ref destRef, i);
@ -234,7 +234,7 @@ public partial class ColorSpaceConverter
ref Lms sourceRef = ref MemoryMarshal.GetReference(source);
ref HunterLab destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref Lms sp = ref Unsafe.Add(ref sourceRef, i);
ref HunterLab dp = ref Unsafe.Add(ref destRef, i);
@ -255,7 +255,7 @@ public partial class ColorSpaceConverter
ref Rgb sourceRef = ref MemoryMarshal.GetReference(source);
ref HunterLab destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref Rgb sp = ref Unsafe.Add(ref sourceRef, i);
ref HunterLab dp = ref Unsafe.Add(ref destRef, i);
@ -276,7 +276,7 @@ public partial class ColorSpaceConverter
ref YCbCr sourceRef = ref MemoryMarshal.GetReference(source);
ref HunterLab destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref YCbCr sp = ref Unsafe.Add(ref sourceRef, i);
ref HunterLab dp = ref Unsafe.Add(ref destRef, i);

26
src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.LinearRgb.cs

@ -24,7 +24,7 @@ public partial class ColorSpaceConverter
ref CieLab sourceRef = ref MemoryMarshal.GetReference(source);
ref LinearRgb destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref CieLab sp = ref Unsafe.Add(ref sourceRef, i);
ref LinearRgb dp = ref Unsafe.Add(ref destRef, i);
@ -45,7 +45,7 @@ public partial class ColorSpaceConverter
ref CieLch sourceRef = ref MemoryMarshal.GetReference(source);
ref LinearRgb destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref CieLch sp = ref Unsafe.Add(ref sourceRef, i);
ref LinearRgb dp = ref Unsafe.Add(ref destRef, i);
@ -66,7 +66,7 @@ public partial class ColorSpaceConverter
ref CieLchuv sourceRef = ref MemoryMarshal.GetReference(source);
ref LinearRgb destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref CieLchuv sp = ref Unsafe.Add(ref sourceRef, i);
ref LinearRgb dp = ref Unsafe.Add(ref destRef, i);
@ -87,7 +87,7 @@ public partial class ColorSpaceConverter
ref CieLuv sourceRef = ref MemoryMarshal.GetReference(source);
ref LinearRgb destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref CieLuv sp = ref Unsafe.Add(ref sourceRef, i);
ref LinearRgb dp = ref Unsafe.Add(ref destRef, i);
@ -108,7 +108,7 @@ public partial class ColorSpaceConverter
ref CieXyy sourceRef = ref MemoryMarshal.GetReference(source);
ref LinearRgb destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref CieXyy sp = ref Unsafe.Add(ref sourceRef, i);
ref LinearRgb dp = ref Unsafe.Add(ref destRef, i);
@ -129,7 +129,7 @@ public partial class ColorSpaceConverter
ref CieXyz sourceRef = ref MemoryMarshal.GetReference(source);
ref LinearRgb destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref CieXyz sp = ref Unsafe.Add(ref sourceRef, i);
ref LinearRgb dp = ref Unsafe.Add(ref destRef, i);
@ -150,7 +150,7 @@ public partial class ColorSpaceConverter
ref Cmyk sourceRef = ref MemoryMarshal.GetReference(source);
ref LinearRgb destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref Cmyk sp = ref Unsafe.Add(ref sourceRef, i);
ref LinearRgb dp = ref Unsafe.Add(ref destRef, i);
@ -171,7 +171,7 @@ public partial class ColorSpaceConverter
ref Hsl sourceRef = ref MemoryMarshal.GetReference(source);
ref LinearRgb destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref Hsl sp = ref Unsafe.Add(ref sourceRef, i);
ref LinearRgb dp = ref Unsafe.Add(ref destRef, i);
@ -192,7 +192,7 @@ public partial class ColorSpaceConverter
ref Hsv sourceRef = ref MemoryMarshal.GetReference(source);
ref LinearRgb destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref Hsv sp = ref Unsafe.Add(ref sourceRef, i);
ref LinearRgb dp = ref Unsafe.Add(ref destRef, i);
@ -213,7 +213,7 @@ public partial class ColorSpaceConverter
ref HunterLab sourceRef = ref MemoryMarshal.GetReference(source);
ref LinearRgb destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref HunterLab sp = ref Unsafe.Add(ref sourceRef, i);
ref LinearRgb dp = ref Unsafe.Add(ref destRef, i);
@ -234,7 +234,7 @@ public partial class ColorSpaceConverter
ref Lms sourceRef = ref MemoryMarshal.GetReference(source);
ref LinearRgb destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref Lms sp = ref Unsafe.Add(ref sourceRef, i);
ref LinearRgb dp = ref Unsafe.Add(ref destRef, i);
@ -255,7 +255,7 @@ public partial class ColorSpaceConverter
ref Rgb sourceRef = ref MemoryMarshal.GetReference(source);
ref LinearRgb destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref Rgb sp = ref Unsafe.Add(ref sourceRef, i);
ref LinearRgb dp = ref Unsafe.Add(ref destRef, i);
@ -276,7 +276,7 @@ public partial class ColorSpaceConverter
ref YCbCr sourceRef = ref MemoryMarshal.GetReference(source);
ref LinearRgb destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref YCbCr sp = ref Unsafe.Add(ref sourceRef, i);
ref LinearRgb dp = ref Unsafe.Add(ref destRef, i);

28
src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Lms.cs

@ -1,4 +1,4 @@
// Copyright (c) Six Labors.
// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.
using System.Runtime.CompilerServices;
@ -24,7 +24,7 @@ public partial class ColorSpaceConverter
ref CieLab sourceRef = ref MemoryMarshal.GetReference(source);
ref Lms destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref CieLab sp = ref Unsafe.Add(ref sourceRef, i);
ref Lms dp = ref Unsafe.Add(ref destRef, i);
@ -45,7 +45,7 @@ public partial class ColorSpaceConverter
ref CieLch sourceRef = ref MemoryMarshal.GetReference(source);
ref Lms destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref CieLch sp = ref Unsafe.Add(ref sourceRef, i);
ref Lms dp = ref Unsafe.Add(ref destRef, i);
@ -66,7 +66,7 @@ public partial class ColorSpaceConverter
ref CieLchuv sourceRef = ref MemoryMarshal.GetReference(source);
ref Lms destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref CieLchuv sp = ref Unsafe.Add(ref sourceRef, i);
ref Lms dp = ref Unsafe.Add(ref destRef, i);
@ -87,7 +87,7 @@ public partial class ColorSpaceConverter
ref CieLuv sourceRef = ref MemoryMarshal.GetReference(source);
ref Lms destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref CieLuv sp = ref Unsafe.Add(ref sourceRef, i);
ref Lms dp = ref Unsafe.Add(ref destRef, i);
@ -108,7 +108,7 @@ public partial class ColorSpaceConverter
ref CieXyy sourceRef = ref MemoryMarshal.GetReference(source);
ref Lms destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref CieXyy sp = ref Unsafe.Add(ref sourceRef, i);
ref Lms dp = ref Unsafe.Add(ref destRef, i);
@ -129,7 +129,7 @@ public partial class ColorSpaceConverter
ref CieXyz sourceRef = ref MemoryMarshal.GetReference(source);
ref Lms destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref CieXyz sp = ref Unsafe.Add(ref sourceRef, i);
ref Lms dp = ref Unsafe.Add(ref destRef, i);
@ -150,7 +150,7 @@ public partial class ColorSpaceConverter
ref Cmyk sourceRef = ref MemoryMarshal.GetReference(source);
ref Lms destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref Cmyk sp = ref Unsafe.Add(ref sourceRef, i);
ref Lms dp = ref Unsafe.Add(ref destRef, i);
@ -171,7 +171,7 @@ public partial class ColorSpaceConverter
ref Hsl sourceRef = ref MemoryMarshal.GetReference(source);
ref Lms destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref Hsl sp = ref Unsafe.Add(ref sourceRef, i);
ref Lms dp = ref Unsafe.Add(ref destRef, i);
@ -192,7 +192,7 @@ public partial class ColorSpaceConverter
ref Hsv sourceRef = ref MemoryMarshal.GetReference(source);
ref Lms destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref Hsv sp = ref Unsafe.Add(ref sourceRef, i);
ref Lms dp = ref Unsafe.Add(ref destRef, i);
@ -213,7 +213,7 @@ public partial class ColorSpaceConverter
ref HunterLab sourceRef = ref MemoryMarshal.GetReference(source);
ref Lms destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref HunterLab sp = ref Unsafe.Add(ref sourceRef, i);
ref Lms dp = ref Unsafe.Add(ref destRef, i);
@ -234,7 +234,7 @@ public partial class ColorSpaceConverter
ref LinearRgb sourceRef = ref MemoryMarshal.GetReference(source);
ref Lms destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref LinearRgb sp = ref Unsafe.Add(ref sourceRef, i);
ref Lms dp = ref Unsafe.Add(ref destRef, i);
@ -255,7 +255,7 @@ public partial class ColorSpaceConverter
ref Rgb sourceRef = ref MemoryMarshal.GetReference(source);
ref Lms destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref Rgb sp = ref Unsafe.Add(ref sourceRef, i);
ref Lms dp = ref Unsafe.Add(ref destRef, i);
@ -276,7 +276,7 @@ public partial class ColorSpaceConverter
ref YCbCr sourceRef = ref MemoryMarshal.GetReference(source);
ref Lms destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref YCbCr sp = ref Unsafe.Add(ref sourceRef, i);
ref Lms dp = ref Unsafe.Add(ref destRef, i);

26
src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Rgb.cs

@ -24,7 +24,7 @@ public partial class ColorSpaceConverter
ref CieLab sourceRef = ref MemoryMarshal.GetReference(source);
ref Rgb destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref CieLab sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgb dp = ref Unsafe.Add(ref destRef, i);
@ -45,7 +45,7 @@ public partial class ColorSpaceConverter
ref CieLch sourceRef = ref MemoryMarshal.GetReference(source);
ref Rgb destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref CieLch sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgb dp = ref Unsafe.Add(ref destRef, i);
@ -66,7 +66,7 @@ public partial class ColorSpaceConverter
ref CieLchuv sourceRef = ref MemoryMarshal.GetReference(source);
ref Rgb destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref CieLchuv sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgb dp = ref Unsafe.Add(ref destRef, i);
@ -87,7 +87,7 @@ public partial class ColorSpaceConverter
ref CieLuv sourceRef = ref MemoryMarshal.GetReference(source);
ref Rgb destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref CieLuv sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgb dp = ref Unsafe.Add(ref destRef, i);
@ -108,7 +108,7 @@ public partial class ColorSpaceConverter
ref CieXyy sourceRef = ref MemoryMarshal.GetReference(source);
ref Rgb destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref CieXyy sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgb dp = ref Unsafe.Add(ref destRef, i);
@ -129,7 +129,7 @@ public partial class ColorSpaceConverter
ref CieXyz sourceRef = ref MemoryMarshal.GetReference(source);
ref Rgb destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref CieXyz sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgb dp = ref Unsafe.Add(ref destRef, i);
@ -150,7 +150,7 @@ public partial class ColorSpaceConverter
ref Cmyk sourceRef = ref MemoryMarshal.GetReference(source);
ref Rgb destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref Cmyk sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgb dp = ref Unsafe.Add(ref destRef, i);
@ -171,7 +171,7 @@ public partial class ColorSpaceConverter
ref Hsv sourceRef = ref MemoryMarshal.GetReference(source);
ref Rgb destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref Hsv sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgb dp = ref Unsafe.Add(ref destRef, i);
@ -192,7 +192,7 @@ public partial class ColorSpaceConverter
ref Hsl sourceRef = ref MemoryMarshal.GetReference(source);
ref Rgb destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref Hsl sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgb dp = ref Unsafe.Add(ref destRef, i);
@ -213,7 +213,7 @@ public partial class ColorSpaceConverter
ref HunterLab sourceRef = ref MemoryMarshal.GetReference(source);
ref Rgb destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref HunterLab sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgb dp = ref Unsafe.Add(ref destRef, i);
@ -234,7 +234,7 @@ public partial class ColorSpaceConverter
ref LinearRgb sourceRef = ref MemoryMarshal.GetReference(source);
ref Rgb destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref LinearRgb sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgb dp = ref Unsafe.Add(ref destRef, i);
@ -255,7 +255,7 @@ public partial class ColorSpaceConverter
ref Lms sourceRef = ref MemoryMarshal.GetReference(source);
ref Rgb destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref Lms sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgb dp = ref Unsafe.Add(ref destRef, i);
@ -276,7 +276,7 @@ public partial class ColorSpaceConverter
ref YCbCr sourceRef = ref MemoryMarshal.GetReference(source);
ref Rgb destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref YCbCr sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgb dp = ref Unsafe.Add(ref destRef, i);

24
src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.YCbCr.cs

@ -24,7 +24,7 @@ public partial class ColorSpaceConverter
ref CieLab sourceRef = ref MemoryMarshal.GetReference(source);
ref YCbCr destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref CieLab sp = ref Unsafe.Add(ref sourceRef, i);
ref YCbCr dp = ref Unsafe.Add(ref destRef, i);
@ -45,7 +45,7 @@ public partial class ColorSpaceConverter
ref CieLch sourceRef = ref MemoryMarshal.GetReference(source);
ref YCbCr destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref CieLch sp = ref Unsafe.Add(ref sourceRef, i);
ref YCbCr dp = ref Unsafe.Add(ref destRef, i);
@ -66,7 +66,7 @@ public partial class ColorSpaceConverter
ref CieLuv sourceRef = ref MemoryMarshal.GetReference(source);
ref YCbCr destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref CieLuv sp = ref Unsafe.Add(ref sourceRef, i);
ref YCbCr dp = ref Unsafe.Add(ref destRef, i);
@ -87,7 +87,7 @@ public partial class ColorSpaceConverter
ref CieXyy sourceRef = ref MemoryMarshal.GetReference(source);
ref YCbCr destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref CieXyy sp = ref Unsafe.Add(ref sourceRef, i);
ref YCbCr dp = ref Unsafe.Add(ref destRef, i);
@ -108,7 +108,7 @@ public partial class ColorSpaceConverter
ref CieXyz sourceRef = ref MemoryMarshal.GetReference(source);
ref YCbCr destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref CieXyz sp = ref Unsafe.Add(ref sourceRef, i);
ref YCbCr dp = ref Unsafe.Add(ref destRef, i);
@ -129,7 +129,7 @@ public partial class ColorSpaceConverter
ref Cmyk sourceRef = ref MemoryMarshal.GetReference(source);
ref YCbCr destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref Cmyk sp = ref Unsafe.Add(ref sourceRef, i);
ref YCbCr dp = ref Unsafe.Add(ref destRef, i);
@ -150,7 +150,7 @@ public partial class ColorSpaceConverter
ref Hsl sourceRef = ref MemoryMarshal.GetReference(source);
ref YCbCr destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref Hsl sp = ref Unsafe.Add(ref sourceRef, i);
ref YCbCr dp = ref Unsafe.Add(ref destRef, i);
@ -171,7 +171,7 @@ public partial class ColorSpaceConverter
ref Hsv sourceRef = ref MemoryMarshal.GetReference(source);
ref YCbCr destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref Hsv sp = ref Unsafe.Add(ref sourceRef, i);
ref YCbCr dp = ref Unsafe.Add(ref destRef, i);
@ -192,7 +192,7 @@ public partial class ColorSpaceConverter
ref HunterLab sourceRef = ref MemoryMarshal.GetReference(source);
ref YCbCr destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref HunterLab sp = ref Unsafe.Add(ref sourceRef, i);
ref YCbCr dp = ref Unsafe.Add(ref destRef, i);
@ -213,7 +213,7 @@ public partial class ColorSpaceConverter
ref LinearRgb sourceRef = ref MemoryMarshal.GetReference(source);
ref YCbCr destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref LinearRgb sp = ref Unsafe.Add(ref sourceRef, i);
ref YCbCr dp = ref Unsafe.Add(ref destRef, i);
@ -234,7 +234,7 @@ public partial class ColorSpaceConverter
ref Lms sourceRef = ref MemoryMarshal.GetReference(source);
ref YCbCr destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref Lms sp = ref Unsafe.Add(ref sourceRef, i);
ref YCbCr dp = ref Unsafe.Add(ref destRef, i);
@ -255,7 +255,7 @@ public partial class ColorSpaceConverter
ref Rgb sourceRef = ref MemoryMarshal.GetReference(source);
ref YCbCr destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref Rgb sp = ref Unsafe.Add(ref sourceRef, i);
ref YCbCr dp = ref Unsafe.Add(ref destRef, i);

2
src/ImageSharp/ColorSpaces/Conversion/Implementation/VonKriesChromaticAdaptation.cs

@ -81,7 +81,7 @@ public sealed class VonKriesChromaticAdaptation : IChromaticAdaptation
ref CieXyz sourceRef = ref MemoryMarshal.GetReference(source);
ref CieXyz destRef = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref CieXyz sp = ref Unsafe.Add(ref sourceRef, i);
ref CieXyz dp = ref Unsafe.Add(ref destRef, i);

24
src/ImageSharp/Common/Helpers/Numerics.cs

@ -297,7 +297,7 @@ internal static class Numerics
if (remainder.Length > 0)
{
ref byte remainderStart = ref MemoryMarshal.GetReference(remainder);
ref byte remainderEnd = ref Unsafe.Add(ref remainderStart, remainder.Length);
ref byte remainderEnd = ref Unsafe.Add(ref remainderStart, (uint)remainder.Length);
while (Unsafe.IsAddressLessThan(ref remainderStart, ref remainderEnd))
{
@ -322,7 +322,7 @@ internal static class Numerics
if (remainder.Length > 0)
{
ref uint remainderStart = ref MemoryMarshal.GetReference(remainder);
ref uint remainderEnd = ref Unsafe.Add(ref remainderStart, remainder.Length);
ref uint remainderEnd = ref Unsafe.Add(ref remainderStart, (uint)remainder.Length);
while (Unsafe.IsAddressLessThan(ref remainderStart, ref remainderEnd))
{
@ -347,7 +347,7 @@ internal static class Numerics
if (remainder.Length > 0)
{
ref int remainderStart = ref MemoryMarshal.GetReference(remainder);
ref int remainderEnd = ref Unsafe.Add(ref remainderStart, remainder.Length);
ref int remainderEnd = ref Unsafe.Add(ref remainderStart, (uint)remainder.Length);
while (Unsafe.IsAddressLessThan(ref remainderStart, ref remainderEnd))
{
@ -372,7 +372,7 @@ internal static class Numerics
if (remainder.Length > 0)
{
ref float remainderStart = ref MemoryMarshal.GetReference(remainder);
ref float remainderEnd = ref Unsafe.Add(ref remainderStart, remainder.Length);
ref float remainderEnd = ref Unsafe.Add(ref remainderStart, (uint)remainder.Length);
while (Unsafe.IsAddressLessThan(ref remainderStart, ref remainderEnd))
{
@ -397,7 +397,7 @@ internal static class Numerics
if (remainder.Length > 0)
{
ref double remainderStart = ref MemoryMarshal.GetReference(remainder);
ref double remainderEnd = ref Unsafe.Add(ref remainderStart, remainder.Length);
ref double remainderEnd = ref Unsafe.Add(ref remainderStart, (uint)remainder.Length);
while (Unsafe.IsAddressLessThan(ref remainderStart, ref remainderEnd))
{
@ -497,7 +497,7 @@ internal static class Numerics
{
// Divide by 2 as 4 elements per Vector4 and 8 per Vector256<float>
ref Vector256<float> vectorsBase = ref Unsafe.As<Vector4, Vector256<float>>(ref MemoryMarshal.GetReference(vectors));
ref Vector256<float> vectorsLast = ref Unsafe.Add(ref vectorsBase, (IntPtr)((uint)vectors.Length / 2u));
ref Vector256<float> vectorsLast = ref Unsafe.Add(ref vectorsBase, (uint)vectors.Length / 2u);
while (Unsafe.IsAddressLessThan(ref vectorsBase, ref vectorsLast))
{
@ -516,7 +516,7 @@ internal static class Numerics
else
{
ref Vector4 vectorsStart = ref MemoryMarshal.GetReference(vectors);
ref Vector4 vectorsEnd = ref Unsafe.Add(ref vectorsStart, vectors.Length);
ref Vector4 vectorsEnd = ref Unsafe.Add(ref vectorsStart, (uint)vectors.Length);
while (Unsafe.IsAddressLessThan(ref vectorsStart, ref vectorsEnd))
{
@ -562,7 +562,7 @@ internal static class Numerics
{
// Divide by 2 as 4 elements per Vector4 and 8 per Vector256<float>
ref Vector256<float> vectorsBase = ref Unsafe.As<Vector4, Vector256<float>>(ref MemoryMarshal.GetReference(vectors));
ref Vector256<float> vectorsLast = ref Unsafe.Add(ref vectorsBase, (IntPtr)((uint)vectors.Length / 2u));
ref Vector256<float> vectorsLast = ref Unsafe.Add(ref vectorsBase, (uint)vectors.Length / 2u);
Vector256<float> epsilon = Vector256.Create(Constants.Epsilon);
while (Unsafe.IsAddressLessThan(ref vectorsBase, ref vectorsLast))
@ -582,7 +582,7 @@ internal static class Numerics
else
{
ref Vector4 vectorsStart = ref MemoryMarshal.GetReference(vectors);
ref Vector4 vectorsEnd = ref Unsafe.Add(ref vectorsStart, vectors.Length);
ref Vector4 vectorsEnd = ref Unsafe.Add(ref vectorsStart, (uint)vectors.Length);
while (Unsafe.IsAddressLessThan(ref vectorsStart, ref vectorsEnd))
{
@ -656,7 +656,7 @@ internal static class Numerics
public static unsafe void CubePowOnXYZ(Span<Vector4> vectors)
{
ref Vector4 baseRef = ref MemoryMarshal.GetReference(vectors);
ref Vector4 endRef = ref Unsafe.Add(ref baseRef, vectors.Length);
ref Vector4 endRef = ref Unsafe.Add(ref baseRef, (uint)vectors.Length);
while (Unsafe.IsAddressLessThan(ref baseRef, ref endRef))
{
@ -687,7 +687,7 @@ internal static class Numerics
if (Sse41.IsSupported)
{
ref Vector128<float> vectors128Ref = ref Unsafe.As<Vector4, Vector128<float>>(ref MemoryMarshal.GetReference(vectors));
ref Vector128<float> vectors128End = ref Unsafe.Add(ref vectors128Ref, vectors.Length);
ref Vector128<float> vectors128End = ref Unsafe.Add(ref vectors128Ref, (uint)vectors.Length);
var v128_341 = Vector128.Create(341);
Vector128<int> v128_negativeZero = Vector128.Create(-0.0f).AsInt32();
@ -736,7 +736,7 @@ internal static class Numerics
else
{
ref Vector4 vectorsRef = ref MemoryMarshal.GetReference(vectors);
ref Vector4 vectorsEnd = ref Unsafe.Add(ref vectorsRef, vectors.Length);
ref Vector4 vectorsEnd = ref Unsafe.Add(ref vectorsRef, (uint)vectors.Length);
// Fallback with scalar preprocessing and vectorized approximation steps
while (Unsafe.IsAddressLessThan(ref vectorsRef, ref vectorsEnd))

20
src/ImageSharp/Common/Helpers/Shuffle/IComponentShuffle.cs

@ -63,12 +63,12 @@ internal readonly struct DefaultShuffle4 : IShuffle4
Shuffle.InverseMMShuffle(this.Control, out int p3, out int p2, out int p1, out int p0);
for (int i = 0; i < source.Length; i += 4)
for (nint i = 0; i < (uint)source.Length; i += 4)
{
Unsafe.Add(ref dBase, i) = Unsafe.Add(ref sBase, p0 + i);
Unsafe.Add(ref dBase, i + 1) = Unsafe.Add(ref sBase, p1 + i);
Unsafe.Add(ref dBase, i + 2) = Unsafe.Add(ref sBase, p2 + i);
Unsafe.Add(ref dBase, i + 3) = Unsafe.Add(ref sBase, p3 + i);
Unsafe.Add(ref dBase, i + 0) = Unsafe.Add(ref sBase, (nint)(uint)p0 + i);
Unsafe.Add(ref dBase, i + 1) = Unsafe.Add(ref sBase, (nint)(uint)p1 + i);
Unsafe.Add(ref dBase, i + 2) = Unsafe.Add(ref sBase, (nint)(uint)p2 + i);
Unsafe.Add(ref dBase, i + 3) = Unsafe.Add(ref sBase, (nint)(uint)p3 + i);
}
}
}
@ -86,7 +86,7 @@ internal readonly struct WXYZShuffle4 : IShuffle4
ref uint dBase = ref Unsafe.As<byte, uint>(ref MemoryMarshal.GetReference(dest));
int n = source.Length / 4;
for (int i = 0; i < n; i++)
for (nint i = 0; i < (uint)n; i++)
{
uint packed = Unsafe.Add(ref sBase, i);
@ -110,7 +110,7 @@ internal readonly struct WZYXShuffle4 : IShuffle4
ref uint dBase = ref Unsafe.As<byte, uint>(ref MemoryMarshal.GetReference(dest));
int n = source.Length / 4;
for (int i = 0; i < n; i++)
for (nint i = 0; i < (uint)n; i++)
{
uint packed = Unsafe.Add(ref sBase, i);
@ -134,7 +134,7 @@ internal readonly struct YZWXShuffle4 : IShuffle4
ref uint dBase = ref Unsafe.As<byte, uint>(ref MemoryMarshal.GetReference(dest));
int n = source.Length / 4;
for (int i = 0; i < n; i++)
for (nint i = 0; i < (uint)n; i++)
{
uint packed = Unsafe.Add(ref sBase, i);
@ -158,7 +158,7 @@ internal readonly struct ZYXWShuffle4 : IShuffle4
ref uint dBase = ref Unsafe.As<byte, uint>(ref MemoryMarshal.GetReference(dest));
int n = source.Length / 4;
for (int i = 0; i < n; i++)
for (nint i = 0; i < (uint)n; i++)
{
uint packed = Unsafe.Add(ref sBase, i);
@ -189,7 +189,7 @@ internal readonly struct XWZYShuffle4 : IShuffle4
ref uint dBase = ref Unsafe.As<byte, uint>(ref MemoryMarshal.GetReference(dest));
int n = source.Length / 4;
for (int i = 0; i < n; i++)
for (nint i = 0; i < (uint)n; i++)
{
uint packed = Unsafe.Add(ref sBase, i);

12
src/ImageSharp/Common/Helpers/Shuffle/IPad3Shuffle4.cs

@ -35,15 +35,15 @@ internal readonly struct DefaultPad3Shuffle4 : IPad3Shuffle4
ref byte t = ref MemoryMarshal.GetReference(temp);
ref uint tu = ref Unsafe.As<byte, uint>(ref t);
for (int i = 0, j = 0; i < source.Length; i += 3, j += 4)
for (nint i = 0, j = 0; i < (uint)source.Length; i += 3, j += 4)
{
ref byte s = ref Unsafe.Add(ref sBase, i);
tu = Unsafe.As<byte, uint>(ref s) | 0xFF000000;
Unsafe.Add(ref dBase, j) = Unsafe.Add(ref t, p0);
Unsafe.Add(ref dBase, j + 1) = Unsafe.Add(ref t, p1);
Unsafe.Add(ref dBase, j + 2) = Unsafe.Add(ref t, p2);
Unsafe.Add(ref dBase, j + 3) = Unsafe.Add(ref t, p3);
Unsafe.Add(ref dBase, j + 0) = Unsafe.Add(ref t, (uint)p0);
Unsafe.Add(ref dBase, j + 1) = Unsafe.Add(ref t, (uint)p1);
Unsafe.Add(ref dBase, j + 2) = Unsafe.Add(ref t, (uint)p2);
Unsafe.Add(ref dBase, j + 3) = Unsafe.Add(ref t, (uint)p3);
}
}
}
@ -60,7 +60,7 @@ internal readonly struct XYZWPad3Shuffle4 : IPad3Shuffle4
ref byte sBase = ref MemoryMarshal.GetReference(source);
ref byte dBase = ref MemoryMarshal.GetReference(dest);
ref byte sEnd = ref Unsafe.Add(ref sBase, source.Length);
ref byte sEnd = ref Unsafe.Add(ref sBase, (uint)source.Length);
ref byte sLoopEnd = ref Unsafe.Subtract(ref sEnd, 4);
while (Unsafe.IsAddressLessThan(ref sBase, ref sLoopEnd))

8
src/ImageSharp/Common/Helpers/Shuffle/IShuffle3.cs

@ -31,11 +31,11 @@ internal readonly struct DefaultShuffle3 : IShuffle3
Shuffle.InverseMMShuffle(this.Control, out _, out int p2, out int p1, out int p0);
for (int i = 0; i < source.Length; i += 3)
for (nint i = 0; i < (uint)source.Length; i += 3)
{
Unsafe.Add(ref dBase, i) = Unsafe.Add(ref sBase, p0 + i);
Unsafe.Add(ref dBase, i + 1) = Unsafe.Add(ref sBase, p1 + i);
Unsafe.Add(ref dBase, i + 2) = Unsafe.Add(ref sBase, p2 + i);
Unsafe.Add(ref dBase, i + 0) = Unsafe.Add(ref sBase, (nint)(uint)p0 + i);
Unsafe.Add(ref dBase, i + 1) = Unsafe.Add(ref sBase, (nint)(uint)p1 + i);
Unsafe.Add(ref dBase, i + 2) = Unsafe.Add(ref sBase, (nint)(uint)p2 + i);
}
}
}

14
src/ImageSharp/Common/Helpers/Shuffle/IShuffle4Slice3.cs

@ -31,11 +31,11 @@ internal readonly struct DefaultShuffle4Slice3 : IShuffle4Slice3
Shuffle.InverseMMShuffle(this.Control, out _, out int p2, out int p1, out int p0);
for (int i = 0, j = 0; i < dest.Length; i += 3, j += 4)
for (nint i = 0, j = 0; i < (uint)dest.Length; i += 3, j += 4)
{
Unsafe.Add(ref dBase, i) = Unsafe.Add(ref sBase, p0 + j);
Unsafe.Add(ref dBase, i + 1) = Unsafe.Add(ref sBase, p1 + j);
Unsafe.Add(ref dBase, i + 2) = Unsafe.Add(ref sBase, p2 + j);
Unsafe.Add(ref dBase, i + 0) = Unsafe.Add(ref sBase, (nint)(uint)p0 + j);
Unsafe.Add(ref dBase, i + 1) = Unsafe.Add(ref sBase, (nint)(uint)p1 + j);
Unsafe.Add(ref dBase, i + 2) = Unsafe.Add(ref sBase, (nint)(uint)p2 + j);
}
}
}
@ -52,9 +52,9 @@ internal readonly struct XYZWShuffle4Slice3 : IShuffle4Slice3
ref uint sBase = ref Unsafe.As<byte, uint>(ref MemoryMarshal.GetReference(source));
ref Byte3 dBase = ref Unsafe.As<byte, Byte3>(ref MemoryMarshal.GetReference(dest));
int n = source.Length / 4;
int m = Numerics.Modulo4(n);
int u = n - m;
nint n = (nint)(uint)source.Length / 4;
nint m = Numerics.Modulo4(n);
nint u = n - m;
ref uint sLoopEnd = ref Unsafe.Add(ref sBase, u);
ref uint sEnd = ref Unsafe.Add(ref sBase, n);

4
src/ImageSharp/Common/Helpers/SimdUtils.FallbackIntrinsics128.cs

@ -83,7 +83,7 @@ internal static partial class SimdUtils
const float scale = 1f / 255f;
Vector4 d = default;
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
ref ByteVector4 s = ref Unsafe.Add(ref sBase, i);
d.X = s.X;
@ -117,7 +117,7 @@ internal static partial class SimdUtils
var half = new Vector4(0.5f);
var maxBytes = new Vector4(255f);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
Vector4 s = Unsafe.Add(ref sBase, i);
s *= maxBytes;

4
src/ImageSharp/Common/Helpers/SimdUtils.HwIntrinsics.cs

@ -995,9 +995,9 @@ internal static partial class SimdUtils
const int bytesPerRgbStride = 24;
int count = (int)((uint)source.Length / 8);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
rgb = Avx2.PermuteVar8x32(Unsafe.AddByteOffset(ref rgbByteSpan, (IntPtr)(bytesPerRgbStride * i)).AsUInt32(), extractToLanesMask).AsByte();
rgb = Avx2.PermuteVar8x32(Unsafe.AddByteOffset(ref rgbByteSpan, (uint)(bytesPerRgbStride * i)).AsUInt32(), extractToLanesMask).AsByte();
rgb = Avx2.Shuffle(rgb, extractRgbMask);

18
src/ImageSharp/Common/Helpers/SimdUtils.Pack.cs

@ -86,8 +86,8 @@ internal static partial class SimdUtils
ref ByteTuple4 b = ref Unsafe.As<byte, ByteTuple4>(ref MemoryMarshal.GetReference(blueChannel));
ref Rgb24 rgb = ref MemoryMarshal.GetReference(destination);
int count = redChannel.Length / 4;
for (int i = 0; i < count; i++)
uint count = (uint)redChannel.Length / 4;
for (nint i = 0; i < count; i++)
{
ref Rgb24 d0 = ref Unsafe.Add(ref rgb, i * 4);
ref Rgb24 d1 = ref Unsafe.Add(ref d0, 1);
@ -115,7 +115,7 @@ internal static partial class SimdUtils
d3.B = bb.V3;
}
int finished = count * 4;
int finished = (int)(count * 4);
redChannel = redChannel[finished..];
greenChannel = greenChannel[finished..];
blueChannel = blueChannel[finished..];
@ -133,9 +133,9 @@ internal static partial class SimdUtils
ref ByteTuple4 b = ref Unsafe.As<byte, ByteTuple4>(ref MemoryMarshal.GetReference(blueChannel));
ref Rgba32 rgb = ref MemoryMarshal.GetReference(destination);
int count = redChannel.Length / 4;
uint count = (uint)redChannel.Length / 4;
destination.Fill(new Rgba32(0, 0, 0, 255));
for (int i = 0; i < count; i++)
for (nint i = 0; i < count; i++)
{
ref Rgba32 d0 = ref Unsafe.Add(ref rgb, i * 4);
ref Rgba32 d1 = ref Unsafe.Add(ref d0, 1);
@ -163,7 +163,7 @@ internal static partial class SimdUtils
d3.B = bb.V3;
}
int finished = count * 4;
int finished = (int)(count * 4);
redChannel = redChannel[finished..];
greenChannel = greenChannel[finished..];
blueChannel = blueChannel[finished..];
@ -181,7 +181,7 @@ internal static partial class SimdUtils
ref byte b = ref MemoryMarshal.GetReference(blueChannel);
ref Rgb24 rgb = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < destination.Length; i++)
for (nint i = 0; i < (uint)destination.Length; i++)
{
ref Rgb24 d = ref Unsafe.Add(ref rgb, i);
d.R = Unsafe.Add(ref r, i);
@ -201,7 +201,7 @@ internal static partial class SimdUtils
ref byte b = ref MemoryMarshal.GetReference(blueChannel);
ref Rgba32 rgba = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < destination.Length; i++)
for (nint i = 0; i < (uint)destination.Length; i++)
{
ref Rgba32 d = ref Unsafe.Add(ref rgba, i);
d.R = Unsafe.Add(ref r, i);
@ -226,7 +226,7 @@ internal static partial class SimdUtils
ref float b = ref MemoryMarshal.GetReference(blueChannel);
ref Rgb24 rgb = ref MemoryMarshal.GetReference(source);
for (int i = 0; i < source.Length; i++)
for (nint i = 0; i < (uint)source.Length; i++)
{
ref Rgb24 src = ref Unsafe.Add(ref rgb, i);
Unsafe.Add(ref r, i) = src.R;

18
src/ImageSharp/Common/Helpers/SimdUtils.Shuffle.cs

@ -147,12 +147,12 @@ internal static partial class SimdUtils
ref float dBase = ref MemoryMarshal.GetReference(dest);
Shuffle.InverseMMShuffle(control, out int p3, out int p2, out int p1, out int p0);
for (int i = 0; i < source.Length; i += 4)
for (nint i = 0; i < (uint)source.Length; i += 4)
{
Unsafe.Add(ref dBase, i) = Unsafe.Add(ref sBase, p0 + i);
Unsafe.Add(ref dBase, i + 1) = Unsafe.Add(ref sBase, p1 + i);
Unsafe.Add(ref dBase, i + 2) = Unsafe.Add(ref sBase, p2 + i);
Unsafe.Add(ref dBase, i + 3) = Unsafe.Add(ref sBase, p3 + i);
Unsafe.Add(ref dBase, i + 0) = Unsafe.Add(ref sBase, (nint)(uint)p0 + i);
Unsafe.Add(ref dBase, i + 1) = Unsafe.Add(ref sBase, (nint)(uint)p1 + i);
Unsafe.Add(ref dBase, i + 2) = Unsafe.Add(ref sBase, (nint)(uint)p2 + i);
Unsafe.Add(ref dBase, i + 3) = Unsafe.Add(ref sBase, (nint)(uint)p3 + i);
}
}
@ -501,10 +501,10 @@ internal static partial class SimdUtils
for (int i = 0; i < span.Length; i += 4)
{
Unsafe.Add(ref spanBase, i) = (byte)(p0 + i);
Unsafe.Add(ref spanBase, i + 1) = (byte)(p1 + i);
Unsafe.Add(ref spanBase, i + 2) = (byte)(p2 + i);
Unsafe.Add(ref spanBase, i + 3) = (byte)(p3 + i);
Unsafe.Add(ref spanBase, (uint)(i + 0)) = (byte)(p0 + i);
Unsafe.Add(ref spanBase, (uint)(i + 1)) = (byte)(p1 + i);
Unsafe.Add(ref spanBase, (uint)(i + 2)) = (byte)(p2 + i);
Unsafe.Add(ref spanBase, (uint)(i + 3)) = (byte)(p3 + i);
}
}

2
src/ImageSharp/Compression/Zlib/Crc32.cs

@ -300,7 +300,7 @@ internal static partial class Crc32
for (int i = 0; i < buffer.Length; i++)
{
crc = Unsafe.Add(ref crcTableRef, (int)((crc ^ Unsafe.Add(ref bufferRef, i)) & 0xFF)) ^ (crc >> 8);
crc = Unsafe.Add(ref crcTableRef, (crc ^ Unsafe.Add(ref bufferRef, i)) & 0xFF) ^ (crc >> 8);
}
return crc;

94
src/ImageSharp/Compression/Zlib/DeflaterHuffman.cs

@ -286,13 +286,13 @@ internal sealed unsafe class DeflaterHuffman : IDisposable
int static_len = this.extraBits;
ref byte staticLLengthRef = ref MemoryMarshal.GetReference(StaticLLength);
for (int i = 0; i < LiteralNumber; i++)
for (nint i = 0; i < LiteralNumber; i++)
{
static_len += this.literalTree.Frequencies[i] * Unsafe.Add(ref staticLLengthRef, i);
}
ref byte staticDLengthRef = ref MemoryMarshal.GetReference(StaticDLength);
for (int i = 0; i < DistanceNumber; i++)
for (nint i = 0; i < DistanceNumber; i++)
{
static_len += this.distTree.Frequencies[i] * Unsafe.Add(ref staticDLengthRef, i);
}
@ -405,10 +405,10 @@ internal sealed unsafe class DeflaterHuffman : IDisposable
ref byte bit4ReverseRef = ref MemoryMarshal.GetReference(Bit4Reverse);
return (short)(Unsafe.Add(ref bit4ReverseRef, toReverse & 0xF) << 12
| Unsafe.Add(ref bit4ReverseRef, (toReverse >> 4) & 0xF) << 8
| Unsafe.Add(ref bit4ReverseRef, (toReverse >> 8) & 0xF) << 4
| Unsafe.Add(ref bit4ReverseRef, toReverseRightShiftBy12));
return (short)((Unsafe.Add(ref bit4ReverseRef, (uint)toReverse & 0xF) << 12)
| (Unsafe.Add(ref bit4ReverseRef, (uint)(toReverse >> 4) & 0xF) << 8)
| (Unsafe.Add(ref bit4ReverseRef, (uint)(toReverse >> 8) & 0xF) << 4)
| Unsafe.Add(ref bit4ReverseRef, (uint)toReverseRightShiftBy12));
}
/// <inheritdoc/>
@ -551,8 +551,8 @@ internal sealed unsafe class DeflaterHuffman : IDisposable
int code = 0;
for (int bits = 0; bits < this.maxLength; bits++)
{
Unsafe.Add(ref nextCodeRef, bits) = code;
code += Unsafe.Add(ref bitLengthCountsRef, bits) << (15 - bits);
Unsafe.Add(ref nextCodeRef, (uint)bits) = code;
code += Unsafe.Add(ref bitLengthCountsRef, (uint)bits) << (15 - bits);
}
for (int i = 0; i < this.NumCodes; i++)
@ -560,8 +560,8 @@ internal sealed unsafe class DeflaterHuffman : IDisposable
int bits = this.Length[i];
if (bits > 0)
{
this.codes[i] = BitReverse(Unsafe.Add(ref nextCodeRef, bits - 1));
Unsafe.Add(ref nextCodeRef, bits - 1) += 1 << (16 - bits);
this.codes[i] = BitReverse(Unsafe.Add(ref nextCodeRef, (uint)(bits - 1)));
Unsafe.Add(ref nextCodeRef, (uint)(bits - 1)) += 1 << (16 - bits);
}
}
}
@ -593,13 +593,13 @@ internal sealed unsafe class DeflaterHuffman : IDisposable
// Insert n into heap
int pos = heapLen++;
int ppos;
while (pos > 0 && this.Frequencies[Unsafe.Add(ref heapRef, ppos = (pos - 1) >> 1)] > freq)
while (pos > 0 && this.Frequencies[Unsafe.Add(ref heapRef, (uint)(ppos = (pos - 1) >> 1))] > freq)
{
Unsafe.Add(ref heapRef, pos) = Unsafe.Add(ref heapRef, ppos);
Unsafe.Add(ref heapRef, pos) = Unsafe.Add(ref heapRef, (uint)ppos);
pos = ppos;
}
Unsafe.Add(ref heapRef, pos) = n;
Unsafe.Add(ref heapRef, (uint)pos) = n;
maxCode = n;
}
@ -611,7 +611,7 @@ internal sealed unsafe class DeflaterHuffman : IDisposable
// this case, both literals get a 1 bit code.
while (heapLen < 2)
{
Unsafe.Add(ref heapRef, heapLen++) = maxCode < 2 ? ++maxCode : 0;
Unsafe.Add(ref heapRef, (uint)heapLen++) = maxCode < 2 ? ++maxCode : 0;
}
this.NumCodes = Math.Max(maxCode + 1, this.minNumCodes);
@ -625,14 +625,14 @@ internal sealed unsafe class DeflaterHuffman : IDisposable
ref int valuesRef = ref MemoryMarshal.GetReference(valuesMemoryOwner.Memory.Span);
int numNodes = numLeafs;
for (int i = 0; i < heapLen; i++)
for (nint i = 0; i < (uint)heapLen; i++)
{
int node = Unsafe.Add(ref heapRef, i);
int i2 = 2 * i;
nint i2 = 2 * i;
Unsafe.Add(ref childrenRef, i2) = node;
Unsafe.Add(ref childrenRef, i2 + 1) = -1;
Unsafe.Add(ref valuesRef, i) = this.Frequencies[node] << 8;
Unsafe.Add(ref heapRef, i) = i;
Unsafe.Add(ref heapRef, i) = (int)i;
}
// Construct the Huffman tree by repeatedly combining the least two
@ -640,7 +640,7 @@ internal sealed unsafe class DeflaterHuffman : IDisposable
do
{
int first = Unsafe.Add(ref heapRef, 0);
int last = Unsafe.Add(ref heapRef, --heapLen);
int last = Unsafe.Add(ref heapRef, (uint)--heapLen);
// Propagate the hole to the leafs of the heap
int ppos = 0;
@ -648,35 +648,35 @@ internal sealed unsafe class DeflaterHuffman : IDisposable
while (path < heapLen)
{
if (path + 1 < heapLen && Unsafe.Add(ref valuesRef, Unsafe.Add(ref heapRef, path)) > Unsafe.Add(ref valuesRef, Unsafe.Add(ref heapRef, path + 1)))
if (path + 1 < heapLen && Unsafe.Add(ref valuesRef, (uint)Unsafe.Add(ref heapRef, (uint)path)) > Unsafe.Add(ref valuesRef, (uint)Unsafe.Add(ref heapRef, (uint)(path + 1))))
{
path++;
}
Unsafe.Add(ref heapRef, ppos) = Unsafe.Add(ref heapRef, path);
Unsafe.Add(ref heapRef, (uint)ppos) = Unsafe.Add(ref heapRef, (uint)path);
ppos = path;
path = (path * 2) + 1;
}
// Now propagate the last element down along path. Normally
// it shouldn't go too deep.
int lastVal = Unsafe.Add(ref valuesRef, last);
int lastVal = Unsafe.Add(ref valuesRef, (uint)last);
while ((path = ppos) > 0
&& Unsafe.Add(ref valuesRef, Unsafe.Add(ref heapRef, ppos = (path - 1) >> 1)) > lastVal)
&& Unsafe.Add(ref valuesRef, (uint)Unsafe.Add(ref heapRef, (uint)(ppos = (path - 1) >> 1))) > lastVal)
{
Unsafe.Add(ref heapRef, path) = Unsafe.Add(ref heapRef, ppos);
Unsafe.Add(ref heapRef, (uint)path) = Unsafe.Add(ref heapRef, (uint)ppos);
}
Unsafe.Add(ref heapRef, path) = last;
Unsafe.Add(ref heapRef, (uint)path) = last;
int second = Unsafe.Add(ref heapRef, 0);
// Create a new node father of first and second
last = numNodes++;
Unsafe.Add(ref childrenRef, 2 * last) = first;
Unsafe.Add(ref childrenRef, (2 * last) + 1) = second;
int mindepth = Math.Min(Unsafe.Add(ref valuesRef, first) & 0xFF, Unsafe.Add(ref valuesRef, second) & 0xFF);
Unsafe.Add(ref valuesRef, last) = lastVal = Unsafe.Add(ref valuesRef, first) + Unsafe.Add(ref valuesRef, second) - mindepth + 1;
Unsafe.Add(ref childrenRef, (uint)(2 * last)) = first;
Unsafe.Add(ref childrenRef, (uint)((2 * last) + 1)) = second;
int mindepth = Math.Min(Unsafe.Add(ref valuesRef, (uint)first) & 0xFF, Unsafe.Add(ref valuesRef, (uint)second) & 0xFF);
Unsafe.Add(ref valuesRef, (uint)last) = lastVal = Unsafe.Add(ref valuesRef, (uint)first) + Unsafe.Add(ref valuesRef, (uint)second) - mindepth + 1;
// Again, propagate the hole to the leafs
ppos = 0;
@ -685,23 +685,23 @@ internal sealed unsafe class DeflaterHuffman : IDisposable
while (path < heapLen)
{
if (path + 1 < heapLen
&& Unsafe.Add(ref valuesRef, Unsafe.Add(ref heapRef, path)) > Unsafe.Add(ref valuesRef, Unsafe.Add(ref heapRef, path + 1)))
&& Unsafe.Add(ref valuesRef, (uint)Unsafe.Add(ref heapRef, (uint)path)) > Unsafe.Add(ref valuesRef, (uint)Unsafe.Add(ref heapRef, (uint)(path + 1))))
{
path++;
}
Unsafe.Add(ref heapRef, ppos) = Unsafe.Add(ref heapRef, path);
Unsafe.Add(ref heapRef, (uint)ppos) = Unsafe.Add(ref heapRef, (uint)path);
ppos = path;
path = (ppos * 2) + 1;
}
// Now propagate the new element down along path
while ((path = ppos) > 0 && Unsafe.Add(ref valuesRef, Unsafe.Add(ref heapRef, ppos = (path - 1) >> 1)) > lastVal)
while ((path = ppos) > 0 && Unsafe.Add(ref valuesRef, (uint)Unsafe.Add(ref heapRef, (uint)(ppos = (path - 1) >> 1))) > lastVal)
{
Unsafe.Add(ref heapRef, path) = Unsafe.Add(ref heapRef, ppos);
Unsafe.Add(ref heapRef, (uint)path) = Unsafe.Add(ref heapRef, (uint)ppos);
}
Unsafe.Add(ref heapRef, path) = last;
Unsafe.Add(ref heapRef, (uint)path) = last;
}
while (heapLen > 1);
@ -886,21 +886,21 @@ internal sealed unsafe class DeflaterHuffman : IDisposable
{
if (children[(2 * i) + 1] != -1)
{
int bitLength = Unsafe.Add(ref lengthsRef, i) + 1;
int bitLength = Unsafe.Add(ref lengthsRef, (uint)i) + 1;
if (bitLength > maxLen)
{
bitLength = maxLen;
overflow++;
}
Unsafe.Add(ref lengthsRef, Unsafe.Add(ref childrenRef, 2 * i)) = Unsafe.Add(ref lengthsRef, Unsafe.Add(ref childrenRef, (2 * i) + 1)) = bitLength;
Unsafe.Add(ref lengthsRef, (uint)Unsafe.Add(ref childrenRef, (uint)(2 * i))) = Unsafe.Add(ref lengthsRef, (uint)Unsafe.Add(ref childrenRef, (uint)((2 * i) + 1))) = bitLength;
}
else
{
// A leaf node
int bitLength = Unsafe.Add(ref lengthsRef, i);
Unsafe.Add(ref bitLengthCountsRef, bitLength - 1)++;
lengthPtr[Unsafe.Add(ref childrenRef, 2 * i)] = (byte)Unsafe.Add(ref lengthsRef, i);
int bitLength = Unsafe.Add(ref lengthsRef, (uint)i);
Unsafe.Add(ref bitLengthCountsRef, (uint)(bitLength - 1))++;
lengthPtr[Unsafe.Add(ref childrenRef, (uint)(2 * i))] = (byte)Unsafe.Add(ref lengthsRef, (uint)i);
}
}
}
@ -914,7 +914,7 @@ internal sealed unsafe class DeflaterHuffman : IDisposable
do
{
// Find the first bit length which could increase:
while (Unsafe.Add(ref bitLengthCountsRef, --incrBitLen) == 0)
while (Unsafe.Add(ref bitLengthCountsRef, (uint)--incrBitLen) == 0)
{
}
@ -922,8 +922,8 @@ internal sealed unsafe class DeflaterHuffman : IDisposable
// number of overflow nodes.
do
{
Unsafe.Add(ref bitLengthCountsRef, incrBitLen)--;
Unsafe.Add(ref bitLengthCountsRef, ++incrBitLen)++;
Unsafe.Add(ref bitLengthCountsRef, (uint)incrBitLen)--;
Unsafe.Add(ref bitLengthCountsRef, (uint)++incrBitLen)++;
overflow -= 1 << (maxLen - 1 - incrBitLen);
}
while (overflow > 0 && incrBitLen < maxLen - 1);
@ -932,8 +932,8 @@ internal sealed unsafe class DeflaterHuffman : IDisposable
// We may have overshot above. Move some nodes from maxLength to
// maxLength-1 in that case.
Unsafe.Add(ref bitLengthCountsRef, maxLen - 1) += overflow;
Unsafe.Add(ref bitLengthCountsRef, maxLen - 2) -= overflow;
Unsafe.Add(ref bitLengthCountsRef, (uint)(maxLen - 1)) += overflow;
Unsafe.Add(ref bitLengthCountsRef, (uint)(maxLen - 2)) -= overflow;
// Now recompute all bit lengths, scanning in increasing
// frequency. It is simpler to reconstruct all lengths instead of
@ -945,14 +945,14 @@ internal sealed unsafe class DeflaterHuffman : IDisposable
int nodeIndex = 2 * numLeafs;
for (int bits = maxLen; bits != 0; bits--)
{
int n = Unsafe.Add(ref bitLengthCountsRef, bits - 1);
int n = Unsafe.Add(ref bitLengthCountsRef, (uint)(bits - 1));
while (n > 0)
{
int childIndex = 2 * Unsafe.Add(ref childrenRef, nodeIndex++);
if (Unsafe.Add(ref childrenRef, childIndex + 1) == -1)
int childIndex = 2 * Unsafe.Add(ref childrenRef, (uint)nodeIndex++);
if (Unsafe.Add(ref childrenRef, (uint)(childIndex + 1)) == -1)
{
// We found another leaf
lengthPtr[Unsafe.Add(ref childrenRef, childIndex)] = (byte)bits;
lengthPtr[Unsafe.Add(ref childrenRef, (uint)childIndex)] = (byte)bits;
n--;
}
}

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

@ -578,8 +578,8 @@ internal sealed class GifDecoderCore : IImageDecoderInternals
// #403 The left + width value can be larger than the image width
for (int x = descriptorLeft; x < descriptorRight && x < imageWidth; x++)
{
int index = Numerics.Clamp(Unsafe.Add(ref indicesRowRef, x - descriptorLeft), 0, colorTableMaxIdx);
ref TPixel pixel = ref Unsafe.Add(ref rowRef, x);
int index = Numerics.Clamp(Unsafe.Add(ref indicesRowRef, (uint)(x - descriptorLeft)), 0, colorTableMaxIdx);
ref TPixel pixel = ref Unsafe.Add(ref rowRef, (uint)x);
Rgb24 rgb = colorTable[index];
pixel.FromRgb24(rgb);
}
@ -588,7 +588,7 @@ internal sealed class GifDecoderCore : IImageDecoderInternals
{
for (int x = descriptorLeft; x < descriptorRight && x < imageWidth; x++)
{
int rawIndex = Unsafe.Add(ref indicesRowRef, x - descriptorLeft);
int rawIndex = Unsafe.Add(ref indicesRowRef, (uint)(x - descriptorLeft));
// Treat any out of bounds values as transparent.
if (rawIndex > colorTableMaxIdx || rawIndex == transIndex)
@ -597,7 +597,7 @@ internal sealed class GifDecoderCore : IImageDecoderInternals
}
int index = Numerics.Clamp(rawIndex, 0, colorTableMaxIdx);
ref TPixel pixel = ref Unsafe.Add(ref rowRef, x);
ref TPixel pixel = ref Unsafe.Add(ref rowRef, (uint)x);
Rgb24 rgb = colorTable[index];
pixel.FromRgb24(rgb);
}

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

@ -254,7 +254,7 @@ internal sealed class GifEncoderCore : IImageEncoderInternals
for (int i = rgbaSpan.Length - 1; i >= 0; i--)
{
if (Unsafe.Add(ref rgbaSpanRef, i).Equals(default))
if (Unsafe.Add(ref rgbaSpanRef, (uint)i).Equals(default))
{
index = i;
}

38
src/ImageSharp/Formats/Gif/LzwDecoder.cs

@ -115,7 +115,7 @@ internal sealed class LzwDecoder : IDisposable
for (code = 0; code < clearCode; code++)
{
Unsafe.Add(ref suffixRef, code) = (byte)code;
Unsafe.Add(ref suffixRef, (uint)code) = (byte)code;
}
Span<byte> buffer = stackalloc byte[byte.MaxValue];
@ -182,7 +182,7 @@ internal sealed class LzwDecoder : IDisposable
if (oldCode == NullCode)
{
Unsafe.Add(ref pixelStackRef, top++) = Unsafe.Add(ref suffixRef, code);
Unsafe.Add(ref pixelStackRef, (uint)top++) = Unsafe.Add(ref suffixRef, (uint)code);
oldCode = code;
first = code;
continue;
@ -191,27 +191,27 @@ internal sealed class LzwDecoder : IDisposable
int inCode = code;
if (code == availableCode)
{
Unsafe.Add(ref pixelStackRef, top++) = (byte)first;
Unsafe.Add(ref pixelStackRef, (uint)top++) = (byte)first;
code = oldCode;
}
while (code > clearCode)
{
Unsafe.Add(ref pixelStackRef, top++) = Unsafe.Add(ref suffixRef, code);
code = Unsafe.Add(ref prefixRef, code);
Unsafe.Add(ref pixelStackRef, (uint)top++) = Unsafe.Add(ref suffixRef, (uint)code);
code = Unsafe.Add(ref prefixRef, (uint)code);
}
int suffixCode = Unsafe.Add(ref suffixRef, code);
int suffixCode = Unsafe.Add(ref suffixRef, (uint)code);
first = suffixCode;
Unsafe.Add(ref pixelStackRef, top++) = suffixCode;
Unsafe.Add(ref pixelStackRef, (uint)top++) = suffixCode;
// Fix for Gifs that have "deferred clear code" as per here :
// https://bugzilla.mozilla.org/show_bug.cgi?id=55918
if (availableCode < MaxStackSize)
{
Unsafe.Add(ref prefixRef, availableCode) = oldCode;
Unsafe.Add(ref suffixRef, availableCode) = first;
Unsafe.Add(ref prefixRef, (uint)availableCode) = oldCode;
Unsafe.Add(ref suffixRef, (uint)availableCode) = first;
availableCode++;
if (availableCode == codeMask + 1 && availableCode < MaxStackSize)
{
@ -228,7 +228,7 @@ internal sealed class LzwDecoder : IDisposable
// Clear missing pixels
xyz++;
Unsafe.Add(ref pixelsRowRef, x++) = (byte)Unsafe.Add(ref pixelStackRef, top);
Unsafe.Add(ref pixelsRowRef, (uint)x++) = (byte)Unsafe.Add(ref pixelStackRef, (uint)top);
}
}
@ -282,7 +282,7 @@ internal sealed class LzwDecoder : IDisposable
for (code = 0; code < clearCode; code++)
{
Unsafe.Add(ref suffixRef, code) = (byte)code;
Unsafe.Add(ref suffixRef, (uint)code) = (byte)code;
}
Span<byte> buffer = stackalloc byte[byte.MaxValue];
@ -336,7 +336,7 @@ internal sealed class LzwDecoder : IDisposable
if (oldCode == NullCode)
{
Unsafe.Add(ref pixelStackRef, top++) = Unsafe.Add(ref suffixRef, code);
Unsafe.Add(ref pixelStackRef, (uint)top++) = Unsafe.Add(ref suffixRef, (uint)code);
oldCode = code;
first = code;
continue;
@ -345,27 +345,27 @@ internal sealed class LzwDecoder : IDisposable
int inCode = code;
if (code == availableCode)
{
Unsafe.Add(ref pixelStackRef, top++) = (byte)first;
Unsafe.Add(ref pixelStackRef, (uint)top++) = (byte)first;
code = oldCode;
}
while (code > clearCode)
{
Unsafe.Add(ref pixelStackRef, top++) = Unsafe.Add(ref suffixRef, code);
code = Unsafe.Add(ref prefixRef, code);
Unsafe.Add(ref pixelStackRef, (uint)top++) = Unsafe.Add(ref suffixRef, (uint)code);
code = Unsafe.Add(ref prefixRef, (uint)code);
}
int suffixCode = Unsafe.Add(ref suffixRef, code);
int suffixCode = Unsafe.Add(ref suffixRef, (uint)code);
first = suffixCode;
Unsafe.Add(ref pixelStackRef, top++) = suffixCode;
Unsafe.Add(ref pixelStackRef, (uint)top++) = suffixCode;
// Fix for Gifs that have "deferred clear code" as per here :
// https://bugzilla.mozilla.org/show_bug.cgi?id=55918
if (availableCode < MaxStackSize)
{
Unsafe.Add(ref prefixRef, availableCode) = oldCode;
Unsafe.Add(ref suffixRef, availableCode) = first;
Unsafe.Add(ref prefixRef, (uint)availableCode) = oldCode;
Unsafe.Add(ref suffixRef, (uint)availableCode) = first;
availableCode++;
if (availableCode == codeMask + 1 && availableCode < MaxStackSize)
{

22
src/ImageSharp/Formats/Gif/LzwEncoder.cs

@ -216,7 +216,7 @@ internal sealed class LzwEncoder : IDisposable
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private void AddCharacter(byte c, ref byte accumulatorsRef, Stream stream)
{
Unsafe.Add(ref accumulatorsRef, this.accumulatorCount++) = c;
Unsafe.Add(ref accumulatorsRef, (uint)this.accumulatorCount++) = c;
if (this.accumulatorCount >= 254)
{
this.FlushPacket(stream);
@ -278,18 +278,18 @@ internal sealed class LzwEncoder : IDisposable
for (int x = offsetX; x < indexedPixels.Width; x++)
{
int code = Unsafe.Add(ref rowSpanRef, x);
int code = Unsafe.Add(ref rowSpanRef, (uint)x);
int freeCode = (code << MaxBits) + entry;
int hashIndex = (code << HashShift) ^ entry;
if (Unsafe.Add(ref hashTableRef, hashIndex) == freeCode)
if (Unsafe.Add(ref hashTableRef, (uint)hashIndex) == freeCode)
{
entry = Unsafe.Add(ref codeTableRef, hashIndex);
entry = Unsafe.Add(ref codeTableRef, (uint)hashIndex);
continue;
}
// Non-empty slot
if (Unsafe.Add(ref hashTableRef, hashIndex) >= 0)
if (Unsafe.Add(ref hashTableRef, (uint)hashIndex) >= 0)
{
int disp = 1;
if (hashIndex != 0)
@ -304,15 +304,15 @@ internal sealed class LzwEncoder : IDisposable
hashIndex += HashSize;
}
if (Unsafe.Add(ref hashTableRef, hashIndex) == freeCode)
if (Unsafe.Add(ref hashTableRef, (uint)hashIndex) == freeCode)
{
entry = Unsafe.Add(ref codeTableRef, hashIndex);
entry = Unsafe.Add(ref codeTableRef, (uint)hashIndex);
break;
}
}
while (Unsafe.Add(ref hashTableRef, hashIndex) >= 0);
while (Unsafe.Add(ref hashTableRef, (uint)hashIndex) >= 0);
if (Unsafe.Add(ref hashTableRef, hashIndex) == freeCode)
if (Unsafe.Add(ref hashTableRef, (uint)hashIndex) == freeCode)
{
continue;
}
@ -322,8 +322,8 @@ internal sealed class LzwEncoder : IDisposable
entry = code;
if (this.freeEntry < MaxMaxCode)
{
Unsafe.Add(ref codeTableRef, hashIndex) = this.freeEntry++; // code -> hashtable
Unsafe.Add(ref hashTableRef, hashIndex) = freeCode;
Unsafe.Add(ref codeTableRef, (uint)hashIndex) = this.freeEntry++; // code -> hashtable
Unsafe.Add(ref hashTableRef, (uint)hashIndex) = freeCode;
}
else
{

10
src/ImageSharp/Formats/Jpeg/Components/Block8x8.cs

@ -47,7 +47,7 @@ internal unsafe partial struct Block8x8
DebugGuard.MustBeBetweenOrEqualTo(idx, 0, Size - 1, nameof(idx));
ref short selfRef = ref Unsafe.As<Block8x8, short>(ref this);
return Unsafe.Add(ref selfRef, idx);
return Unsafe.Add(ref selfRef, (uint)idx);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@ -56,7 +56,7 @@ internal unsafe partial struct Block8x8
DebugGuard.MustBeBetweenOrEqualTo(idx, 0, Size - 1, nameof(idx));
ref short selfRef = ref Unsafe.As<Block8x8, short>(ref this);
Unsafe.Add(ref selfRef, idx) = value;
Unsafe.Add(ref selfRef, (uint)idx) = value;
}
}
@ -207,12 +207,12 @@ internal unsafe partial struct Block8x8
// Given mask is not actually suitable for lzcnt as 1's represent zero elements and 0's represent non-zero elements
// So we need to invert it
int lzcnt = BitOperations.LeadingZeroCount(~(uint)areEqual);
uint lzcnt = (uint)BitOperations.LeadingZeroCount(~(uint)areEqual);
// As input number is represented by 2 bits in the mask, we need to divide lzcnt result by 2
// to get the exact number of zero elements in the stride
int strideRelativeIndex = 15 - (lzcnt / 2);
return (i * 16) + strideRelativeIndex;
uint strideRelativeIndex = 15 - (lzcnt / 2);
return (i * 16) + (nint)strideRelativeIndex;
}
}

18
src/ImageSharp/Formats/Jpeg/Components/Block8x8F.Generated.cs

@ -44,31 +44,31 @@ internal partial struct Block8x8F
{
var off = new Vector<float>(MathF.Ceiling(maximum / 2));
var max = new Vector<float>(maximum);
ref Vector<float> row0 = ref Unsafe.As<Vector4, Vector<float>>(ref this.V0L);
row0 = NormalizeAndRound(row0, off, max);
ref Vector<float> row1 = ref Unsafe.As<Vector4, Vector<float>>(ref this.V1L);
row1 = NormalizeAndRound(row1, off, max);
ref Vector<float> row2 = ref Unsafe.As<Vector4, Vector<float>>(ref this.V2L);
row2 = NormalizeAndRound(row2, off, max);
ref Vector<float> row3 = ref Unsafe.As<Vector4, Vector<float>>(ref this.V3L);
row3 = NormalizeAndRound(row3, off, max);
ref Vector<float> row4 = ref Unsafe.As<Vector4, Vector<float>>(ref this.V4L);
row4 = NormalizeAndRound(row4, off, max);
ref Vector<float> row5 = ref Unsafe.As<Vector4, Vector<float>>(ref this.V5L);
row5 = NormalizeAndRound(row5, off, max);
ref Vector<float> row6 = ref Unsafe.As<Vector4, Vector<float>>(ref this.V6L);
row6 = NormalizeAndRound(row6, off, max);
ref Vector<float> row7 = ref Unsafe.As<Vector4, Vector<float>>(ref this.V7L);
row7 = NormalizeAndRound(row7, off, max);
}
/// <summary>

6
src/ImageSharp/Formats/Jpeg/Components/Block8x8F.Intrinsic.cs

@ -51,7 +51,7 @@ internal partial struct Block8x8F
Vector256<short> row = Avx2.PackSignedSaturate(row0, row1);
row = Avx2.PermuteVar8x32(row.AsInt32(), multiplyIntoInt16ShuffleMask).AsInt16();
Unsafe.Add(ref destRef, (IntPtr)((uint)i / 2)) = row;
Unsafe.Add(ref destRef, i / 2) = row;
}
}
@ -64,13 +64,13 @@ internal partial struct Block8x8F
ref Vector128<short> destBase = ref Unsafe.As<Block8x8, Vector128<short>>(ref dest);
for (int i = 0; i < 16; i += 2)
for (nint i = 0; i < 16; i += 2)
{
Vector128<int> left = Sse2.ConvertToVector128Int32(Sse.Multiply(Unsafe.Add(ref aBase, i + 0), Unsafe.Add(ref bBase, i + 0)));
Vector128<int> right = Sse2.ConvertToVector128Int32(Sse.Multiply(Unsafe.Add(ref aBase, i + 1), Unsafe.Add(ref bBase, i + 1)));
Vector128<short> row = Sse2.PackSignedSaturate(left, right);
Unsafe.Add(ref destBase, (IntPtr)((uint)i / 2)) = row;
Unsafe.Add(ref destBase, i / 2) = row;
}
}

12
src/ImageSharp/Formats/Jpeg/Components/Block8x8F.ScaledCopy.cs

@ -98,11 +98,11 @@ internal partial struct Block8x8F
int xx = x * horizontalScale;
float value = this[y8 + x];
nint baseIdx = (yy * areaStride) + xx;
nint baseIdx = (nint)(uint)((yy * areaStride) + xx);
for (nint i = 0; i < verticalScale; i++, baseIdx += areaStride)
{
for (nint j = 0; j < horizontalScale; j++)
for (nint j = 0; j < (uint)horizontalScale; j++)
{
// area[xx + j, yy + i] = value;
Unsafe.Add(ref areaOrigin, baseIdx + j) = value;
@ -128,8 +128,8 @@ internal partial struct Block8x8F
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static void CopyRowImpl(ref byte origin, ref byte dest, int destStride, int row)
{
origin = ref Unsafe.Add(ref origin, row * 8 * sizeof(float));
dest = ref Unsafe.Add(ref dest, row * destStride);
origin = ref Unsafe.Add(ref origin, (uint)row * 8 * sizeof(float));
dest = ref Unsafe.Add(ref dest, (uint)(row * destStride));
Unsafe.CopyBlock(ref dest, ref origin, 8 * sizeof(float));
}
}
@ -150,8 +150,8 @@ internal partial struct Block8x8F
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static void CopyRowImpl(ref byte origin, ref byte dest, int sourceStride, int row)
{
origin = ref Unsafe.Add(ref origin, row * sourceStride);
dest = ref Unsafe.Add(ref dest, row * 8 * sizeof(float));
origin = ref Unsafe.Add(ref origin, (uint)(row * sourceStride));
dest = ref Unsafe.Add(ref dest, (uint)row * 8 * sizeof(float));
Unsafe.CopyBlock(ref dest, ref origin, 8 * sizeof(float));
}
}

2
src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.GrayScaleScalar.cs

@ -28,7 +28,7 @@ internal abstract partial class JpegColorConverterBase
ref float valuesRef = ref MemoryMarshal.GetReference(values);
float scale = 1 / maxValue;
for (nint i = 0; i < values.Length; i++)
for (nint i = 0; i < (uint)values.Length; i++)
{
Unsafe.Add(ref valuesRef, i) *= scale;
}

4
src/ImageSharp/Formats/Jpeg/Components/Decoder/ArithmeticScanDecoder.cs

@ -705,7 +705,7 @@ internal class ArithmeticScanDecoder : IJpegScanDecoder
// Sections F.2.4.1 & F.1.4.4.1: Decoding of DC coefficients.
// Table F.4: Point to statistics bin S0 for DC coefficient coding.
ref byte st = ref Unsafe.Add(ref component.DcStatistics.GetReference(), component.DcContext);
ref byte st = ref Unsafe.Add(ref component.DcStatistics.GetReference(), (uint)component.DcContext);
// Figure F.19: Decode_DC_DIFF
if (this.DecodeBinaryDecision(ref reader, ref st) == 0)
@ -955,7 +955,7 @@ internal class ArithmeticScanDecoder : IJpegScanDecoder
// Sections F.2.4.1 & F.1.4.4.1: Decoding of DC coefficients.
// Table F.4: Point to statistics bin S0 for DC coefficient coding.
ref byte st = ref Unsafe.Add(ref component.DcStatistics.GetReference(), component.DcContext);
ref byte st = ref Unsafe.Add(ref component.DcStatistics.GetReference(), (uint)component.DcContext);
/* Figure F.19: Decode_DC_DIFF */
if (this.DecodeBinaryDecision(ref reader, ref st) == 0)

12
src/ImageSharp/Formats/Jpeg/Components/Decoder/HuffmanScanDecoder.cs

@ -211,7 +211,7 @@ internal class HuffmanScanDecoder : IJpegScanDecoder
this.DecodeBlockBaseline(
component,
ref Unsafe.Add(ref blockRef, blockCol),
ref Unsafe.Add(ref blockRef, (uint)blockCol),
ref dcHuffmanTable,
ref acHuffmanTable);
}
@ -255,7 +255,7 @@ internal class HuffmanScanDecoder : IJpegScanDecoder
this.DecodeBlockBaseline(
component,
ref Unsafe.Add(ref blockRef, i),
ref Unsafe.Add(ref blockRef, (uint)i),
ref dcHuffmanTable,
ref acHuffmanTable);
@ -297,7 +297,7 @@ internal class HuffmanScanDecoder : IJpegScanDecoder
this.DecodeBlockBaseline(
component,
ref Unsafe.Add(ref blockRef, k),
ref Unsafe.Add(ref blockRef, (uint)k),
ref dcHuffmanTable,
ref acHuffmanTable);
@ -417,7 +417,7 @@ internal class HuffmanScanDecoder : IJpegScanDecoder
this.DecodeBlockProgressiveDC(
component,
ref Unsafe.Add(ref blockRef, blockCol),
ref Unsafe.Add(ref blockRef, (uint)blockCol),
ref dcHuffmanTable);
}
}
@ -459,7 +459,7 @@ internal class HuffmanScanDecoder : IJpegScanDecoder
this.DecodeBlockProgressiveDC(
component,
ref Unsafe.Add(ref blockRef, i),
ref Unsafe.Add(ref blockRef, (uint)i),
ref dcHuffmanTable);
this.HandleRestart();
@ -485,7 +485,7 @@ internal class HuffmanScanDecoder : IJpegScanDecoder
}
this.DecodeBlockProgressiveAC(
ref Unsafe.Add(ref blockRef, i),
ref Unsafe.Add(ref blockRef, (uint)i),
ref acHuffmanTable);
this.HandleRestart();

12
src/ImageSharp/Formats/Jpeg/Components/Encoder/ComponentProcessor.cs

@ -141,7 +141,7 @@ internal class ComponentProcessor : IDisposable
ref float targetRef = ref MemoryMarshal.GetReference(target);
ref float sourceRef = ref MemoryMarshal.GetReference(source);
for (nint i = count * Vector<float>.Count; i < source.Length; i++)
for (nint i = count * Vector<float>.Count; i < (uint)source.Length; i++)
{
Unsafe.Add(ref targetRef, i) += Unsafe.Add(ref sourceRef, i);
}
@ -166,16 +166,16 @@ internal class ComponentProcessor : IDisposable
source = source.Slice(touchedCount);
target = target.Slice(touchedCount / factor);
uint length = (uint)touchedCount / (uint)Vector256<float>.Count;
nint length = (nint)(uint)touchedCount / Vector256<float>.Count;
for (int i = 0; i < haddIterationsCount; i++)
{
length /= 2;
for (nuint j = 0; j < length; j++)
for (nint j = 0; j < length; j++)
{
nuint indexLeft = j * 2;
nuint indexRight = indexLeft + 1;
nint indexLeft = j * 2;
nint indexRight = indexLeft + 1;
Vector256<float> sum = Avx.HorizontalAdd(Unsafe.Add(ref targetRef, indexLeft), Unsafe.Add(ref targetRef, indexRight));
Unsafe.Add(ref targetRef, j) = Avx2.Permute4x64(sum.AsDouble(), 0b11_01_10_00).AsSingle();
}
@ -219,7 +219,7 @@ internal class ComponentProcessor : IDisposable
}
ref float targetRef = ref MemoryMarshal.GetReference(target);
for (nint i = count * Vector<float>.Count; i < target.Length; i++)
for (nint i = count * Vector<float>.Count; i < (uint)target.Length; i++)
{
Unsafe.Add(ref targetRef, i) *= multiplier;
}

4
src/ImageSharp/Formats/Jpeg/Components/Encoder/HuffmanScanEncoder.cs

@ -180,7 +180,7 @@ internal class HuffmanScanEncoder
Span<Block8x8> blockSpan = component.SpectralBlocks.DangerousGetRowSpan(y: 0);
ref Block8x8 blockRef = ref MemoryMarshal.GetReference(blockSpan);
for (nint k = 0; k < w; k++)
for (nint k = 0; k < (uint)w; k++)
{
this.WriteBlock(
component,
@ -219,7 +219,7 @@ internal class HuffmanScanEncoder
Span<Block8x8> blockSpan = component.SpectralBlocks.DangerousGetRowSpan(y: i);
ref Block8x8 blockRef = ref MemoryMarshal.GetReference(blockSpan);
for (nint k = 0; k < w; k++)
for (nint k = 0; k < (uint)w; k++)
{
this.WriteBlock(
component,

16
src/ImageSharp/Formats/Png/Filters/AverageFilter.cs

@ -42,7 +42,7 @@ internal static class AverageFilter
}
else
{
DecodeScalar(scanline, previousScanline, bytesPerPixel);
DecodeScalar(scanline, previousScanline, (nint)(uint)bytesPerPixel);
}
}
@ -88,7 +88,7 @@ internal static class AverageFilter
Vector64<byte> d = Vector64<byte>.Zero;
int rb = scanline.Length;
int offset = 1;
nint offset = 1;
const int bytesPerBatch = 4;
while (rb >= bytesPerBatch)
{
@ -108,7 +108,7 @@ internal static class AverageFilter
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static void DecodeScalar(Span<byte> scanline, Span<byte> previousScanline, int bytesPerPixel)
private static void DecodeScalar(Span<byte> scanline, Span<byte> previousScanline, nint bytesPerPixel)
{
ref byte scanBaseRef = ref MemoryMarshal.GetReference(scanline);
ref byte prevBaseRef = ref MemoryMarshal.GetReference(previousScanline);
@ -121,7 +121,7 @@ internal static class AverageFilter
scan = (byte)(scan + (above >> 1));
}
for (; x < scanline.Length; ++x)
for (; x < (uint)scanline.Length; ++x)
{
ref byte scan = ref Unsafe.Add(ref scanBaseRef, x);
byte left = Unsafe.Add(ref scanBaseRef, x - bytesPerPixel);
@ -153,7 +153,7 @@ internal static class AverageFilter
resultBaseRef = (byte)FilterType.Average;
nint x = 0;
for (; x < bytesPerPixel; /* Note: ++x happens in the body to avoid one add operation */)
for (; x < (uint)bytesPerPixel; /* Note: ++x happens in the body to avoid one add operation */)
{
byte scan = Unsafe.Add(ref scanBaseRef, x);
byte above = Unsafe.Add(ref prevBaseRef, x);
@ -169,7 +169,7 @@ internal static class AverageFilter
Vector256<int> sumAccumulator = Vector256<int>.Zero;
Vector256<byte> allBitsSet = Avx2.CompareEqual(sumAccumulator, sumAccumulator).AsByte();
for (nint xLeft = x - bytesPerPixel; x <= scanline.Length - Vector256<byte>.Count; xLeft += Vector256<byte>.Count)
for (nint xLeft = x - (nint)(uint)bytesPerPixel; x <= (uint)scanline.Length - Vector256<byte>.Count; xLeft += Vector256<byte>.Count)
{
Vector256<byte> scan = Unsafe.As<byte, Vector256<byte>>(ref Unsafe.Add(ref scanBaseRef, x));
Vector256<byte> left = Unsafe.As<byte, Vector256<byte>>(ref Unsafe.Add(ref scanBaseRef, xLeft));
@ -192,7 +192,7 @@ internal static class AverageFilter
Vector128<int> sumAccumulator = Vector128<int>.Zero;
Vector128<byte> allBitsSet = Sse2.CompareEqual(sumAccumulator, sumAccumulator).AsByte();
for (nint xLeft = x - bytesPerPixel; x <= scanline.Length - Vector128<byte>.Count; xLeft += Vector128<byte>.Count)
for (nint xLeft = x - (nint)(uint)bytesPerPixel; x <= (uint)scanline.Length - Vector128<byte>.Count; xLeft += Vector128<byte>.Count)
{
Vector128<byte> scan = Unsafe.As<byte, Vector128<byte>>(ref Unsafe.Add(ref scanBaseRef, x));
Vector128<byte> left = Unsafe.As<byte, Vector128<byte>>(ref Unsafe.Add(ref scanBaseRef, xLeft));
@ -221,7 +221,7 @@ internal static class AverageFilter
sum += Numerics.EvenReduceSum(sumAccumulator);
}
for (nint xLeft = x - bytesPerPixel; x < scanline.Length; ++xLeft /* Note: ++x happens in the body to avoid one add operation */)
for (nint xLeft = x - (nint)(uint)bytesPerPixel; x < (uint)scanline.Length; ++xLeft /* Note: ++x happens in the body to avoid one add operation */)
{
byte scan = Unsafe.Add(ref scanBaseRef, x);
byte left = Unsafe.Add(ref scanBaseRef, xLeft);

12
src/ImageSharp/Formats/Png/Filters/PaethFilter.cs

@ -187,14 +187,14 @@ internal static class PaethFilter
// Paeth(x) + PaethPredictor(Raw(x-bpp), Prior(x), Prior(x-bpp))
int offset = bytesPerPixel + 1; // Add one because x starts at one.
nint x = 1;
for (; x < offset; x++)
for (; x < (uint)offset; x++)
{
ref byte scan = ref Unsafe.Add(ref scanBaseRef, x);
byte above = Unsafe.Add(ref prevBaseRef, x);
scan = (byte)(scan + above);
}
for (; x < scanline.Length; x++)
for (; x < (uint)scanline.Length; x++)
{
ref byte scan = ref Unsafe.Add(ref scanBaseRef, x);
byte left = Unsafe.Add(ref scanBaseRef, x - bytesPerPixel);
@ -227,7 +227,7 @@ internal static class PaethFilter
resultBaseRef = (byte)FilterType.Paeth;
nint x = 0;
for (; x < bytesPerPixel; /* Note: ++x happens in the body to avoid one add operation */)
for (; x < (uint)bytesPerPixel; /* Note: ++x happens in the body to avoid one add operation */)
{
byte scan = Unsafe.Add(ref scanBaseRef, x);
byte above = Unsafe.Add(ref prevBaseRef, x);
@ -242,7 +242,7 @@ internal static class PaethFilter
Vector256<byte> zero = Vector256<byte>.Zero;
Vector256<int> sumAccumulator = Vector256<int>.Zero;
for (nint xLeft = x - bytesPerPixel; x <= scanline.Length - Vector256<byte>.Count; xLeft += Vector256<byte>.Count)
for (nint xLeft = x - (nint)(uint)bytesPerPixel; x <= (nint)(uint)scanline.Length - Vector256<byte>.Count; xLeft += Vector256<byte>.Count)
{
Vector256<byte> scan = Unsafe.As<byte, Vector256<byte>>(ref Unsafe.Add(ref scanBaseRef, x));
Vector256<byte> left = Unsafe.As<byte, Vector256<byte>>(ref Unsafe.Add(ref scanBaseRef, xLeft));
@ -262,7 +262,7 @@ internal static class PaethFilter
{
Vector<uint> sumAccumulator = Vector<uint>.Zero;
for (nint xLeft = x - bytesPerPixel; x <= scanline.Length - Vector<byte>.Count; xLeft += Vector<byte>.Count)
for (nint xLeft = x - (nint)(uint)bytesPerPixel; x <= (nint)(uint)scanline.Length - Vector<byte>.Count; xLeft += Vector<byte>.Count)
{
Vector<byte> scan = Unsafe.As<byte, Vector<byte>>(ref Unsafe.Add(ref scanBaseRef, x));
Vector<byte> left = Unsafe.As<byte, Vector<byte>>(ref Unsafe.Add(ref scanBaseRef, xLeft));
@ -282,7 +282,7 @@ internal static class PaethFilter
}
}
for (nint xLeft = x - bytesPerPixel; x < scanline.Length; ++xLeft /* Note: ++x happens in the body to avoid one add operation */)
for (nint xLeft = x - (nint)(uint)bytesPerPixel; x < (nint)(uint)scanline.Length; ++xLeft /* Note: ++x happens in the body to avoid one add operation */)
{
byte scan = Unsafe.Add(ref scanBaseRef, x);
byte left = Unsafe.Add(ref scanBaseRef, xLeft);

14
src/ImageSharp/Formats/Png/Filters/SubFilter.cs

@ -36,7 +36,7 @@ internal static class SubFilter
}
else
{
DecodeScalar(scanline, bytesPerPixel);
DecodeScalar(scanline, (nint)(uint)bytesPerPixel);
}
}
@ -70,7 +70,7 @@ internal static class SubFilter
Vector64<byte> d = Vector64<byte>.Zero;
int rb = scanline.Length;
int offset = 1;
nint offset = 1;
const int bytesPerBatch = 4;
while (rb >= bytesPerBatch)
{
@ -87,7 +87,7 @@ internal static class SubFilter
}
}
private static void DecodeScalar(Span<byte> scanline, int bytesPerPixel)
private static void DecodeScalar(Span<byte> scanline, nint bytesPerPixel)
{
ref byte scanBaseRef = ref MemoryMarshal.GetReference(scanline);
@ -122,7 +122,7 @@ internal static class SubFilter
resultBaseRef = (byte)FilterType.Sub;
nint x = 0;
for (; x < bytesPerPixel; /* Note: ++x happens in the body to avoid one add operation */)
for (; x < (nint)(uint)bytesPerPixel; /* Note: ++x happens in the body to avoid one add operation */)
{
byte scan = Unsafe.Add(ref scanBaseRef, x);
++x;
@ -136,7 +136,7 @@ internal static class SubFilter
Vector256<byte> zero = Vector256<byte>.Zero;
Vector256<int> sumAccumulator = Vector256<int>.Zero;
for (nint xLeft = x - bytesPerPixel; x <= scanline.Length - Vector256<byte>.Count; xLeft += Vector256<byte>.Count)
for (nint xLeft = x - (nint)(uint)bytesPerPixel; x <= (nint)(uint)scanline.Length - Vector256<byte>.Count; xLeft += Vector256<byte>.Count)
{
Vector256<byte> scan = Unsafe.As<byte, Vector256<byte>>(ref Unsafe.Add(ref scanBaseRef, x));
Vector256<byte> prev = Unsafe.As<byte, Vector256<byte>>(ref Unsafe.Add(ref scanBaseRef, xLeft));
@ -154,7 +154,7 @@ internal static class SubFilter
{
Vector<uint> sumAccumulator = Vector<uint>.Zero;
for (nint xLeft = x - bytesPerPixel; x <= scanline.Length - Vector<byte>.Count; xLeft += Vector<byte>.Count)
for (nint xLeft = x - (nint)(uint)bytesPerPixel; x <= (nint)(uint)scanline.Length - Vector<byte>.Count; xLeft += Vector<byte>.Count)
{
Vector<byte> scan = Unsafe.As<byte, Vector<byte>>(ref Unsafe.Add(ref scanBaseRef, x));
Vector<byte> prev = Unsafe.As<byte, Vector<byte>>(ref Unsafe.Add(ref scanBaseRef, xLeft));
@ -172,7 +172,7 @@ internal static class SubFilter
}
}
for (nint xLeft = x - bytesPerPixel; x < scanline.Length; ++xLeft /* Note: ++x happens in the body to avoid one add operation */)
for (nint xLeft = x - (nint)(uint)bytesPerPixel; x < (nint)(uint)scanline.Length; ++xLeft /* Note: ++x happens in the body to avoid one add operation */)
{
byte scan = Unsafe.Add(ref scanBaseRef, x);
byte prev = Unsafe.Add(ref scanBaseRef, xLeft);

14
src/ImageSharp/Formats/Png/Filters/UpFilter.cs

@ -66,7 +66,7 @@ internal static class UpFilter
}
// Handle left over.
for (nint i = offset; i < scanline.Length; i++)
for (nint i = offset; i < (uint)scanline.Length; i++)
{
ref byte scan = ref Unsafe.Add(ref scanBaseRef, offset);
byte above = Unsafe.Add(ref prevBaseRef, offset);
@ -96,7 +96,7 @@ internal static class UpFilter
}
// Handle left over.
for (nint i = offset; i < scanline.Length; i++)
for (nint i = offset; i < (uint)scanline.Length; i++)
{
ref byte scan = ref Unsafe.Add(ref scanBaseRef, offset);
byte above = Unsafe.Add(ref prevBaseRef, offset);
@ -127,7 +127,7 @@ internal static class UpFilter
}
// Handle left over.
for (nint i = offset; i < scanline.Length; i++)
for (nint i = offset; i < (uint)scanline.Length; i++)
{
ref byte scan = ref Unsafe.Add(ref scanBaseRef, offset);
byte above = Unsafe.Add(ref prevBaseRef, offset);
@ -143,7 +143,7 @@ internal static class UpFilter
ref byte prevBaseRef = ref MemoryMarshal.GetReference(previousScanline);
// Up(x) + Prior(x)
for (nint x = 1; x < scanline.Length; x++)
for (nint x = 1; x < (uint)scanline.Length; x++)
{
ref byte scan = ref Unsafe.Add(ref scanBaseRef, x);
byte above = Unsafe.Add(ref prevBaseRef, x);
@ -179,7 +179,7 @@ internal static class UpFilter
Vector256<byte> zero = Vector256<byte>.Zero;
Vector256<int> sumAccumulator = Vector256<int>.Zero;
for (; x <= scanline.Length - Vector256<byte>.Count;)
for (; x <= (nint)(uint)(scanline.Length - Vector256<byte>.Count);)
{
Vector256<byte> scan = Unsafe.As<byte, Vector256<byte>>(ref Unsafe.Add(ref scanBaseRef, x));
Vector256<byte> above = Unsafe.As<byte, Vector256<byte>>(ref Unsafe.Add(ref prevBaseRef, x));
@ -197,7 +197,7 @@ internal static class UpFilter
{
Vector<uint> sumAccumulator = Vector<uint>.Zero;
for (; x <= scanline.Length - Vector<byte>.Count;)
for (; x <= (nint)(uint)(scanline.Length - Vector<byte>.Count);)
{
Vector<byte> scan = Unsafe.As<byte, Vector<byte>>(ref Unsafe.Add(ref scanBaseRef, x));
Vector<byte> above = Unsafe.As<byte, Vector<byte>>(ref Unsafe.Add(ref prevBaseRef, x));
@ -215,7 +215,7 @@ internal static class UpFilter
}
}
for (; x < scanline.Length; /* Note: ++x happens in the body to avoid one add operation */)
for (; x < (nint)(uint)scanline.Length; /* Note: ++x happens in the body to avoid one add operation */)
{
byte scan = Unsafe.Add(ref scanBaseRef, x);
byte above = Unsafe.Add(ref prevBaseRef, x);

4
src/ImageSharp/Formats/Png/PngDecoderCore.cs

@ -414,11 +414,11 @@ internal sealed class PngDecoderCore : IImageDecoderInternals
for (int i = 0; i < bytesPerScanline; i++)
{
byte b = Unsafe.Add(ref sourceRef, i);
byte b = Unsafe.Add(ref sourceRef, (uint)i);
for (int shift = 0; shift < 8; shift += bits)
{
int colorIndex = (b >> (8 - bits - shift)) & mask;
Unsafe.Add(ref resultRef, resultOffset) = (byte)colorIndex;
Unsafe.Add(ref resultRef, (uint)resultOffset) = (byte)colorIndex;
resultOffset++;
}
}

14
src/ImageSharp/Formats/Png/PngEncoderCore.cs

@ -266,7 +266,7 @@ internal sealed class PngEncoderCore : IImageEncoderInternals, IDisposable
// Can't map directly to byte array as it's big-endian.
for (int x = 0, o = 0; x < luminanceSpan.Length; x++, o += 2)
{
L16 luminance = Unsafe.Add(ref luminanceRef, x);
L16 luminance = Unsafe.Add(ref luminanceRef, (uint)x);
BinaryPrimitives.WriteUInt16BigEndian(rawScanlineSpan.Slice(o, 2), luminance.PackedValue);
}
}
@ -306,7 +306,7 @@ internal sealed class PngEncoderCore : IImageEncoderInternals, IDisposable
// Can't map directly to byte array as it's big endian.
for (int x = 0, o = 0; x < laSpan.Length; x++, o += 4)
{
La32 la = Unsafe.Add(ref laRef, x);
La32 la = Unsafe.Add(ref laRef, (uint)x);
BinaryPrimitives.WriteUInt16BigEndian(rawScanlineSpan.Slice(o, 2), la.L);
BinaryPrimitives.WriteUInt16BigEndian(rawScanlineSpan.Slice(o + 2, 2), la.A);
}
@ -366,7 +366,7 @@ internal sealed class PngEncoderCore : IImageEncoderInternals, IDisposable
// Can't map directly to byte array as it's big endian.
for (int x = 0, o = 0; x < rowSpan.Length; x++, o += 8)
{
Rgba64 rgba = Unsafe.Add(ref rgbaRef, x);
Rgba64 rgba = Unsafe.Add(ref rgbaRef, (uint)x);
BinaryPrimitives.WriteUInt16BigEndian(rawScanlineSpan.Slice(o, 2), rgba.R);
BinaryPrimitives.WriteUInt16BigEndian(rawScanlineSpan.Slice(o + 2, 2), rgba.G);
BinaryPrimitives.WriteUInt16BigEndian(rawScanlineSpan.Slice(o + 4, 2), rgba.B);
@ -388,7 +388,7 @@ internal sealed class PngEncoderCore : IImageEncoderInternals, IDisposable
// Can't map directly to byte array as it's big endian.
for (int x = 0, o = 0; x < rowSpan.Length; x++, o += 6)
{
Rgb48 rgb = Unsafe.Add(ref rgbRef, x);
Rgb48 rgb = Unsafe.Add(ref rgbRef, (uint)x);
BinaryPrimitives.WriteUInt16BigEndian(rawScanlineSpan.Slice(o, 2), rgb.R);
BinaryPrimitives.WriteUInt16BigEndian(rawScanlineSpan.Slice(o + 2, 2), rgb.G);
BinaryPrimitives.WriteUInt16BigEndian(rawScanlineSpan.Slice(o + 4, 2), rgb.B);
@ -617,17 +617,17 @@ internal sealed class PngEncoderCore : IImageEncoderInternals, IDisposable
// Loop, assign, and extract alpha values from the palette.
for (int i = 0; i < paletteLength; i++)
{
Rgba32 rgba = Unsafe.Add(ref rgbaPaletteRef, i);
Rgba32 rgba = Unsafe.Add(ref rgbaPaletteRef, (uint)i);
byte alpha = rgba.A;
Unsafe.Add(ref colorTableRef, i) = rgba.Rgb;
Unsafe.Add(ref colorTableRef, (uint)i) = rgba.Rgb;
if (alpha > this.encoder.Threshold)
{
alpha = byte.MaxValue;
}
hasAlpha = hasAlpha || alpha < byte.MaxValue;
Unsafe.Add(ref alphaTableRef, i) = alpha;
Unsafe.Add(ref alphaTableRef, (uint)i) = alpha;
}
this.WriteChunk(stream, PngChunkType.Palette, colorTable.GetSpan(), 0, colorTableLength);

6
src/ImageSharp/Formats/Png/PngEncoderHelpers.cs

@ -31,13 +31,13 @@ internal static class PngEncoderHelpers
for (int i = 0; i < source.Length; i++)
{
int value = ((int)MathF.Round(Unsafe.Add(ref sourceRef, i) / scale)) & mask;
int value = ((int)MathF.Round(Unsafe.Add(ref sourceRef, (uint)i) / scale)) & mask;
v |= value << shift;
if (shift == 0)
{
shift = shift0;
Unsafe.Add(ref resultRef, resultOffset) = (byte)v;
Unsafe.Add(ref resultRef, (uint)resultOffset) = (byte)v;
resultOffset++;
v = 0;
}
@ -49,7 +49,7 @@ internal static class PngEncoderHelpers
if (shift != shift0)
{
Unsafe.Add(ref resultRef, resultOffset) = (byte)v;
Unsafe.Add(ref resultRef, (uint)resultOffset) = (byte)v;
}
}
}

110
src/ImageSharp/Formats/Png/PngScanlineProcessor.cs

@ -36,16 +36,16 @@ internal static class PngScanlineProcessor
{
ushort luminance = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o, 2));
pixel.FromL16(Unsafe.As<ushort, L16>(ref luminance));
Unsafe.Add(ref rowSpanRef, x) = pixel;
Unsafe.Add(ref rowSpanRef, (uint)x) = pixel;
}
}
else
{
for (int x = 0; x < header.Width; x++)
{
byte luminance = (byte)(Unsafe.Add(ref scanlineSpanRef, x) * scaleFactor);
byte luminance = (byte)(Unsafe.Add(ref scanlineSpanRef, (uint)x) * scaleFactor);
pixel.FromL8(Unsafe.As<byte, L8>(ref luminance));
Unsafe.Add(ref rowSpanRef, x) = pixel;
Unsafe.Add(ref rowSpanRef, (uint)x) = pixel;
}
}
@ -62,7 +62,7 @@ internal static class PngScanlineProcessor
source.A = luminance.Equals(luminance16Trans.PackedValue) ? ushort.MinValue : ushort.MaxValue;
pixel.FromLa32(source);
Unsafe.Add(ref rowSpanRef, x) = pixel;
Unsafe.Add(ref rowSpanRef, (uint)x) = pixel;
}
}
else
@ -71,12 +71,12 @@ internal static class PngScanlineProcessor
byte scaledLuminanceTrans = (byte)(luminanceTrans.PackedValue * scaleFactor);
for (int x = 0; x < header.Width; x++)
{
byte luminance = (byte)(Unsafe.Add(ref scanlineSpanRef, x) * scaleFactor);
byte luminance = (byte)(Unsafe.Add(ref scanlineSpanRef, (uint)x) * scaleFactor);
source.L = luminance;
source.A = luminance.Equals(scaledLuminanceTrans) ? byte.MinValue : byte.MaxValue;
pixel.FromLa16(source);
Unsafe.Add(ref rowSpanRef, x) = pixel;
Unsafe.Add(ref rowSpanRef, (uint)x) = pixel;
}
}
}
@ -105,16 +105,16 @@ internal static class PngScanlineProcessor
{
ushort luminance = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o, 2));
pixel.FromL16(Unsafe.As<ushort, L16>(ref luminance));
Unsafe.Add(ref rowSpanRef, x) = pixel;
Unsafe.Add(ref rowSpanRef, (uint)x) = pixel;
}
}
else
{
for (int x = pixelOffset, o = 0; x < header.Width; x += increment, o++)
{
byte luminance = (byte)(Unsafe.Add(ref scanlineSpanRef, o) * scaleFactor);
byte luminance = (byte)(Unsafe.Add(ref scanlineSpanRef, (uint)o) * scaleFactor);
pixel.FromL8(Unsafe.As<byte, L8>(ref luminance));
Unsafe.Add(ref rowSpanRef, x) = pixel;
Unsafe.Add(ref rowSpanRef, (uint)x) = pixel;
}
}
@ -131,7 +131,7 @@ internal static class PngScanlineProcessor
source.A = luminance.Equals(luminance16Trans.PackedValue) ? ushort.MinValue : ushort.MaxValue;
pixel.FromLa32(source);
Unsafe.Add(ref rowSpanRef, x) = pixel;
Unsafe.Add(ref rowSpanRef, (uint)x) = pixel;
}
}
else
@ -140,12 +140,12 @@ internal static class PngScanlineProcessor
byte scaledLuminanceTrans = (byte)(luminanceTrans.PackedValue * scaleFactor);
for (int x = pixelOffset, o = 0; x < header.Width; x += increment, o++)
{
byte luminance = (byte)(Unsafe.Add(ref scanlineSpanRef, o) * scaleFactor);
byte luminance = (byte)(Unsafe.Add(ref scanlineSpanRef, (uint)o) * scaleFactor);
source.L = luminance;
source.A = luminance.Equals(scaledLuminanceTrans) ? byte.MinValue : byte.MaxValue;
pixel.FromLa16(source);
Unsafe.Add(ref rowSpanRef, x) = pixel;
Unsafe.Add(ref rowSpanRef, (uint)x) = pixel;
}
}
}
@ -171,7 +171,7 @@ internal static class PngScanlineProcessor
source.A = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + 2, 2));
pixel.FromLa32(source);
Unsafe.Add(ref rowSpanRef, x) = pixel;
Unsafe.Add(ref rowSpanRef, (uint)x) = pixel;
}
}
else
@ -180,11 +180,11 @@ internal static class PngScanlineProcessor
for (int x = 0; x < header.Width; x++)
{
int offset = x * bytesPerPixel;
source.L = Unsafe.Add(ref scanlineSpanRef, offset);
source.A = Unsafe.Add(ref scanlineSpanRef, offset + bytesPerSample);
source.L = Unsafe.Add(ref scanlineSpanRef, (uint)offset);
source.A = Unsafe.Add(ref scanlineSpanRef, (uint)(offset + bytesPerSample));
pixel.FromLa16(source);
Unsafe.Add(ref rowSpanRef, x) = pixel;
Unsafe.Add(ref rowSpanRef, (uint)x) = pixel;
}
}
}
@ -212,7 +212,7 @@ internal static class PngScanlineProcessor
source.A = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + 2, 2));
pixel.FromLa32(source);
Unsafe.Add(ref rowSpanRef, x) = pixel;
Unsafe.Add(ref rowSpanRef, (uint)x) = pixel;
}
}
else
@ -221,11 +221,11 @@ internal static class PngScanlineProcessor
La16 source = default;
for (int x = pixelOffset; x < header.Width; x += increment)
{
source.L = Unsafe.Add(ref scanlineSpanRef, offset);
source.A = Unsafe.Add(ref scanlineSpanRef, offset + bytesPerSample);
source.L = Unsafe.Add(ref scanlineSpanRef, (uint)offset);
source.A = Unsafe.Add(ref scanlineSpanRef, (uint)(offset + bytesPerSample));
pixel.FromLa16(source);
Unsafe.Add(ref rowSpanRef, x) = pixel;
Unsafe.Add(ref rowSpanRef, (uint)x) = pixel;
offset += bytesPerPixel;
}
}
@ -259,23 +259,23 @@ internal static class PngScanlineProcessor
for (int x = 0; x < header.Width; x++)
{
int index = Unsafe.Add(ref scanlineSpanRef, x);
rgba.Rgb = Unsafe.Add(ref palettePixelsRef, index);
rgba.A = paletteAlpha.Length > index ? Unsafe.Add(ref paletteAlphaRef, index) : byte.MaxValue;
int index = Unsafe.Add(ref scanlineSpanRef, (uint)x);
rgba.Rgb = Unsafe.Add(ref palettePixelsRef, (uint)index);
rgba.A = paletteAlpha.Length > index ? Unsafe.Add(ref paletteAlphaRef, (uint)index) : byte.MaxValue;
pixel.FromRgba32(rgba);
Unsafe.Add(ref rowSpanRef, x) = pixel;
Unsafe.Add(ref rowSpanRef, (uint)x) = pixel;
}
}
else
{
for (int x = 0; x < header.Width; x++)
{
int index = Unsafe.Add(ref scanlineSpanRef, x);
Rgb24 rgb = Unsafe.Add(ref palettePixelsRef, index);
int index = Unsafe.Add(ref scanlineSpanRef, (uint)x);
Rgb24 rgb = Unsafe.Add(ref palettePixelsRef, (uint)index);
pixel.FromRgb24(rgb);
Unsafe.Add(ref rowSpanRef, x) = pixel;
Unsafe.Add(ref rowSpanRef, (uint)x) = pixel;
}
}
}
@ -304,23 +304,23 @@ internal static class PngScanlineProcessor
ref byte paletteAlphaRef = ref paletteAlpha[0];
for (int x = pixelOffset, o = 0; x < header.Width; x += increment, o++)
{
int index = Unsafe.Add(ref scanlineSpanRef, o);
rgba.A = paletteAlpha.Length > index ? Unsafe.Add(ref paletteAlphaRef, index) : byte.MaxValue;
rgba.Rgb = Unsafe.Add(ref palettePixelsRef, index);
int index = Unsafe.Add(ref scanlineSpanRef, (uint)o);
rgba.A = paletteAlpha.Length > index ? Unsafe.Add(ref paletteAlphaRef, (uint)index) : byte.MaxValue;
rgba.Rgb = Unsafe.Add(ref palettePixelsRef, (uint)index);
pixel.FromRgba32(rgba);
Unsafe.Add(ref rowSpanRef, x) = pixel;
Unsafe.Add(ref rowSpanRef, (uint)x) = pixel;
}
}
else
{
for (int x = pixelOffset, o = 0; x < header.Width; x += increment, o++)
{
int index = Unsafe.Add(ref scanlineSpanRef, o);
Rgb24 rgb = Unsafe.Add(ref palettePixelsRef, index);
int index = Unsafe.Add(ref scanlineSpanRef, (uint)o);
Rgb24 rgb = Unsafe.Add(ref palettePixelsRef, (uint)index);
pixel.FromRgb24(rgb);
Unsafe.Add(ref rowSpanRef, x) = pixel;
Unsafe.Add(ref rowSpanRef, (uint)x) = pixel;
}
}
}
@ -352,7 +352,7 @@ internal static class PngScanlineProcessor
rgb48.B = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + (2 * bytesPerSample), bytesPerSample));
pixel.FromRgb48(rgb48);
Unsafe.Add(ref rowSpanRef, x) = pixel;
Unsafe.Add(ref rowSpanRef, (uint)x) = pixel;
}
}
else
@ -377,7 +377,7 @@ internal static class PngScanlineProcessor
rgba64.A = rgb48.Equals(rgb48Trans) ? ushort.MinValue : ushort.MaxValue;
pixel.FromRgba64(rgba64);
Unsafe.Add(ref rowSpanRef, x) = pixel;
Unsafe.Add(ref rowSpanRef, (uint)x) = pixel;
}
}
else
@ -387,12 +387,12 @@ internal static class PngScanlineProcessor
ref Rgb24 rgb24SpanRef = ref MemoryMarshal.GetReference(rgb24Span);
for (int x = 0; x < header.Width; x++)
{
ref readonly Rgb24 rgb24 = ref Unsafe.Add(ref rgb24SpanRef, x);
ref readonly Rgb24 rgb24 = ref Unsafe.Add(ref rgb24SpanRef, (uint)x);
rgba32.Rgb = rgb24;
rgba32.A = rgb24.Equals(rgb24Trans) ? byte.MinValue : byte.MaxValue;
pixel.FromRgba32(rgba32);
Unsafe.Add(ref rowSpanRef, x) = pixel;
Unsafe.Add(ref rowSpanRef, (uint)x) = pixel;
}
}
}
@ -430,7 +430,7 @@ internal static class PngScanlineProcessor
rgba64.A = rgb48.Equals(rgb48Trans) ? ushort.MinValue : ushort.MaxValue;
pixel.FromRgba64(rgba64);
Unsafe.Add(ref rowSpanRef, x) = pixel;
Unsafe.Add(ref rowSpanRef, (uint)x) = pixel;
}
}
else
@ -443,7 +443,7 @@ internal static class PngScanlineProcessor
rgb48.B = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + (2 * bytesPerSample), bytesPerSample));
pixel.FromRgb48(rgb48);
Unsafe.Add(ref rowSpanRef, x) = pixel;
Unsafe.Add(ref rowSpanRef, (uint)x) = pixel;
}
}
@ -455,13 +455,13 @@ internal static class PngScanlineProcessor
Rgba32 rgba = default;
for (int x = pixelOffset, o = 0; x < header.Width; x += increment, o += bytesPerPixel)
{
rgba.R = Unsafe.Add(ref scanlineSpanRef, o);
rgba.G = Unsafe.Add(ref scanlineSpanRef, o + bytesPerSample);
rgba.B = Unsafe.Add(ref scanlineSpanRef, o + (2 * bytesPerSample));
rgba.R = Unsafe.Add(ref scanlineSpanRef, (uint)o);
rgba.G = Unsafe.Add(ref scanlineSpanRef, (uint)(o + bytesPerSample));
rgba.B = Unsafe.Add(ref scanlineSpanRef, (uint)(o + (2 * bytesPerSample)));
rgba.A = rgb24Trans.Equals(rgba.Rgb) ? byte.MinValue : byte.MaxValue;
pixel.FromRgba32(rgba);
Unsafe.Add(ref rowSpanRef, x) = pixel;
Unsafe.Add(ref rowSpanRef, (uint)x) = pixel;
}
}
else
@ -469,12 +469,12 @@ internal static class PngScanlineProcessor
Rgb24 rgb = default;
for (int x = pixelOffset, o = 0; x < header.Width; x += increment, o += bytesPerPixel)
{
rgb.R = Unsafe.Add(ref scanlineSpanRef, o);
rgb.G = Unsafe.Add(ref scanlineSpanRef, o + bytesPerSample);
rgb.B = Unsafe.Add(ref scanlineSpanRef, o + (2 * bytesPerSample));
rgb.R = Unsafe.Add(ref scanlineSpanRef, (uint)o);
rgb.G = Unsafe.Add(ref scanlineSpanRef, (uint)(o + bytesPerSample));
rgb.B = Unsafe.Add(ref scanlineSpanRef, (uint)(o + (2 * bytesPerSample)));
pixel.FromRgb24(rgb);
Unsafe.Add(ref rowSpanRef, x) = pixel;
Unsafe.Add(ref rowSpanRef, (uint)x) = pixel;
}
}
}
@ -502,7 +502,7 @@ internal static class PngScanlineProcessor
rgba64.A = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + (3 * bytesPerSample), bytesPerSample));
pixel.FromRgba64(rgba64);
Unsafe.Add(ref rowSpanRef, x) = pixel;
Unsafe.Add(ref rowSpanRef, (uint)x) = pixel;
}
}
else
@ -536,7 +536,7 @@ internal static class PngScanlineProcessor
rgba64.A = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + (3 * bytesPerSample), bytesPerSample));
pixel.FromRgba64(rgba64);
Unsafe.Add(ref rowSpanRef, x) = pixel;
Unsafe.Add(ref rowSpanRef, (uint)x) = pixel;
}
}
else
@ -544,13 +544,13 @@ internal static class PngScanlineProcessor
Rgba32 rgba = default;
for (int x = pixelOffset, o = 0; x < header.Width; x += increment, o += bytesPerPixel)
{
rgba.R = Unsafe.Add(ref scanlineSpanRef, o);
rgba.G = Unsafe.Add(ref scanlineSpanRef, o + bytesPerSample);
rgba.B = Unsafe.Add(ref scanlineSpanRef, o + (2 * bytesPerSample));
rgba.A = Unsafe.Add(ref scanlineSpanRef, o + (3 * bytesPerSample));
rgba.R = Unsafe.Add(ref scanlineSpanRef, (uint)o);
rgba.G = Unsafe.Add(ref scanlineSpanRef, (uint)(o + bytesPerSample));
rgba.B = Unsafe.Add(ref scanlineSpanRef, (uint)(o + (2 * bytesPerSample)));
rgba.A = Unsafe.Add(ref scanlineSpanRef, (uint)(o + (3 * bytesPerSample)));
pixel.FromRgba32(rgba);
Unsafe.Add(ref rowSpanRef, x) = pixel;
Unsafe.Add(ref rowSpanRef, (uint)x) = pixel;
}
}
}

2
src/ImageSharp/Formats/Tiff/Compression/Decompressors/T6TiffCompression.cs

@ -78,7 +78,7 @@ internal sealed class T6TiffCompression : TiffBaseDecompressor
nint bitPos = Numerics.Modulo8(bitsWritten);
nint bufferPos = bitsWritten / 8;
ref byte scanLineRef = ref MemoryMarshal.GetReference(scanLine);
for (nint i = 0; i < scanLine.Length; i++)
for (nint i = 0; i < (uint)scanLine.Length; i++)
{
if (Unsafe.Add(ref scanLineRef, i) != this.white)
{

6
src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZero1TiffColor{TPixel}.cs

@ -29,7 +29,7 @@ internal class BlackIsZero1TiffColor<TPixel> : TiffBaseColorDecoder<TPixel>
{
Span<TPixel> pixelRowSpan = pixels.DangerousGetRowSpan((int)y);
ref TPixel pixelRowRef = ref MemoryMarshal.GetReference(pixelRowSpan);
for (nint x = left; x < left + width; x += 8)
for (nint x = (nint)(uint)left; x < (nint)(uint)(left + width); x += 8)
{
byte b = Unsafe.Add(ref dataRef, offset++);
nint maxShift = Math.Min(left + width - x, 8);
@ -70,9 +70,9 @@ internal class BlackIsZero1TiffColor<TPixel> : TiffBaseColorDecoder<TPixel>
}
else
{
for (int shift = 0; shift < maxShift; shift++)
for (nint shift = 0; shift < maxShift; shift++)
{
int bit = (b >> (7 - shift)) & 1;
int bit = (b >> (7 - (int)shift)) & 1;
ref TPixel pixel = ref Unsafe.Add(ref pixelRowRef, x + shift);
pixel = bit == 0 ? colorBlack : colorWhite;

6
src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero1TiffColor{TPixel}.cs

@ -24,11 +24,11 @@ internal class WhiteIsZero1TiffColor<TPixel> : TiffBaseColorDecoder<TPixel>
colorBlack.FromRgba32(Color.Black);
colorWhite.FromRgba32(Color.White);
ref byte dataRef = ref MemoryMarshal.GetReference(data);
for (nint y = top; y < top + height; y++)
for (nint y = top; y < (nint)(uint)(top + height); y++)
{
Span<TPixel> pixelRowSpan = pixels.DangerousGetRowSpan((int)y);
ref TPixel pixelRowRef = ref MemoryMarshal.GetReference(pixelRowSpan);
for (nint x = left; x < left + width; x += 8)
for (nint x = left; x < (nint)(uint)(left + width); x += 8)
{
byte b = Unsafe.Add(ref dataRef, offset++);
nint maxShift = Math.Min(left + width - x, 8);
@ -73,7 +73,7 @@ internal class WhiteIsZero1TiffColor<TPixel> : TiffBaseColorDecoder<TPixel>
{
int bit = (b >> (7 - shift)) & 1;
ref TPixel pixel = ref Unsafe.Add(ref pixelRowRef, x + shift);
ref TPixel pixel = ref Unsafe.Add(ref pixelRowRef, x + (nint)(uint)shift);
pixel = bit == 0 ? colorWhite : colorBlack;
}
}

11
src/ImageSharp/Formats/Webp/AlphaDecoder.cs

@ -322,7 +322,8 @@ internal class AlphaDecoder : IDisposable
nint i;
Vector128<int> last = Vector128<int>.Zero.WithElement(0, dst[0]);
ref byte srcRef = ref MemoryMarshal.GetReference(input);
for (i = 1; i + 8 <= width; i += 8)
ref byte dstRef = ref MemoryMarshal.GetReference(dst);
for (i = 1; i <= (uint)width - 8; i += 8)
{
Vector128<long> a0 = Vector128.Create(Unsafe.As<byte, long>(ref Unsafe.Add(ref srcRef, i)), 0);
Vector128<byte> a1 = Sse2.Add(a0.AsByte(), last.AsByte());
@ -333,12 +334,12 @@ internal class AlphaDecoder : IDisposable
Vector128<byte> a6 = Sse2.ShiftLeftLogical128BitLane(a5, 4);
Vector128<byte> a7 = Sse2.Add(a5, a6);
ref byte outputRef = ref Unsafe.Add(ref MemoryMarshal.GetReference(dst), i);
ref byte outputRef = ref Unsafe.Add(ref dstRef, i);
Unsafe.As<byte, Vector64<byte>>(ref outputRef) = a7.GetLower();
last = Sse2.ShiftRightLogical(a7.AsInt64(), 56).AsInt32();
}
for (; i < width; ++i)
for (; i < (uint)width; ++i)
{
dst[(int)i] = (byte)(input[(int)i] + dst[(int)i - 1]);
}
@ -366,7 +367,7 @@ internal class AlphaDecoder : IDisposable
{
nint i;
int maxPos = width & ~31;
for (i = 0; i < maxPos; i += 32)
for (i = 0; i < (uint)maxPos; i += 32)
{
Vector256<int> a0 = Unsafe.As<byte, Vector256<int>>(ref Unsafe.Add(ref MemoryMarshal.GetReference(input), i));
Vector256<int> b0 = Unsafe.As<byte, Vector256<int>>(ref Unsafe.Add(ref MemoryMarshal.GetReference(prev), i));
@ -375,7 +376,7 @@ internal class AlphaDecoder : IDisposable
Unsafe.As<byte, Vector256<byte>>(ref outputRef) = c0;
}
for (; i < width; i++)
for (; i < (uint) width; i++)
{
dst[(int)i] = (byte)(prev[(int)i] + input[(int)i]);
}

22
src/ImageSharp/Formats/Webp/Lossless/LosslessUtils.cs

@ -51,7 +51,7 @@ internal static unsafe class LosslessUtils
ref uint array1Ref = ref MemoryMarshal.GetReference(array1);
ref uint array2Ref = ref MemoryMarshal.GetReference(array2);
while (matchLen < length && Unsafe.Add(ref array1Ref, matchLen) == Unsafe.Add(ref array2Ref, matchLen))
while (matchLen < length && Unsafe.Add(ref array1Ref, (uint)matchLen) == Unsafe.Add(ref array2Ref, (uint)matchLen))
{
matchLen++;
}
@ -99,7 +99,7 @@ internal static unsafe class LosslessUtils
Vector256<byte> addGreenToBlueAndRedMaskAvx2 = Vector256.Create(1, 255, 1, 255, 5, 255, 5, 255, 9, 255, 9, 255, 13, 255, 13, 255, 17, 255, 17, 255, 21, 255, 21, 255, 25, 255, 25, 255, 29, 255, 29, 255);
int numPixels = pixelData.Length;
nint i;
for (i = 0; i <= numPixels - 8; i += 8)
for (i = 0; i <= (nint)(uint)numPixels - 8; i += 8)
{
ref uint pos = ref Unsafe.Add(ref MemoryMarshal.GetReference(pixelData), i);
Vector256<byte> input = Unsafe.As<uint, Vector256<uint>>(ref pos).AsByte();
@ -118,7 +118,7 @@ internal static unsafe class LosslessUtils
Vector128<byte> addGreenToBlueAndRedMaskSsse3 = Vector128.Create(1, 255, 1, 255, 5, 255, 5, 255, 9, 255, 9, 255, 13, 255, 13, 255);
int numPixels = pixelData.Length;
nint i;
for (i = 0; i <= numPixels - 4; i += 4)
for (i = 0; i <= (nint)(uint)numPixels - 4; i += 4)
{
ref uint pos = ref Unsafe.Add(ref MemoryMarshal.GetReference(pixelData), i);
Vector128<byte> input = Unsafe.As<uint, Vector128<uint>>(ref pos).AsByte();
@ -136,7 +136,7 @@ internal static unsafe class LosslessUtils
{
int numPixels = pixelData.Length;
nint i;
for (i = 0; i <= numPixels - 4; i += 4)
for (i = 0; i <= (nint)(uint)numPixels - 4; i += 4)
{
ref uint pos = ref Unsafe.Add(ref MemoryMarshal.GetReference(pixelData), i);
Vector128<byte> input = Unsafe.As<uint, Vector128<uint>>(ref pos).AsByte();
@ -179,7 +179,7 @@ internal static unsafe class LosslessUtils
Vector256<byte> subtractGreenFromBlueAndRedMaskAvx2 = Vector256.Create(1, 255, 1, 255, 5, 255, 5, 255, 9, 255, 9, 255, 13, 255, 13, 255, 17, 255, 17, 255, 21, 255, 21, 255, 25, 255, 25, 255, 29, 255, 29, 255);
int numPixels = pixelData.Length;
nint i;
for (i = 0; i <= numPixels - 8; i += 8)
for (i = 0; i <= (nint)(uint)numPixels - 8; i += 8)
{
ref uint pos = ref Unsafe.Add(ref MemoryMarshal.GetReference(pixelData), i);
Vector256<byte> input = Unsafe.As<uint, Vector256<uint>>(ref pos).AsByte();
@ -198,7 +198,7 @@ internal static unsafe class LosslessUtils
Vector128<byte> subtractGreenFromBlueAndRedMaskSsse3 = Vector128.Create(1, 255, 1, 255, 5, 255, 5, 255, 9, 255, 9, 255, 13, 255, 13, 255);
int numPixels = pixelData.Length;
nint i;
for (i = 0; i <= numPixels - 4; i += 4)
for (i = 0; i <= (nint)(uint)numPixels - 4; i += 4)
{
ref uint pos = ref Unsafe.Add(ref MemoryMarshal.GetReference(pixelData), i);
Vector128<byte> input = Unsafe.As<uint, Vector128<uint>>(ref pos).AsByte();
@ -216,7 +216,7 @@ internal static unsafe class LosslessUtils
{
int numPixels = pixelData.Length;
nint i;
for (i = 0; i <= numPixels - 4; i += 4)
for (i = 0; i <= (nint)(uint)numPixels - 4; i += 4)
{
ref uint pos = ref Unsafe.Add(ref MemoryMarshal.GetReference(pixelData), i);
Vector128<byte> input = Unsafe.As<uint, Vector128<uint>>(ref pos).AsByte();
@ -373,7 +373,7 @@ internal static unsafe class LosslessUtils
Vector256<int> multsb2 = MkCst32(Cst5b(m.RedToBlue), 0);
nint idx;
for (idx = 0; idx <= numPixels - 8; idx += 8)
for (idx = 0; idx <= (nint)(uint)numPixels - 8; idx += 8)
{
ref uint pos = ref Unsafe.Add(ref MemoryMarshal.GetReference(pixelData), idx);
Vector256<uint> input = Unsafe.As<uint, Vector256<uint>>(ref pos);
@ -402,7 +402,7 @@ internal static unsafe class LosslessUtils
Vector128<int> multsrb = MkCst16(Cst5b(m.GreenToRed), Cst5b(m.GreenToBlue));
Vector128<int> multsb2 = MkCst16(Cst5b(m.RedToBlue), 0);
nint idx;
for (idx = 0; idx <= numPixels - 4; idx += 4)
for (idx = 0; idx <= (nint)(uint)numPixels - 4; idx += 4)
{
ref uint pos = ref Unsafe.Add(ref MemoryMarshal.GetReference(pixelData), idx);
Vector128<uint> input = Unsafe.As<uint, Vector128<uint>>(ref pos);
@ -461,7 +461,7 @@ internal static unsafe class LosslessUtils
Vector256<int> multsrb = MkCst32(Cst5b(m.GreenToRed), Cst5b(m.GreenToBlue));
Vector256<int> multsb2 = MkCst32(Cst5b(m.RedToBlue), 0);
nint idx;
for (idx = 0; idx <= pixelData.Length - 8; idx += 8)
for (idx = 0; idx <= (nint)(uint)pixelData.Length - 8; idx += 8)
{
ref uint pos = ref Unsafe.Add(ref MemoryMarshal.GetReference(pixelData), idx);
Vector256<uint> input = Unsafe.As<uint, Vector256<uint>>(ref pos);
@ -491,7 +491,7 @@ internal static unsafe class LosslessUtils
Vector128<int> multsb2 = MkCst16(Cst5b(m.RedToBlue), 0);
nint idx;
for (idx = 0; idx <= pixelData.Length - 4; idx += 4)
for (idx = 0; idx <= (nint)(uint)pixelData.Length - 4; idx += 4)
{
ref uint pos = ref Unsafe.Add(ref MemoryMarshal.GetReference(pixelData), idx);
Vector128<uint> input = Unsafe.As<uint, Vector128<uint>>(ref pos);

29
src/ImageSharp/Formats/Webp/Lossless/Vp8LHistogram.cs

@ -518,28 +518,29 @@ internal sealed class Vp8LHistogram : IDeepCloneable
ref uint aRef = ref MemoryMarshal.GetReference(a);
ref uint bRef = ref MemoryMarshal.GetReference(b);
ref uint outputRef = ref MemoryMarshal.GetReference(output);
int i;
nint idx;
for (i = 0; i + 32 <= count; i += 32)
for (idx = 0; idx <= (nint)(uint)count - 32; idx += 32)
{
// Load values.
Vector256<uint> a0 = Unsafe.As<uint, Vector256<uint>>(ref Unsafe.Add(ref aRef, i));
Vector256<uint> a1 = Unsafe.As<uint, Vector256<uint>>(ref Unsafe.Add(ref aRef, i + 8));
Vector256<uint> a2 = Unsafe.As<uint, Vector256<uint>>(ref Unsafe.Add(ref aRef, i + 16));
Vector256<uint> a3 = Unsafe.As<uint, Vector256<uint>>(ref Unsafe.Add(ref aRef, i + 24));
Vector256<uint> b0 = Unsafe.As<uint, Vector256<uint>>(ref Unsafe.Add(ref bRef, i));
Vector256<uint> b1 = Unsafe.As<uint, Vector256<uint>>(ref Unsafe.Add(ref bRef, i + 8));
Vector256<uint> b2 = Unsafe.As<uint, Vector256<uint>>(ref Unsafe.Add(ref bRef, i + 16));
Vector256<uint> b3 = Unsafe.As<uint, Vector256<uint>>(ref Unsafe.Add(ref bRef, i + 24));
Vector256<uint> a0 = Unsafe.As<uint, Vector256<uint>>(ref Unsafe.Add(ref aRef, idx));
Vector256<uint> a1 = Unsafe.As<uint, Vector256<uint>>(ref Unsafe.Add(ref aRef, idx + 8));
Vector256<uint> a2 = Unsafe.As<uint, Vector256<uint>>(ref Unsafe.Add(ref aRef, idx + 16));
Vector256<uint> a3 = Unsafe.As<uint, Vector256<uint>>(ref Unsafe.Add(ref aRef, idx + 24));
Vector256<uint> b0 = Unsafe.As<uint, Vector256<uint>>(ref Unsafe.Add(ref bRef, idx));
Vector256<uint> b1 = Unsafe.As<uint, Vector256<uint>>(ref Unsafe.Add(ref bRef, idx + 8));
Vector256<uint> b2 = Unsafe.As<uint, Vector256<uint>>(ref Unsafe.Add(ref bRef, idx + 16));
Vector256<uint> b3 = Unsafe.As<uint, Vector256<uint>>(ref Unsafe.Add(ref bRef, idx + 24));
// Note we are adding uint32_t's as *signed* int32's (using _mm_add_epi32). But
// that's ok since the histogram values are less than 1<<28 (max picture count).
Unsafe.As<uint, Vector256<uint>>(ref Unsafe.Add(ref outputRef, i)) = Avx2.Add(a0, b0);
Unsafe.As<uint, Vector256<uint>>(ref Unsafe.Add(ref outputRef, i + 8)) = Avx2.Add(a1, b1);
Unsafe.As<uint, Vector256<uint>>(ref Unsafe.Add(ref outputRef, i + 16)) = Avx2.Add(a2, b2);
Unsafe.As<uint, Vector256<uint>>(ref Unsafe.Add(ref outputRef, i + 24)) = Avx2.Add(a3, b3);
Unsafe.As<uint, Vector256<uint>>(ref Unsafe.Add(ref outputRef, idx)) = Avx2.Add(a0, b0);
Unsafe.As<uint, Vector256<uint>>(ref Unsafe.Add(ref outputRef, idx + 8)) = Avx2.Add(a1, b1);
Unsafe.As<uint, Vector256<uint>>(ref Unsafe.Add(ref outputRef, idx + 16)) = Avx2.Add(a2, b2);
Unsafe.As<uint, Vector256<uint>>(ref Unsafe.Add(ref outputRef, idx + 24)) = Avx2.Add(a3, b3);
}
int i = (int)idx;
for (; i < count; i++)
{
output[i] = a[i] + b[i];

114
src/ImageSharp/Formats/Webp/Lossy/LossyUtils.cs

@ -1427,17 +1427,17 @@ internal static class LossyUtils
if (Sse2.IsSupported)
{
// Load.
ref byte pRef = ref Unsafe.Add(ref MemoryMarshal.GetReference(p), offset);
ref byte pRef = ref Unsafe.Add(ref MemoryMarshal.GetReference(p), (uint)offset);
Vector128<byte> p1 = Unsafe.As<byte, Vector128<byte>>(ref Unsafe.Subtract(ref pRef, 2 * stride));
Vector128<byte> p0 = Unsafe.As<byte, Vector128<byte>>(ref Unsafe.Subtract(ref pRef, stride));
Vector128<byte> q0 = Unsafe.As<byte, Vector128<byte>>(ref pRef);
Vector128<byte> q1 = Unsafe.As<byte, Vector128<byte>>(ref Unsafe.Add(ref pRef, stride));
Vector128<byte> q1 = Unsafe.As<byte, Vector128<byte>>(ref Unsafe.Add(ref pRef, (uint)stride));
DoFilter2Sse2(ref p1, ref p0, ref q0, ref q1, thresh);
// Store.
ref byte outputRef = ref Unsafe.Add(ref MemoryMarshal.GetReference(p), offset);
ref byte outputRef = ref Unsafe.Add(ref MemoryMarshal.GetReference(p), (uint)offset);
Unsafe.As<byte, Vector128<sbyte>>(ref Unsafe.Subtract(ref outputRef, stride)) = p0.AsSByte();
Unsafe.As<byte, Vector128<sbyte>>(ref outputRef) = q0.AsSByte();
}
@ -1460,11 +1460,11 @@ internal static class LossyUtils
if (Sse2.IsSupported)
{
// Beginning of p1
ref byte pRef = ref Unsafe.Add(ref MemoryMarshal.GetReference(p), offset - 2);
ref byte pRef = ref Unsafe.Add(ref MemoryMarshal.GetReference(p), (uint)(offset - 2));
Load16x4(ref pRef, ref Unsafe.Add(ref pRef, 8 * stride), stride, out Vector128<byte> p1, out Vector128<byte> p0, out Vector128<byte> q0, out Vector128<byte> q1);
Load16x4(ref pRef, ref Unsafe.Add(ref pRef, 8 * (uint)stride), stride, out Vector128<byte> p1, out Vector128<byte> p0, out Vector128<byte> q0, out Vector128<byte> q1);
DoFilter2Sse2(ref p1, ref p0, ref q0, ref q1, thresh);
Store16x4(p1, p0, q0, q1, ref pRef, ref Unsafe.Add(ref pRef, 8 * stride), stride);
Store16x4(p1, p0, q0, q1, ref pRef, ref Unsafe.Add(ref pRef, 8 * (uint)stride), stride);
}
else
{
@ -1527,19 +1527,19 @@ internal static class LossyUtils
if (Sse2.IsSupported)
{
ref byte pRef = ref MemoryMarshal.GetReference(p);
Vector128<byte> t1 = Unsafe.As<byte, Vector128<byte>>(ref Unsafe.Add(ref pRef, offset - (4 * stride)));
Vector128<byte> p2 = Unsafe.As<byte, Vector128<byte>>(ref Unsafe.Add(ref pRef, offset - (3 * stride)));
Vector128<byte> p1 = Unsafe.As<byte, Vector128<byte>>(ref Unsafe.Add(ref pRef, offset - (2 * stride)));
Vector128<byte> p0 = Unsafe.As<byte, Vector128<byte>>(ref Unsafe.Add(ref pRef, offset - stride));
Vector128<byte> t1 = Unsafe.As<byte, Vector128<byte>>(ref Unsafe.Add(ref pRef, (uint)(offset - (4 * stride))));
Vector128<byte> p2 = Unsafe.As<byte, Vector128<byte>>(ref Unsafe.Add(ref pRef, (uint)(offset - (3 * stride))));
Vector128<byte> p1 = Unsafe.As<byte, Vector128<byte>>(ref Unsafe.Add(ref pRef, (uint)(offset - (2 * stride))));
Vector128<byte> p0 = Unsafe.As<byte, Vector128<byte>>(ref Unsafe.Add(ref pRef, (uint)(offset - stride)));
Vector128<byte> mask = Abs(p1, p0);
mask = Sse2.Max(mask, Abs(t1, p2));
mask = Sse2.Max(mask, Abs(p2, p1));
Vector128<byte> q0 = Unsafe.As<byte, Vector128<byte>>(ref Unsafe.Add(ref pRef, offset));
Vector128<byte> q1 = Unsafe.As<byte, Vector128<byte>>(ref Unsafe.Add(ref pRef, offset + stride));
Vector128<byte> q2 = Unsafe.As<byte, Vector128<byte>>(ref Unsafe.Add(ref pRef, offset + (2 * stride)));
t1 = Unsafe.As<byte, Vector128<byte>>(ref Unsafe.Add(ref pRef, offset + (3 * stride)));
Vector128<byte> q0 = Unsafe.As<byte, Vector128<byte>>(ref Unsafe.Add(ref pRef, (uint)offset));
Vector128<byte> q1 = Unsafe.As<byte, Vector128<byte>>(ref Unsafe.Add(ref pRef, (uint)(offset + stride)));
Vector128<byte> q2 = Unsafe.As<byte, Vector128<byte>>(ref Unsafe.Add(ref pRef, (uint)(offset + (2 * stride))));
t1 = Unsafe.As<byte, Vector128<byte>>(ref Unsafe.Add(ref pRef, (uint)(offset + (3 * stride))));
mask = Sse2.Max(mask, Abs(q1, q0));
mask = Sse2.Max(mask, Abs(t1, q2));
@ -1550,12 +1550,12 @@ internal static class LossyUtils
// Store.
ref byte outputRef = ref MemoryMarshal.GetReference(p);
Unsafe.As<byte, Vector128<int>>(ref Unsafe.Add(ref outputRef, offset - (3 * stride))) = p2.AsInt32();
Unsafe.As<byte, Vector128<int>>(ref Unsafe.Add(ref outputRef, offset - (2 * stride))) = p1.AsInt32();
Unsafe.As<byte, Vector128<int>>(ref Unsafe.Add(ref outputRef, offset - stride)) = p0.AsInt32();
Unsafe.As<byte, Vector128<int>>(ref Unsafe.Add(ref outputRef, offset)) = q0.AsInt32();
Unsafe.As<byte, Vector128<int>>(ref Unsafe.Add(ref outputRef, offset + stride)) = q1.AsInt32();
Unsafe.As<byte, Vector128<int>>(ref Unsafe.Add(ref outputRef, offset + (2 * stride))) = q2.AsInt32();
Unsafe.As<byte, Vector128<int>>(ref Unsafe.Add(ref outputRef, (uint)(offset - (3 * stride)))) = p2.AsInt32();
Unsafe.As<byte, Vector128<int>>(ref Unsafe.Add(ref outputRef, (uint)(offset - (2 * stride)))) = p1.AsInt32();
Unsafe.As<byte, Vector128<int>>(ref Unsafe.Add(ref outputRef, (uint)(offset - stride))) = p0.AsInt32();
Unsafe.As<byte, Vector128<int>>(ref Unsafe.Add(ref outputRef, (uint)(offset))) = q0.AsInt32();
Unsafe.As<byte, Vector128<int>>(ref Unsafe.Add(ref outputRef, (uint)(offset + stride))) = q1.AsInt32();
Unsafe.As<byte, Vector128<int>>(ref Unsafe.Add(ref outputRef, (uint)(offset + (2 * stride)))) = q2.AsInt32();
}
else
{
@ -1569,14 +1569,14 @@ internal static class LossyUtils
if (Sse2.IsSupported)
{
ref byte pRef = ref MemoryMarshal.GetReference(p);
ref byte bRef = ref Unsafe.Add(ref pRef, offset - 4);
Load16x4(ref bRef, ref Unsafe.Add(ref bRef, 8 * stride), stride, out Vector128<byte> p3, out Vector128<byte> p2, out Vector128<byte> p1, out Vector128<byte> p0);
ref byte bRef = ref Unsafe.Add(ref pRef, (uint)offset - 4);
Load16x4(ref bRef, ref Unsafe.Add(ref bRef, 8 * (uint)stride), stride, out Vector128<byte> p3, out Vector128<byte> p2, out Vector128<byte> p1, out Vector128<byte> p0);
Vector128<byte> mask = Abs(p1, p0);
mask = Sse2.Max(mask, Abs(p3, p2));
mask = Sse2.Max(mask, Abs(p2, p1));
Load16x4(ref Unsafe.Add(ref pRef, offset), ref Unsafe.Add(ref pRef, offset + (8 * stride)), stride, out Vector128<byte> q0, out Vector128<byte> q1, out Vector128<byte> q2, out Vector128<byte> q3);
Load16x4(ref Unsafe.Add(ref pRef, (uint)offset), ref Unsafe.Add(ref pRef, (uint)(offset + (8 * stride))), stride, out Vector128<byte> q0, out Vector128<byte> q1, out Vector128<byte> q2, out Vector128<byte> q3);
mask = Sse2.Max(mask, Abs(q1, q0));
mask = Sse2.Max(mask, Abs(q3, q2));
@ -1585,8 +1585,8 @@ internal static class LossyUtils
ComplexMask(p1, p0, q0, q1, thresh, ithresh, ref mask);
DoFilter6Sse2(ref p2, ref p1, ref p0, ref q0, ref q1, ref q2, mask, hevThresh);
Store16x4(p3, p2, p1, p0, ref bRef, ref Unsafe.Add(ref bRef, 8 * stride), stride);
Store16x4(q0, q1, q2, q3, ref Unsafe.Add(ref pRef, offset), ref Unsafe.Add(ref pRef, offset + (8 * stride)), stride);
Store16x4(p3, p2, p1, p0, ref bRef, ref Unsafe.Add(ref bRef, 8 * (uint)stride), stride);
Store16x4(q0, q1, q2, q3, ref Unsafe.Add(ref pRef, (uint)offset), ref Unsafe.Add(ref pRef, (uint)(offset + (8 * stride))), stride);
}
else
{
@ -1599,10 +1599,10 @@ internal static class LossyUtils
if (Sse2.IsSupported)
{
ref byte pRef = ref MemoryMarshal.GetReference(p);
Vector128<byte> p3 = Unsafe.As<byte, Vector128<byte>>(ref Unsafe.Add(ref pRef, offset));
Vector128<byte> p2 = Unsafe.As<byte, Vector128<byte>>(ref Unsafe.Add(ref pRef, offset + stride));
Vector128<byte> p1 = Unsafe.As<byte, Vector128<byte>>(ref Unsafe.Add(ref pRef, offset + (2 * stride)));
Vector128<byte> p0 = Unsafe.As<byte, Vector128<byte>>(ref Unsafe.Add(ref pRef, offset + (3 * stride)));
Vector128<byte> p3 = Unsafe.As<byte, Vector128<byte>>(ref Unsafe.Add(ref pRef, (uint)(offset)));
Vector128<byte> p2 = Unsafe.As<byte, Vector128<byte>>(ref Unsafe.Add(ref pRef, (uint)(offset + stride)));
Vector128<byte> p1 = Unsafe.As<byte, Vector128<byte>>(ref Unsafe.Add(ref pRef, (uint)(offset + (2 * stride))));
Vector128<byte> p0 = Unsafe.As<byte, Vector128<byte>>(ref Unsafe.Add(ref pRef, (uint)(offset + (3 * stride))));
for (int k = 3; k > 0; k--)
{
@ -1614,10 +1614,10 @@ internal static class LossyUtils
mask = Sse2.Max(mask, Abs(p3, p2));
mask = Sse2.Max(mask, Abs(p2, p1));
p3 = Unsafe.As<byte, Vector128<byte>>(ref Unsafe.Add(ref pRef, offset));
p2 = Unsafe.As<byte, Vector128<byte>>(ref Unsafe.Add(ref pRef, offset + stride));
Vector128<byte> tmp1 = Unsafe.As<byte, Vector128<byte>>(ref Unsafe.Add(ref pRef, offset + (2 * stride)));
Vector128<byte> tmp2 = Unsafe.As<byte, Vector128<byte>>(ref Unsafe.Add(ref pRef, offset + (3 * stride)));
p3 = Unsafe.As<byte, Vector128<byte>>(ref Unsafe.Add(ref pRef, (uint)offset));
p2 = Unsafe.As<byte, Vector128<byte>>(ref Unsafe.Add(ref pRef, (uint)(offset + stride)));
Vector128<byte> tmp1 = Unsafe.As<byte, Vector128<byte>>(ref Unsafe.Add(ref pRef, (uint)(offset + (2 * stride))));
Vector128<byte> tmp2 = Unsafe.As<byte, Vector128<byte>>(ref Unsafe.Add(ref pRef, (uint)(offset + (3 * stride))));
mask = Sse2.Max(mask, Abs(tmp1, tmp2));
mask = Sse2.Max(mask, Abs(p3, p2));
@ -1631,9 +1631,9 @@ internal static class LossyUtils
// Store.
ref byte outputRef = ref MemoryMarshal.GetReference(b);
Unsafe.As<byte, Vector128<int>>(ref outputRef) = p1.AsInt32();
Unsafe.As<byte, Vector128<int>>(ref Unsafe.Add(ref outputRef, stride)) = p0.AsInt32();
Unsafe.As<byte, Vector128<int>>(ref Unsafe.Add(ref outputRef, stride * 2)) = p3.AsInt32();
Unsafe.As<byte, Vector128<int>>(ref Unsafe.Add(ref outputRef, stride * 3)) = p2.AsInt32();
Unsafe.As<byte, Vector128<int>>(ref Unsafe.Add(ref outputRef, (uint)stride)) = p0.AsInt32();
Unsafe.As<byte, Vector128<int>>(ref Unsafe.Add(ref outputRef, (uint)(stride * 2))) = p3.AsInt32();
Unsafe.As<byte, Vector128<int>>(ref Unsafe.Add(ref outputRef, (uint)(stride * 3))) = p2.AsInt32();
// Rotate samples.
p1 = tmp1;
@ -1655,13 +1655,13 @@ internal static class LossyUtils
if (Sse2.IsSupported)
{
ref byte pRef = ref MemoryMarshal.GetReference(p);
Load16x4(ref Unsafe.Add(ref pRef, offset), ref Unsafe.Add(ref pRef, offset + (8 * stride)), stride, out Vector128<byte> p3, out Vector128<byte> p2, out Vector128<byte> p1, out Vector128<byte> p0);
Load16x4(ref Unsafe.Add(ref pRef, (uint)offset), ref Unsafe.Add(ref pRef, (uint)(offset + (8 * stride))), stride, out Vector128<byte> p3, out Vector128<byte> p2, out Vector128<byte> p1, out Vector128<byte> p0);
Vector128<byte> mask;
for (int k = 3; k > 0; k--)
{
// Beginning of p1.
ref byte bRef = ref Unsafe.Add(ref pRef, offset + 2);
ref byte bRef = ref Unsafe.Add(ref pRef, (uint)offset + 2);
// Beginning of q0 (and next span).
offset += 4;
@ -1671,7 +1671,7 @@ internal static class LossyUtils
mask = Sse2.Max(mask, Abs(p3, p2));
mask = Sse2.Max(mask, Abs(p2, p1));
Load16x4(ref Unsafe.Add(ref pRef, offset), ref Unsafe.Add(ref pRef, offset + (8 * stride)), stride, out p3, out p2, out Vector128<byte> tmp1, out Vector128<byte> tmp2);
Load16x4(ref Unsafe.Add(ref pRef, (uint)offset), ref Unsafe.Add(ref pRef, (uint)(offset + (8 * stride))), stride, out p3, out p2, out Vector128<byte> tmp1, out Vector128<byte> tmp2);
mask = Sse2.Max(mask, Abs(tmp1, tmp2));
mask = Sse2.Max(mask, Abs(p3, p2));
@ -1680,7 +1680,7 @@ internal static class LossyUtils
ComplexMask(p1, p0, p3, p2, thresh, ithresh, ref mask);
DoFilter4Sse2(ref p1, ref p0, ref p3, ref p2, mask, hevThresh);
Store16x4(p1, p0, p3, p2, ref bRef, ref Unsafe.Add(ref bRef, 8 * stride), stride);
Store16x4(p1, p0, p3, p2, ref bRef, ref Unsafe.Add(ref bRef, 8 * (uint)stride), stride);
// Rotate samples.
p1 = tmp1;
@ -1749,13 +1749,13 @@ internal static class LossyUtils
{
ref byte uRef = ref MemoryMarshal.GetReference(u);
ref byte vRef = ref MemoryMarshal.GetReference(v);
Load16x4(ref Unsafe.Add(ref uRef, offset - 4), ref Unsafe.Add(ref vRef, offset - 4), stride, out Vector128<byte> p3, out Vector128<byte> p2, out Vector128<byte> p1, out Vector128<byte> p0);
Load16x4(ref Unsafe.Add(ref uRef, (uint)offset - 4), ref Unsafe.Add(ref vRef, (uint)offset - 4), stride, out Vector128<byte> p3, out Vector128<byte> p2, out Vector128<byte> p1, out Vector128<byte> p0);
Vector128<byte> mask = Abs(p1, p0);
mask = Sse2.Max(mask, Abs(p3, p2));
mask = Sse2.Max(mask, Abs(p2, p1));
Load16x4(ref Unsafe.Add(ref uRef, offset), ref Unsafe.Add(ref vRef, offset), stride, out Vector128<byte> q0, out Vector128<byte> q1, out Vector128<byte> q2, out Vector128<byte> q3);
Load16x4(ref Unsafe.Add(ref uRef, (uint)offset), ref Unsafe.Add(ref vRef, (uint)offset), stride, out Vector128<byte> q0, out Vector128<byte> q1, out Vector128<byte> q2, out Vector128<byte> q3);
mask = Sse2.Max(mask, Abs(q1, q0));
mask = Sse2.Max(mask, Abs(q3, q2));
@ -1764,8 +1764,8 @@ internal static class LossyUtils
ComplexMask(p1, p0, q0, q1, thresh, ithresh, ref mask);
DoFilter6Sse2(ref p2, ref p1, ref p0, ref q0, ref q1, ref q2, mask, hevThresh);
Store16x4(p3, p2, p1, p0, ref Unsafe.Add(ref uRef, offset - 4), ref Unsafe.Add(ref vRef, offset - 4), stride);
Store16x4(q0, q1, q2, q3, ref Unsafe.Add(ref uRef, offset), ref Unsafe.Add(ref vRef, offset), stride);
Store16x4(p3, p2, p1, p0, ref Unsafe.Add(ref uRef, (uint)offset - 4), ref Unsafe.Add(ref vRef, (uint)offset - 4), stride);
Store16x4(q0, q1, q2, q3, ref Unsafe.Add(ref uRef, (uint)offset), ref Unsafe.Add(ref vRef, (uint)offset), stride);
}
else
{
@ -1826,7 +1826,7 @@ internal static class LossyUtils
{
ref byte uRef = ref MemoryMarshal.GetReference(u);
ref byte vRef = ref MemoryMarshal.GetReference(v);
Load16x4(ref Unsafe.Add(ref uRef, offset), ref Unsafe.Add(ref vRef, offset), stride, out Vector128<byte> t2, out Vector128<byte> t1, out Vector128<byte> p1, out Vector128<byte> p0);
Load16x4(ref Unsafe.Add(ref uRef, (uint)offset), ref Unsafe.Add(ref vRef, (uint)offset), stride, out Vector128<byte> t2, out Vector128<byte> t1, out Vector128<byte> p1, out Vector128<byte> p0);
Vector128<byte> mask = Abs(p1, p0);
mask = Sse2.Max(mask, Abs(t2, t1));
@ -1835,7 +1835,7 @@ internal static class LossyUtils
// Beginning of q0.
offset += 4;
Load16x4(ref Unsafe.Add(ref uRef, offset), ref Unsafe.Add(ref vRef, offset), stride, out Vector128<byte> q0, out Vector128<byte> q1, out t1, out t2);
Load16x4(ref Unsafe.Add(ref uRef, (uint)offset), ref Unsafe.Add(ref vRef, (uint)offset), stride, out Vector128<byte> q0, out Vector128<byte> q1, out t1, out t2);
mask = Sse2.Max(mask, Abs(q1, q0));
mask = Sse2.Max(mask, Abs(t2, t1));
@ -1846,7 +1846,7 @@ internal static class LossyUtils
// Beginning of p1.
offset -= 2;
Store16x4(p1, p0, q0, q1, ref Unsafe.Add(ref uRef, offset), ref Unsafe.Add(ref vRef, offset), stride);
Store16x4(p1, p0, q0, q1, ref Unsafe.Add(ref uRef, (uint)offset), ref Unsafe.Add(ref vRef, (uint)offset), stride);
}
else
{
@ -2278,8 +2278,8 @@ internal static class LossyUtils
// q0 = 73 63 53 43 33 23 13 03 72 62 52 42 32 22 12 02
// p0 = f1 e1 d1 c1 b1 a1 91 81 f0 e0 d0 c0 b0 a0 90 80
// q1 = f3 e3 d3 c3 b3 a3 93 83 f2 e2 d2 c2 b2 a2 92 82
Load8x4(ref r0, stride, out Vector128<byte> t1, out Vector128<byte> t2);
Load8x4(ref r8, stride, out p0, out q1);
Load8x4(ref r0, (nint)(uint)stride, out Vector128<byte> t1, out Vector128<byte> t2);
Load8x4(ref r8, (nint)(uint)stride, out p0, out q1);
// p1 = f0 e0 d0 c0 b0 a0 90 80 70 60 50 40 30 20 10 00
// p0 = f1 e1 d1 c1 b1 a1 91 81 71 61 51 41 31 21 11 01
@ -2292,7 +2292,7 @@ internal static class LossyUtils
}
// Reads 8 rows across a vertical edge.
private static void Load8x4(ref byte bRef, int stride, out Vector128<byte> p, out Vector128<byte> q)
private static void Load8x4(ref byte bRef, nint stride, out Vector128<byte> p, out Vector128<byte> q)
{
// A0 = 63 62 61 60 23 22 21 20 43 42 41 40 03 02 01 00
// A1 = 73 72 71 70 33 32 31 30 53 52 51 50 13 12 11 10
@ -2349,10 +2349,10 @@ internal static class LossyUtils
q1s = Sse2.UnpackHigh(t1.AsInt16(), q1s.AsInt16()).AsByte();
Store4x4(p0s, ref r0Ref, stride);
Store4x4(q0s, ref Unsafe.Add(ref r0Ref, 4 * stride), stride);
Store4x4(q0s, ref Unsafe.Add(ref r0Ref, 4 * (uint)stride), stride);
Store4x4(p1s, ref r8Ref, stride);
Store4x4(q1s, ref Unsafe.Add(ref r8Ref, 4 * stride), stride);
Store4x4(q1s, ref Unsafe.Add(ref r8Ref, 4 * (uint)stride), stride);
}
private static void Store4x4(Vector128<byte> x, ref byte dstRef, int stride)
@ -2360,7 +2360,7 @@ internal static class LossyUtils
int offset = 0;
for (int i = 0; i < 4; i++)
{
Unsafe.As<byte, int>(ref Unsafe.Add(ref dstRef, offset)) = Sse2.ConvertToInt32(x.AsInt32());
Unsafe.As<byte, int>(ref Unsafe.Add(ref dstRef, (uint)offset)) = Sse2.ConvertToInt32(x.AsInt32());
x = Sse2.ShiftRightLogical128BitLane(x, 4);
offset += stride;
}
@ -2421,16 +2421,16 @@ internal static class LossyUtils
[MethodImpl(InliningOptions.ShortMethod)]
private static Vector128<byte> LoadUvEdge(ref byte uRef, ref byte vRef, int offset)
{
var uVec = Vector128.Create(Unsafe.As<byte, long>(ref Unsafe.Add(ref uRef, offset)), 0);
var vVec = Vector128.Create(Unsafe.As<byte, long>(ref Unsafe.Add(ref vRef, offset)), 0);
var uVec = Vector128.Create(Unsafe.As<byte, long>(ref Unsafe.Add(ref uRef, (uint)offset)), 0);
var vVec = Vector128.Create(Unsafe.As<byte, long>(ref Unsafe.Add(ref vRef, (uint)offset)), 0);
return Sse2.UnpackLow(uVec, vVec).AsByte();
}
[MethodImpl(InliningOptions.ShortMethod)]
private static void StoreUv(Vector128<byte> x, ref byte uRef, ref byte vRef, int offset)
{
Unsafe.As<byte, Vector64<byte>>(ref Unsafe.Add(ref uRef, offset)) = x.GetLower();
Unsafe.As<byte, Vector64<byte>>(ref Unsafe.Add(ref vRef, offset)) = x.GetUpper();
Unsafe.As<byte, Vector64<byte>>(ref Unsafe.Add(ref uRef, (uint)offset)) = x.GetLower();
Unsafe.As<byte, Vector64<byte>>(ref Unsafe.Add(ref vRef, (uint)offset)) = x.GetUpper();
}
// Compute abs(p - q) = subs(p - q) OR subs(q - p)

2
src/ImageSharp/Formats/Webp/Lossy/QuantEnc.cs

@ -789,7 +789,7 @@ internal static unsafe class QuantEnc
{
int score = 0;
ref short levelsRef = ref MemoryMarshal.GetReference(levels);
int offset = 0;
nint offset = 0;
while (numBlocks-- > 0)
{
for (nint i = 1; i < 16; i++)

8
src/ImageSharp/Formats/Webp/Lossy/YuvConversion.cs

@ -138,8 +138,8 @@ internal static class YuvConversion
{
for (pos = 1, uvPos = 0; pos + 32 + 1 <= len; pos += 32, uvPos += 16)
{
UpSample32Pixels(ref Unsafe.Add(ref topURef, uvPos), ref Unsafe.Add(ref curURef, uvPos), ru);
UpSample32Pixels(ref Unsafe.Add(ref topVRef, uvPos), ref Unsafe.Add(ref curVRef, uvPos), rv);
UpSample32Pixels(ref Unsafe.Add(ref topURef, (uint)uvPos), ref Unsafe.Add(ref curURef, (uint)uvPos), ru);
UpSample32Pixels(ref Unsafe.Add(ref topVRef, (uint)uvPos), ref Unsafe.Add(ref curVRef, (uint)uvPos), rv);
ConvertYuvToBgrWithBottomYSse41(topY, bottomY, topDst, bottomDst, ru, rv, pos, xStep);
}
}
@ -147,8 +147,8 @@ internal static class YuvConversion
{
for (pos = 1, uvPos = 0; pos + 32 + 1 <= len; pos += 32, uvPos += 16)
{
UpSample32Pixels(ref Unsafe.Add(ref topURef, uvPos), ref Unsafe.Add(ref curURef, uvPos), ru);
UpSample32Pixels(ref Unsafe.Add(ref topVRef, uvPos), ref Unsafe.Add(ref curVRef, uvPos), rv);
UpSample32Pixels(ref Unsafe.Add(ref topURef, (uint)uvPos), ref Unsafe.Add(ref curURef, (uint)uvPos), ru);
UpSample32Pixels(ref Unsafe.Add(ref topVRef, (uint)uvPos), ref Unsafe.Add(ref curVRef, (uint)uvPos), rv);
ConvertYuvToBgrSse41(topY, topDst, ru, rv, pos, xStep);
}
}

2
src/ImageSharp/Memory/Allocators/Internals/ManagedBufferBase.cs

@ -1,4 +1,4 @@
// Copyright (c) Six Labors.
// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.
using System.Buffers;

2
src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroup{T}.cs

@ -252,7 +252,7 @@ internal abstract partial class MemoryGroup<T> : IMemoryGroup<T>, IDisposable
{
ref byte b0 = ref MemoryMarshal.GetReference<byte>(this.memoryGroupSpanCache.SingleArray);
ref T e0 = ref Unsafe.As<byte, T>(ref b0);
e0 = ref Unsafe.Add(ref e0, y * width);
e0 = ref Unsafe.Add(ref e0, (uint)(y * width));
return MemoryMarshal.CreateSpan(ref e0, width);
}

432
src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.cs

File diff suppressed because it is too large

4
src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.tt

@ -95,7 +95,7 @@ var blenders = new []{
{
// Divide by 2 as 4 elements per Vector4 and 8 per Vector256<float>
ref Vector256<float> destinationBase = ref Unsafe.As<Vector4, Vector256<float>>(ref MemoryMarshal.GetReference(destination));
ref Vector256<float> destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u));
ref Vector256<float> destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u);
ref Vector256<float> backgroundBase = ref Unsafe.As<Vector4, Vector256<float>>(ref MemoryMarshal.GetReference(background));
ref Vector256<float> sourceBase = ref Unsafe.As<Vector4, Vector256<float>>(ref MemoryMarshal.GetReference(source));
@ -132,7 +132,7 @@ var blenders = new []{
{
// Divide by 2 as 4 elements per Vector4 and 8 per Vector256<float>
ref Vector256<float> destinationBase = ref Unsafe.As<Vector4, Vector256<float>>(ref MemoryMarshal.GetReference(destination));
ref Vector256<float> destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u));
ref Vector256<float> destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u);
ref Vector256<float> backgroundBase = ref Unsafe.As<Vector4, Vector256<float>>(ref MemoryMarshal.GetReference(background));
ref Vector256<float> sourceBase = ref Unsafe.As<Vector4, Vector256<float>>(ref MemoryMarshal.GetReference(source));

2
src/ImageSharp/PixelFormats/PixelImplementations/Abgr32.cs

@ -216,7 +216,7 @@ public partial struct Abgr32 : IPixel<Abgr32>, IPackedVector<uint>
{
// We can assign the Bgr24 value directly to last three bytes of this instance.
ref byte thisRef = ref Unsafe.As<Abgr32, byte>(ref this);
ref byte thisRefFromB = ref Unsafe.AddByteOffset(ref thisRef, new IntPtr(1));
ref byte thisRefFromB = ref Unsafe.AddByteOffset(ref thisRef, 1);
Unsafe.As<byte, Bgr24>(ref thisRefFromB) = source;
this.A = byte.MaxValue;
}

2
src/ImageSharp/PixelFormats/PixelImplementations/Bgr24.cs

@ -190,7 +190,7 @@ public partial struct Bgr24 : IPixel<Bgr24>
{
// We can assign this instances value directly to last three bytes of the Abgr32.
ref byte sourceRef = ref Unsafe.As<Abgr32, byte>(ref source);
ref byte sourceRefFromB = ref Unsafe.AddByteOffset(ref sourceRef, new IntPtr(1));
ref byte sourceRefFromB = ref Unsafe.AddByteOffset(ref sourceRef, 1);
this = Unsafe.As<byte, Bgr24>(ref sourceRefFromB);
}

14
src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Abgr32.PixelOperations.Generated.cs

@ -210,7 +210,7 @@ public partial struct Abgr32
ref Abgr32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref L8 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref Abgr32 sp = ref Unsafe.Add(ref sourceRef, i);
ref L8 dp = ref Unsafe.Add(ref destRef, i);
@ -231,7 +231,7 @@ public partial struct Abgr32
ref Abgr32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref L16 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref Abgr32 sp = ref Unsafe.Add(ref sourceRef, i);
ref L16 dp = ref Unsafe.Add(ref destRef, i);
@ -252,7 +252,7 @@ public partial struct Abgr32
ref Abgr32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref La16 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref Abgr32 sp = ref Unsafe.Add(ref sourceRef, i);
ref La16 dp = ref Unsafe.Add(ref destRef, i);
@ -273,7 +273,7 @@ public partial struct Abgr32
ref Abgr32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref La32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref Abgr32 sp = ref Unsafe.Add(ref sourceRef, i);
ref La32 dp = ref Unsafe.Add(ref destRef, i);
@ -294,7 +294,7 @@ public partial struct Abgr32
ref Abgr32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgb48 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref Abgr32 sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgb48 dp = ref Unsafe.Add(ref destRef, i);
@ -315,7 +315,7 @@ public partial struct Abgr32
ref Abgr32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgba64 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref Abgr32 sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgba64 dp = ref Unsafe.Add(ref destRef, i);
@ -336,7 +336,7 @@ public partial struct Abgr32
ref Abgr32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref Abgr32 sp = ref Unsafe.Add(ref sourceRef, i);
ref Bgra5551 dp = ref Unsafe.Add(ref destRef, i);

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

@ -210,7 +210,7 @@ public partial struct Argb32
ref Argb32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref L8 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref Argb32 sp = ref Unsafe.Add(ref sourceRef, i);
ref L8 dp = ref Unsafe.Add(ref destRef, i);
@ -231,7 +231,7 @@ public partial struct Argb32
ref Argb32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref L16 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref Argb32 sp = ref Unsafe.Add(ref sourceRef, i);
ref L16 dp = ref Unsafe.Add(ref destRef, i);
@ -252,7 +252,7 @@ public partial struct Argb32
ref Argb32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref La16 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref Argb32 sp = ref Unsafe.Add(ref sourceRef, i);
ref La16 dp = ref Unsafe.Add(ref destRef, i);
@ -273,7 +273,7 @@ public partial struct Argb32
ref Argb32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref La32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref Argb32 sp = ref Unsafe.Add(ref sourceRef, i);
ref La32 dp = ref Unsafe.Add(ref destRef, i);
@ -294,7 +294,7 @@ public partial struct Argb32
ref Argb32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgb48 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref Argb32 sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgb48 dp = ref Unsafe.Add(ref destRef, i);
@ -315,7 +315,7 @@ public partial struct Argb32
ref Argb32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgba64 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref Argb32 sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgba64 dp = ref Unsafe.Add(ref destRef, i);
@ -336,7 +336,7 @@ public partial struct Argb32
ref Argb32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref Argb32 sp = ref Unsafe.Add(ref sourceRef, i);
ref Bgra5551 dp = ref Unsafe.Add(ref destRef, i);

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

@ -210,7 +210,7 @@ public partial struct Bgr24
ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref L8 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i);
ref L8 dp = ref Unsafe.Add(ref destRef, i);
@ -231,7 +231,7 @@ public partial struct Bgr24
ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref L16 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i);
ref L16 dp = ref Unsafe.Add(ref destRef, i);
@ -252,7 +252,7 @@ public partial struct Bgr24
ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref La16 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i);
ref La16 dp = ref Unsafe.Add(ref destRef, i);
@ -273,7 +273,7 @@ public partial struct Bgr24
ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref La32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i);
ref La32 dp = ref Unsafe.Add(ref destRef, i);
@ -294,7 +294,7 @@ public partial struct Bgr24
ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgb48 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgb48 dp = ref Unsafe.Add(ref destRef, i);
@ -315,7 +315,7 @@ public partial struct Bgr24
ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgba64 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgba64 dp = ref Unsafe.Add(ref destRef, i);
@ -336,7 +336,7 @@ public partial struct Bgr24
ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i);
ref Bgra5551 dp = ref Unsafe.Add(ref destRef, i);

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

@ -210,7 +210,7 @@ public partial struct Bgra32
ref Bgra32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref L8 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref Bgra32 sp = ref Unsafe.Add(ref sourceRef, i);
ref L8 dp = ref Unsafe.Add(ref destRef, i);
@ -231,7 +231,7 @@ public partial struct Bgra32
ref Bgra32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref L16 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref Bgra32 sp = ref Unsafe.Add(ref sourceRef, i);
ref L16 dp = ref Unsafe.Add(ref destRef, i);
@ -252,7 +252,7 @@ public partial struct Bgra32
ref Bgra32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref La16 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref Bgra32 sp = ref Unsafe.Add(ref sourceRef, i);
ref La16 dp = ref Unsafe.Add(ref destRef, i);
@ -273,7 +273,7 @@ public partial struct Bgra32
ref Bgra32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref La32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref Bgra32 sp = ref Unsafe.Add(ref sourceRef, i);
ref La32 dp = ref Unsafe.Add(ref destRef, i);
@ -294,7 +294,7 @@ public partial struct Bgra32
ref Bgra32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgb48 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref Bgra32 sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgb48 dp = ref Unsafe.Add(ref destRef, i);
@ -315,7 +315,7 @@ public partial struct Bgra32
ref Bgra32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgba64 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref Bgra32 sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgba64 dp = ref Unsafe.Add(ref destRef, i);
@ -336,7 +336,7 @@ public partial struct Bgra32
ref Bgra32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref Bgra32 sp = ref Unsafe.Add(ref sourceRef, i);
ref Bgra5551 dp = ref Unsafe.Add(ref destRef, i);

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

@ -50,7 +50,7 @@ public partial struct Bgra5551
ref Bgra5551 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Argb32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref Bgra5551 sp = ref Unsafe.Add(ref sourceRef, i);
ref Argb32 dp = ref Unsafe.Add(ref destRef, i);
@ -71,7 +71,7 @@ public partial struct Bgra5551
ref Bgra5551 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Abgr32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref Bgra5551 sp = ref Unsafe.Add(ref sourceRef, i);
ref Abgr32 dp = ref Unsafe.Add(ref destRef, i);
@ -92,7 +92,7 @@ public partial struct Bgra5551
ref Bgra5551 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Bgr24 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref Bgra5551 sp = ref Unsafe.Add(ref sourceRef, i);
ref Bgr24 dp = ref Unsafe.Add(ref destRef, i);
@ -113,7 +113,7 @@ public partial struct Bgra5551
ref Bgra5551 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Bgra32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref Bgra5551 sp = ref Unsafe.Add(ref sourceRef, i);
ref Bgra32 dp = ref Unsafe.Add(ref destRef, i);
@ -134,7 +134,7 @@ public partial struct Bgra5551
ref Bgra5551 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref L8 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref Bgra5551 sp = ref Unsafe.Add(ref sourceRef, i);
ref L8 dp = ref Unsafe.Add(ref destRef, i);
@ -155,7 +155,7 @@ public partial struct Bgra5551
ref Bgra5551 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref L16 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref Bgra5551 sp = ref Unsafe.Add(ref sourceRef, i);
ref L16 dp = ref Unsafe.Add(ref destRef, i);
@ -176,7 +176,7 @@ public partial struct Bgra5551
ref Bgra5551 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref La16 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref Bgra5551 sp = ref Unsafe.Add(ref sourceRef, i);
ref La16 dp = ref Unsafe.Add(ref destRef, i);
@ -197,7 +197,7 @@ public partial struct Bgra5551
ref Bgra5551 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref La32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref Bgra5551 sp = ref Unsafe.Add(ref sourceRef, i);
ref La32 dp = ref Unsafe.Add(ref destRef, i);
@ -218,7 +218,7 @@ public partial struct Bgra5551
ref Bgra5551 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgb24 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref Bgra5551 sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgb24 dp = ref Unsafe.Add(ref destRef, i);
@ -239,7 +239,7 @@ public partial struct Bgra5551
ref Bgra5551 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgba32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref Bgra5551 sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgba32 dp = ref Unsafe.Add(ref destRef, i);
@ -260,7 +260,7 @@ public partial struct Bgra5551
ref Bgra5551 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgb48 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref Bgra5551 sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgb48 dp = ref Unsafe.Add(ref destRef, i);
@ -281,7 +281,7 @@ public partial struct Bgra5551
ref Bgra5551 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgba64 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref Bgra5551 sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgba64 dp = ref Unsafe.Add(ref destRef, i);

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

@ -50,7 +50,7 @@ public partial struct L16
ref L16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Argb32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref L16 sp = ref Unsafe.Add(ref sourceRef, i);
ref Argb32 dp = ref Unsafe.Add(ref destRef, i);
@ -71,7 +71,7 @@ public partial struct L16
ref L16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Abgr32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref L16 sp = ref Unsafe.Add(ref sourceRef, i);
ref Abgr32 dp = ref Unsafe.Add(ref destRef, i);
@ -92,7 +92,7 @@ public partial struct L16
ref L16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Bgr24 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref L16 sp = ref Unsafe.Add(ref sourceRef, i);
ref Bgr24 dp = ref Unsafe.Add(ref destRef, i);
@ -113,7 +113,7 @@ public partial struct L16
ref L16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Bgra32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref L16 sp = ref Unsafe.Add(ref sourceRef, i);
ref Bgra32 dp = ref Unsafe.Add(ref destRef, i);
@ -134,7 +134,7 @@ public partial struct L16
ref L16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref L8 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref L16 sp = ref Unsafe.Add(ref sourceRef, i);
ref L8 dp = ref Unsafe.Add(ref destRef, i);
@ -155,7 +155,7 @@ public partial struct L16
ref L16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref La16 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref L16 sp = ref Unsafe.Add(ref sourceRef, i);
ref La16 dp = ref Unsafe.Add(ref destRef, i);
@ -176,7 +176,7 @@ public partial struct L16
ref L16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref La32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref L16 sp = ref Unsafe.Add(ref sourceRef, i);
ref La32 dp = ref Unsafe.Add(ref destRef, i);
@ -197,7 +197,7 @@ public partial struct L16
ref L16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgb24 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref L16 sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgb24 dp = ref Unsafe.Add(ref destRef, i);
@ -218,7 +218,7 @@ public partial struct L16
ref L16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgba32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref L16 sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgba32 dp = ref Unsafe.Add(ref destRef, i);
@ -239,7 +239,7 @@ public partial struct L16
ref L16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgb48 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref L16 sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgb48 dp = ref Unsafe.Add(ref destRef, i);
@ -260,7 +260,7 @@ public partial struct L16
ref L16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgba64 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref L16 sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgba64 dp = ref Unsafe.Add(ref destRef, i);
@ -281,7 +281,7 @@ public partial struct L16
ref L16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref L16 sp = ref Unsafe.Add(ref sourceRef, i);
ref Bgra5551 dp = ref Unsafe.Add(ref destRef, i);

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

@ -50,7 +50,7 @@ public partial struct L8
ref L8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Argb32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref L8 sp = ref Unsafe.Add(ref sourceRef, i);
ref Argb32 dp = ref Unsafe.Add(ref destRef, i);
@ -71,7 +71,7 @@ public partial struct L8
ref L8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Abgr32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref L8 sp = ref Unsafe.Add(ref sourceRef, i);
ref Abgr32 dp = ref Unsafe.Add(ref destRef, i);
@ -92,7 +92,7 @@ public partial struct L8
ref L8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Bgr24 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref L8 sp = ref Unsafe.Add(ref sourceRef, i);
ref Bgr24 dp = ref Unsafe.Add(ref destRef, i);
@ -113,7 +113,7 @@ public partial struct L8
ref L8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Bgra32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref L8 sp = ref Unsafe.Add(ref sourceRef, i);
ref Bgra32 dp = ref Unsafe.Add(ref destRef, i);
@ -134,7 +134,7 @@ public partial struct L8
ref L8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref L16 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref L8 sp = ref Unsafe.Add(ref sourceRef, i);
ref L16 dp = ref Unsafe.Add(ref destRef, i);
@ -155,7 +155,7 @@ public partial struct L8
ref L8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref La16 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref L8 sp = ref Unsafe.Add(ref sourceRef, i);
ref La16 dp = ref Unsafe.Add(ref destRef, i);
@ -176,7 +176,7 @@ public partial struct L8
ref L8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref La32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref L8 sp = ref Unsafe.Add(ref sourceRef, i);
ref La32 dp = ref Unsafe.Add(ref destRef, i);
@ -197,7 +197,7 @@ public partial struct L8
ref L8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgb24 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref L8 sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgb24 dp = ref Unsafe.Add(ref destRef, i);
@ -218,7 +218,7 @@ public partial struct L8
ref L8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgba32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref L8 sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgba32 dp = ref Unsafe.Add(ref destRef, i);
@ -239,7 +239,7 @@ public partial struct L8
ref L8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgb48 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref L8 sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgb48 dp = ref Unsafe.Add(ref destRef, i);
@ -260,7 +260,7 @@ public partial struct L8
ref L8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgba64 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref L8 sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgba64 dp = ref Unsafe.Add(ref destRef, i);
@ -281,7 +281,7 @@ public partial struct L8
ref L8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref L8 sp = ref Unsafe.Add(ref sourceRef, i);
ref Bgra5551 dp = ref Unsafe.Add(ref destRef, i);

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

@ -50,7 +50,7 @@ public partial struct La16
ref La16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Argb32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref La16 sp = ref Unsafe.Add(ref sourceRef, i);
ref Argb32 dp = ref Unsafe.Add(ref destRef, i);
@ -71,7 +71,7 @@ public partial struct La16
ref La16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Abgr32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref La16 sp = ref Unsafe.Add(ref sourceRef, i);
ref Abgr32 dp = ref Unsafe.Add(ref destRef, i);
@ -92,7 +92,7 @@ public partial struct La16
ref La16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Bgr24 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref La16 sp = ref Unsafe.Add(ref sourceRef, i);
ref Bgr24 dp = ref Unsafe.Add(ref destRef, i);

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

@ -210,7 +210,7 @@ public partial struct Rgb24
ref Rgb24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref L8 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref Rgb24 sp = ref Unsafe.Add(ref sourceRef, i);
ref L8 dp = ref Unsafe.Add(ref destRef, i);
@ -231,7 +231,7 @@ public partial struct Rgb24
ref Rgb24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref L16 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref Rgb24 sp = ref Unsafe.Add(ref sourceRef, i);
ref L16 dp = ref Unsafe.Add(ref destRef, i);
@ -252,7 +252,7 @@ public partial struct Rgb24
ref Rgb24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref La16 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref Rgb24 sp = ref Unsafe.Add(ref sourceRef, i);
ref La16 dp = ref Unsafe.Add(ref destRef, i);
@ -273,7 +273,7 @@ public partial struct Rgb24
ref Rgb24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref La32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref Rgb24 sp = ref Unsafe.Add(ref sourceRef, i);
ref La32 dp = ref Unsafe.Add(ref destRef, i);
@ -294,7 +294,7 @@ public partial struct Rgb24
ref Rgb24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgb48 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref Rgb24 sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgb48 dp = ref Unsafe.Add(ref destRef, i);
@ -315,7 +315,7 @@ public partial struct Rgb24
ref Rgb24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgba64 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref Rgb24 sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgba64 dp = ref Unsafe.Add(ref destRef, i);
@ -336,7 +336,7 @@ public partial struct Rgb24
ref Rgb24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref Rgb24 sp = ref Unsafe.Add(ref sourceRef, i);
ref Bgra5551 dp = ref Unsafe.Add(ref destRef, i);

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

@ -50,7 +50,7 @@ public partial struct Rgb48
ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Argb32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i);
ref Argb32 dp = ref Unsafe.Add(ref destRef, i);
@ -71,7 +71,7 @@ public partial struct Rgb48
ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Abgr32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i);
ref Abgr32 dp = ref Unsafe.Add(ref destRef, i);
@ -92,7 +92,7 @@ public partial struct Rgb48
ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Bgr24 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i);
ref Bgr24 dp = ref Unsafe.Add(ref destRef, i);
@ -113,7 +113,7 @@ public partial struct Rgb48
ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Bgra32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i);
ref Bgra32 dp = ref Unsafe.Add(ref destRef, i);
@ -134,7 +134,7 @@ public partial struct Rgb48
ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref L8 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i);
ref L8 dp = ref Unsafe.Add(ref destRef, i);
@ -155,7 +155,7 @@ public partial struct Rgb48
ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref L16 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i);
ref L16 dp = ref Unsafe.Add(ref destRef, i);
@ -176,7 +176,7 @@ public partial struct Rgb48
ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref La16 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i);
ref La16 dp = ref Unsafe.Add(ref destRef, i);
@ -197,7 +197,7 @@ public partial struct Rgb48
ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref La32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i);
ref La32 dp = ref Unsafe.Add(ref destRef, i);
@ -218,7 +218,7 @@ public partial struct Rgb48
ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgb24 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgb24 dp = ref Unsafe.Add(ref destRef, i);
@ -239,7 +239,7 @@ public partial struct Rgb48
ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgba32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgba32 dp = ref Unsafe.Add(ref destRef, i);
@ -260,7 +260,7 @@ public partial struct Rgb48
ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgba64 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgba64 dp = ref Unsafe.Add(ref destRef, i);
@ -281,7 +281,7 @@ public partial struct Rgb48
ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i);
ref Bgra5551 dp = ref Unsafe.Add(ref destRef, i);

2
src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/_Common.ttinclude

@ -103,7 +103,7 @@ using SixLabors.ImageSharp.PixelFormats.Utils;
ref <#=fromPixelType#> sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref <#=toPixelType#> destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref <#=fromPixelType#> sp = ref Unsafe.Add(ref sourceRef, i);
ref <#=toPixelType#> dp = ref Unsafe.Add(ref destRef, i);

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

@ -72,7 +72,7 @@ public partial struct RgbaVector
ref Vector4 sourceBaseRef = ref Unsafe.As<RgbaVector, Vector4>(ref MemoryMarshal.GetReference(sourcePixels));
ref L8 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref Vector4 sp = ref Unsafe.Add(ref sourceBaseRef, i);
ref L8 dp = ref Unsafe.Add(ref destBaseRef, i);
@ -91,7 +91,7 @@ public partial struct RgbaVector
ref Vector4 sourceBaseRef = ref Unsafe.As<RgbaVector, Vector4>(ref MemoryMarshal.GetReference(sourcePixels));
ref L16 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref Vector4 sp = ref Unsafe.Add(ref sourceBaseRef, i);
ref L16 dp = ref Unsafe.Add(ref destBaseRef, i);

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

@ -22,7 +22,7 @@ public partial class PixelOperations<TPixel>
ref Argb32 sourceBaseRef = ref MemoryMarshal.GetReference(source);
ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < source.Length; i++)
for (nint i = 0; i < (uint)source.Length; i++)
{
ref Argb32 sp = ref Unsafe.Add(ref sourceBaseRef, i);
ref TPixel dp = ref Unsafe.Add(ref destBaseRef, i);
@ -58,7 +58,7 @@ public partial class PixelOperations<TPixel>
ref TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Argb32 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref TPixel sp = ref Unsafe.Add(ref sourceBaseRef, i);
ref Argb32 dp = ref Unsafe.Add(ref destBaseRef, i);
@ -94,7 +94,7 @@ public partial class PixelOperations<TPixel>
ref Abgr32 sourceBaseRef = ref MemoryMarshal.GetReference(source);
ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < source.Length; i++)
for (nint i = 0; i < (uint)source.Length; i++)
{
ref Abgr32 sp = ref Unsafe.Add(ref sourceBaseRef, i);
ref TPixel dp = ref Unsafe.Add(ref destBaseRef, i);
@ -130,7 +130,7 @@ public partial class PixelOperations<TPixel>
ref TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Abgr32 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref TPixel sp = ref Unsafe.Add(ref sourceBaseRef, i);
ref Abgr32 dp = ref Unsafe.Add(ref destBaseRef, i);
@ -166,7 +166,7 @@ public partial class PixelOperations<TPixel>
ref Bgr24 sourceBaseRef = ref MemoryMarshal.GetReference(source);
ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < source.Length; i++)
for (nint i = 0; i < (uint)source.Length; i++)
{
ref Bgr24 sp = ref Unsafe.Add(ref sourceBaseRef, i);
ref TPixel dp = ref Unsafe.Add(ref destBaseRef, i);
@ -202,7 +202,7 @@ public partial class PixelOperations<TPixel>
ref TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Bgr24 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref TPixel sp = ref Unsafe.Add(ref sourceBaseRef, i);
ref Bgr24 dp = ref Unsafe.Add(ref destBaseRef, i);
@ -238,7 +238,7 @@ public partial class PixelOperations<TPixel>
ref Bgra32 sourceBaseRef = ref MemoryMarshal.GetReference(source);
ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < source.Length; i++)
for (nint i = 0; i < (uint)source.Length; i++)
{
ref Bgra32 sp = ref Unsafe.Add(ref sourceBaseRef, i);
ref TPixel dp = ref Unsafe.Add(ref destBaseRef, i);
@ -274,7 +274,7 @@ public partial class PixelOperations<TPixel>
ref TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Bgra32 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref TPixel sp = ref Unsafe.Add(ref sourceBaseRef, i);
ref Bgra32 dp = ref Unsafe.Add(ref destBaseRef, i);
@ -310,7 +310,7 @@ public partial class PixelOperations<TPixel>
ref L8 sourceBaseRef = ref MemoryMarshal.GetReference(source);
ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < source.Length; i++)
for (nint i = 0; i < (uint)source.Length; i++)
{
ref L8 sp = ref Unsafe.Add(ref sourceBaseRef, i);
ref TPixel dp = ref Unsafe.Add(ref destBaseRef, i);
@ -346,7 +346,7 @@ public partial class PixelOperations<TPixel>
ref TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels);
ref L8 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref TPixel sp = ref Unsafe.Add(ref sourceBaseRef, i);
ref L8 dp = ref Unsafe.Add(ref destBaseRef, i);
@ -382,7 +382,7 @@ public partial class PixelOperations<TPixel>
ref L16 sourceBaseRef = ref MemoryMarshal.GetReference(source);
ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < source.Length; i++)
for (nint i = 0; i < (uint)source.Length; i++)
{
ref L16 sp = ref Unsafe.Add(ref sourceBaseRef, i);
ref TPixel dp = ref Unsafe.Add(ref destBaseRef, i);
@ -418,7 +418,7 @@ public partial class PixelOperations<TPixel>
ref TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels);
ref L16 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref TPixel sp = ref Unsafe.Add(ref sourceBaseRef, i);
ref L16 dp = ref Unsafe.Add(ref destBaseRef, i);
@ -454,7 +454,7 @@ public partial class PixelOperations<TPixel>
ref La16 sourceBaseRef = ref MemoryMarshal.GetReference(source);
ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < source.Length; i++)
for (nint i = 0; i < (uint)source.Length; i++)
{
ref La16 sp = ref Unsafe.Add(ref sourceBaseRef, i);
ref TPixel dp = ref Unsafe.Add(ref destBaseRef, i);
@ -490,7 +490,7 @@ public partial class PixelOperations<TPixel>
ref TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels);
ref La16 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref TPixel sp = ref Unsafe.Add(ref sourceBaseRef, i);
ref La16 dp = ref Unsafe.Add(ref destBaseRef, i);
@ -526,7 +526,7 @@ public partial class PixelOperations<TPixel>
ref La32 sourceBaseRef = ref MemoryMarshal.GetReference(source);
ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < source.Length; i++)
for (nint i = 0; i < (uint)source.Length; i++)
{
ref La32 sp = ref Unsafe.Add(ref sourceBaseRef, i);
ref TPixel dp = ref Unsafe.Add(ref destBaseRef, i);
@ -562,7 +562,7 @@ public partial class PixelOperations<TPixel>
ref TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels);
ref La32 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref TPixel sp = ref Unsafe.Add(ref sourceBaseRef, i);
ref La32 dp = ref Unsafe.Add(ref destBaseRef, i);
@ -598,7 +598,7 @@ public partial class PixelOperations<TPixel>
ref Rgb24 sourceBaseRef = ref MemoryMarshal.GetReference(source);
ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < source.Length; i++)
for (nint i = 0; i < (uint)source.Length; i++)
{
ref Rgb24 sp = ref Unsafe.Add(ref sourceBaseRef, i);
ref TPixel dp = ref Unsafe.Add(ref destBaseRef, i);
@ -634,7 +634,7 @@ public partial class PixelOperations<TPixel>
ref TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgb24 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref TPixel sp = ref Unsafe.Add(ref sourceBaseRef, i);
ref Rgb24 dp = ref Unsafe.Add(ref destBaseRef, i);
@ -670,7 +670,7 @@ public partial class PixelOperations<TPixel>
ref Rgba32 sourceBaseRef = ref MemoryMarshal.GetReference(source);
ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < source.Length; i++)
for (nint i = 0; i < (uint)source.Length; i++)
{
ref Rgba32 sp = ref Unsafe.Add(ref sourceBaseRef, i);
ref TPixel dp = ref Unsafe.Add(ref destBaseRef, i);
@ -706,7 +706,7 @@ public partial class PixelOperations<TPixel>
ref TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgba32 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref TPixel sp = ref Unsafe.Add(ref sourceBaseRef, i);
ref Rgba32 dp = ref Unsafe.Add(ref destBaseRef, i);
@ -742,7 +742,7 @@ public partial class PixelOperations<TPixel>
ref Rgb48 sourceBaseRef = ref MemoryMarshal.GetReference(source);
ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < source.Length; i++)
for (nint i = 0; i < (uint)source.Length; i++)
{
ref Rgb48 sp = ref Unsafe.Add(ref sourceBaseRef, i);
ref TPixel dp = ref Unsafe.Add(ref destBaseRef, i);
@ -778,7 +778,7 @@ public partial class PixelOperations<TPixel>
ref TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgb48 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref TPixel sp = ref Unsafe.Add(ref sourceBaseRef, i);
ref Rgb48 dp = ref Unsafe.Add(ref destBaseRef, i);
@ -814,7 +814,7 @@ public partial class PixelOperations<TPixel>
ref Rgba64 sourceBaseRef = ref MemoryMarshal.GetReference(source);
ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < source.Length; i++)
for (nint i = 0; i < (uint)source.Length; i++)
{
ref Rgba64 sp = ref Unsafe.Add(ref sourceBaseRef, i);
ref TPixel dp = ref Unsafe.Add(ref destBaseRef, i);
@ -850,7 +850,7 @@ public partial class PixelOperations<TPixel>
ref TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgba64 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref TPixel sp = ref Unsafe.Add(ref sourceBaseRef, i);
ref Rgba64 dp = ref Unsafe.Add(ref destBaseRef, i);
@ -886,7 +886,7 @@ public partial class PixelOperations<TPixel>
ref Bgra5551 sourceBaseRef = ref MemoryMarshal.GetReference(source);
ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < source.Length; i++)
for (nint i = 0; i < (uint)source.Length; i++)
{
ref Bgra5551 sp = ref Unsafe.Add(ref sourceBaseRef, i);
ref TPixel dp = ref Unsafe.Add(ref destBaseRef, i);
@ -922,7 +922,7 @@ public partial class PixelOperations<TPixel>
ref TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Bgra5551 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref TPixel sp = ref Unsafe.Add(ref sourceBaseRef, i);
ref Bgra5551 dp = ref Unsafe.Add(ref destBaseRef, i);

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

@ -28,7 +28,7 @@
ref <#=pixelType#> sourceBaseRef = ref MemoryMarshal.GetReference(source);
ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < source.Length; i++)
for (nint i = 0; i < (uint)source.Length; i++)
{
ref <#=pixelType#> sp = ref Unsafe.Add(ref sourceBaseRef, i);
ref TPixel dp = ref Unsafe.Add(ref destBaseRef, i);
@ -70,7 +70,7 @@
ref TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels);
ref <#=pixelType#> destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
for (nint i = 0; i < (uint)sourcePixels.Length; i++)
{
ref TPixel sp = ref Unsafe.Add(ref sourceBaseRef, i);
ref <#=pixelType#> dp = ref Unsafe.Add(ref destBaseRef, i);

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

@ -187,7 +187,7 @@ public partial class PixelOperations<TPixel>
ref byte b = ref MemoryMarshal.GetReference(blueChannel);
ref TPixel d = ref MemoryMarshal.GetReference(destination);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
rgb24.R = Unsafe.Add(ref r, i);
rgb24.G = Unsafe.Add(ref g, i);
@ -218,7 +218,7 @@ public partial class PixelOperations<TPixel>
ref float g = ref MemoryMarshal.GetReference(greenChannel);
ref float b = ref MemoryMarshal.GetReference(blueChannel);
ref TPixel src = ref MemoryMarshal.GetReference(source);
for (int i = 0; i < count; i++)
for (nint i = 0; i < (uint)count; i++)
{
Unsafe.Add(ref src, i).ToRgba32(ref rgba32);
Unsafe.Add(ref r, i) = rgba32.R;

10
src/ImageSharp/PixelFormats/Utils/Vector4Converters.Default.cs

@ -1,4 +1,4 @@
// Copyright (c) Six Labors.
// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.
using System.Numerics;
@ -88,7 +88,7 @@ internal static partial class Vector4Converters
where TPixel : unmanaged, IPixel<TPixel>
{
ref Vector4 sourceStart = ref MemoryMarshal.GetReference(sourceVectors);
ref Vector4 sourceEnd = ref Unsafe.Add(ref sourceStart, sourceVectors.Length);
ref Vector4 sourceEnd = ref Unsafe.Add(ref sourceStart, (uint)sourceVectors.Length);
ref TPixel destRef = ref MemoryMarshal.GetReference(destPixels);
while (Unsafe.IsAddressLessThan(ref sourceStart, ref sourceEnd))
@ -107,7 +107,7 @@ internal static partial class Vector4Converters
where TPixel : unmanaged, IPixel<TPixel>
{
ref TPixel sourceStart = ref MemoryMarshal.GetReference(sourcePixels);
ref TPixel sourceEnd = ref Unsafe.Add(ref sourceStart, sourcePixels.Length);
ref TPixel sourceEnd = ref Unsafe.Add(ref sourceStart, (uint)sourcePixels.Length);
ref Vector4 destRef = ref MemoryMarshal.GetReference(destVectors);
while (Unsafe.IsAddressLessThan(ref sourceStart, ref sourceEnd))
@ -126,7 +126,7 @@ internal static partial class Vector4Converters
where TPixel : unmanaged, IPixel<TPixel>
{
ref Vector4 sourceStart = ref MemoryMarshal.GetReference(sourceVectors);
ref Vector4 sourceEnd = ref Unsafe.Add(ref sourceStart, sourceVectors.Length);
ref Vector4 sourceEnd = ref Unsafe.Add(ref sourceStart, (uint)sourceVectors.Length);
ref TPixel destRef = ref MemoryMarshal.GetReference(destinationColors);
while (Unsafe.IsAddressLessThan(ref sourceStart, ref sourceEnd))
@ -145,7 +145,7 @@ internal static partial class Vector4Converters
where TPixel : unmanaged, IPixel<TPixel>
{
ref TPixel sourceStart = ref MemoryMarshal.GetReference(sourceColors);
ref TPixel sourceEnd = ref Unsafe.Add(ref sourceStart, sourceColors.Length);
ref TPixel sourceEnd = ref Unsafe.Add(ref sourceStart, (uint)sourceColors.Length);
ref Vector4 destRef = ref MemoryMarshal.GetReference(destinationVectors);
while (Unsafe.IsAddressLessThan(ref sourceStart, ref sourceEnd))

6
src/ImageSharp/Processing/Processors/Convolution/BokehBlurProcessor.cs

@ -128,19 +128,19 @@ public sealed class BokehBlurProcessor : IImageProcessor
int boundsWidth = this.bounds.Width;
int kernelSize = this.kernel.Length;
ref int sampleRowBase = ref Unsafe.Add(ref MemoryMarshal.GetReference(this.map.GetRowOffsetSpan()), (y - this.bounds.Y) * kernelSize);
ref int sampleRowBase = ref Unsafe.Add(ref MemoryMarshal.GetReference(this.map.GetRowOffsetSpan()), (uint)((y - this.bounds.Y) * kernelSize));
// The target buffer is zeroed initially and then it accumulates the results
// of each partial convolution, so we don't have to clear it here as well
ref Vector4 targetBase = ref this.targetValues.GetElementUnsafe(boundsX, y);
ref Complex64 kernelStart = ref this.kernel[0];
ref Complex64 kernelEnd = ref Unsafe.Add(ref kernelStart, kernelSize);
ref Complex64 kernelEnd = ref Unsafe.Add(ref kernelStart, (uint)kernelSize);
while (Unsafe.IsAddressLessThan(ref kernelStart, ref kernelEnd))
{
// Get the precalculated source sample row for this kernel row and copy to our buffer
ref ComplexVector4 sourceBase = ref this.sourceValues.GetElementUnsafe(0, sampleRowBase);
ref ComplexVector4 sourceEnd = ref Unsafe.Add(ref sourceBase, boundsWidth);
ref ComplexVector4 sourceEnd = ref Unsafe.Add(ref sourceBase, (uint)boundsWidth);
ref Vector4 targetStart = ref targetBase;
Complex64 factor = kernelStart;

16
src/ImageSharp/Processing/Processors/Convolution/BokehBlurProcessor{TPixel}.cs

@ -157,8 +157,8 @@ internal class BokehBlurProcessor<TPixel> : ImageProcessor<TPixel>
for (int i = 0; i < this.kernels.Length; i++)
{
// Compute the resulting complex buffer for the current component
Complex64[] kernel = Unsafe.Add(ref baseRef, i);
Vector4 parameters = Unsafe.Add(ref paramsRef, i);
Complex64[] kernel = Unsafe.Add(ref baseRef, (uint)i);
Vector4 parameters = Unsafe.Add(ref paramsRef, (uint)i);
// Horizontal convolution
var horizontalOperation = new FirstPassConvolutionRowOperation(
@ -243,9 +243,9 @@ internal class BokehBlurProcessor<TPixel> : ImageProcessor<TPixel>
ref Vector4 sourceBase = ref MemoryMarshal.GetReference(span);
ref ComplexVector4 targetStart = ref MemoryMarshal.GetReference(targetBuffer);
ref ComplexVector4 targetEnd = ref Unsafe.Add(ref targetStart, span.Length);
ref ComplexVector4 targetEnd = ref Unsafe.Add(ref targetStart, (uint)span.Length);
ref Complex64 kernelBase = ref this.kernel[0];
ref Complex64 kernelEnd = ref Unsafe.Add(ref kernelBase, kernelSize);
ref Complex64 kernelEnd = ref Unsafe.Add(ref kernelBase, (uint)kernelSize);
ref int sampleColumnBase = ref MemoryMarshal.GetReference(this.map.GetColumnOffsetSpan());
while (Unsafe.IsAddressLessThan(ref targetStart, ref targetEnd))
@ -255,7 +255,7 @@ internal class BokehBlurProcessor<TPixel> : ImageProcessor<TPixel>
while (Unsafe.IsAddressLessThan(ref kernelStart, ref kernelEnd))
{
Vector4 sample = Unsafe.Add(ref sourceBase, sampleColumnStart - boundsX);
Vector4 sample = Unsafe.Add(ref sourceBase, (uint)(sampleColumnStart - boundsX));
targetStart.Sum(kernelStart * sample);
@ -265,7 +265,7 @@ internal class BokehBlurProcessor<TPixel> : ImageProcessor<TPixel>
// Shift the base column sampling reference by one row at the end of each outer
// iteration so that the inner tight loop indexing can skip the multiplication
sampleColumnBase = ref Unsafe.Add(ref sampleColumnBase, kernelSize);
sampleColumnBase = ref Unsafe.Add(ref sampleColumnBase, (uint)kernelSize);
targetStart = ref Unsafe.Add(ref targetStart, 1);
}
}
@ -309,7 +309,7 @@ internal class BokehBlurProcessor<TPixel> : ImageProcessor<TPixel>
for (int x = 0; x < this.bounds.Width; x++)
{
ref Vector4 v = ref Unsafe.Add(ref baseRef, x);
ref Vector4 v = ref Unsafe.Add(ref baseRef, (uint)x);
v.X = MathF.Pow(v.X, this.gamma);
v.Y = MathF.Pow(v.Y, this.gamma);
v.Z = MathF.Pow(v.Z, this.gamma);
@ -399,7 +399,7 @@ internal class BokehBlurProcessor<TPixel> : ImageProcessor<TPixel>
for (int x = 0; x < this.bounds.Width; x++)
{
ref Vector4 v = ref Unsafe.Add(ref sourceRef, x);
ref Vector4 v = ref Unsafe.Add(ref sourceRef, (uint)x);
Vector4 clamp = Numerics.Clamp(v, low, high);
v.X = MathF.Pow(clamp.X, this.inverseGamma);
v.Y = MathF.Pow(clamp.Y, this.inverseGamma);

30
src/ImageSharp/Processing/Processors/Convolution/Convolution2DRowOperation{TPixel}.cs

@ -90,7 +90,7 @@ internal readonly struct Convolution2DRowOperation<TPixel> : IRowOperation<Vecto
for (int kY = 0; kY < kernelY.Rows; kY++)
{
// Get the precalculated source sample row for this kernel row and copy to our buffer.
int sampleY = Unsafe.Add(ref sampleRowBase, kY);
int sampleY = Unsafe.Add(ref sampleRowBase, (uint)kY);
sourceRow = this.sourcePixels.DangerousGetRowSpan(sampleY).Slice(boundsX, boundsWidth);
PixelOperations<TPixel>.Instance.ToVector4(this.configuration, sourceRow, sourceBuffer);
@ -99,13 +99,13 @@ internal readonly struct Convolution2DRowOperation<TPixel> : IRowOperation<Vecto
for (int x = 0; x < sourceBuffer.Length; x++)
{
ref int sampleColumnBase = ref state.GetSampleColumn(x);
ref Vector4 targetY = ref Unsafe.Add(ref targetBaseY, x);
ref Vector4 targetX = ref Unsafe.Add(ref targetBaseX, x);
ref Vector4 targetY = ref Unsafe.Add(ref targetBaseY, (uint)x);
ref Vector4 targetX = ref Unsafe.Add(ref targetBaseX, (uint)x);
for (int kX = 0; kX < kernelY.Columns; kX++)
{
int sampleX = Unsafe.Add(ref sampleColumnBase, kX) - boundsX;
Vector4 sample = Unsafe.Add(ref sourceBase, sampleX);
int sampleX = Unsafe.Add(ref sampleColumnBase, (uint)kX) - boundsX;
Vector4 sample = Unsafe.Add(ref sourceBase, (uint)sampleX);
targetY += kernelX[kY, kX] * sample;
targetX += kernelY[kY, kX] * sample;
}
@ -119,12 +119,12 @@ internal readonly struct Convolution2DRowOperation<TPixel> : IRowOperation<Vecto
for (int x = 0; x < sourceRow.Length; x++)
{
ref Vector4 target = ref Unsafe.Add(ref targetBaseY, x);
ref Vector4 target = ref Unsafe.Add(ref targetBaseY, (uint)x);
Vector4 vectorY = target;
Vector4 vectorX = Unsafe.Add(ref targetBaseX, x);
Vector4 vectorX = Unsafe.Add(ref targetBaseX, (uint)x);
target = Vector4.SquareRoot((vectorX * vectorX) + (vectorY * vectorY));
target.W = Unsafe.Add(ref MemoryMarshal.GetReference(sourceBuffer), x).W;
target.W = Unsafe.Add(ref MemoryMarshal.GetReference(sourceBuffer), (uint)x).W;
}
Span<TPixel> targetRowSpan = this.targetPixels.DangerousGetRowSpan(y).Slice(boundsX, boundsWidth);
@ -155,7 +155,7 @@ internal readonly struct Convolution2DRowOperation<TPixel> : IRowOperation<Vecto
for (int kY = 0; kY < kernelY.Rows; kY++)
{
// Get the precalculated source sample row for this kernel row and copy to our buffer.
int sampleY = Unsafe.Add(ref sampleRowBase, kY);
int sampleY = Unsafe.Add(ref sampleRowBase, (uint)kY);
Span<TPixel> sourceRow = this.sourcePixels.DangerousGetRowSpan(sampleY).Slice(boundsX, boundsWidth);
PixelOperations<TPixel>.Instance.ToVector4(this.configuration, sourceRow, sourceBuffer);
@ -165,13 +165,13 @@ internal readonly struct Convolution2DRowOperation<TPixel> : IRowOperation<Vecto
for (int x = 0; x < sourceBuffer.Length; x++)
{
ref int sampleColumnBase = ref state.GetSampleColumn(x);
ref Vector4 targetY = ref Unsafe.Add(ref targetBaseY, x);
ref Vector4 targetX = ref Unsafe.Add(ref targetBaseX, x);
ref Vector4 targetY = ref Unsafe.Add(ref targetBaseY, (uint)x);
ref Vector4 targetX = ref Unsafe.Add(ref targetBaseX, (uint)x);
for (int kX = 0; kX < kernelY.Columns; kX++)
{
int sampleX = Unsafe.Add(ref sampleColumnBase, kX) - boundsX;
Vector4 sample = Unsafe.Add(ref sourceBase, sampleX);
int sampleX = Unsafe.Add(ref sampleColumnBase, (uint)kX) - boundsX;
Vector4 sample = Unsafe.Add(ref sourceBase, (uint)sampleX);
targetY += kernelX[kY, kX] * sample;
targetX += kernelY[kY, kX] * sample;
}
@ -181,9 +181,9 @@ internal readonly struct Convolution2DRowOperation<TPixel> : IRowOperation<Vecto
// Now we need to combine the values
for (int x = 0; x < targetYBuffer.Length; x++)
{
ref Vector4 target = ref Unsafe.Add(ref targetBaseY, x);
ref Vector4 target = ref Unsafe.Add(ref targetBaseY, (uint)x);
Vector4 vectorY = target;
Vector4 vectorX = Unsafe.Add(ref targetBaseX, x);
Vector4 vectorX = Unsafe.Add(ref targetBaseX, (uint)x);
target = Vector4.SquareRoot((vectorX * vectorX) + (vectorY * vectorY));
}

4
src/ImageSharp/Processing/Processors/Convolution/Convolution2DState.cs

@ -44,9 +44,9 @@ internal readonly ref struct Convolution2DState
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly ref int GetSampleRow(int row)
=> ref Unsafe.Add(ref MemoryMarshal.GetReference(this.rowOffsetMap), row * this.kernelHeight);
=> ref Unsafe.Add(ref MemoryMarshal.GetReference(this.rowOffsetMap), (uint)(row * this.kernelHeight));
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly ref int GetSampleColumn(int column)
=> ref Unsafe.Add(ref MemoryMarshal.GetReference(this.columnOffsetMap), column * this.kernelWidth);
=> ref Unsafe.Add(ref MemoryMarshal.GetReference(this.columnOffsetMap), (uint)(column * this.kernelWidth));
}

30
src/ImageSharp/Processing/Processors/Convolution/Convolution2PassProcessor{TPixel}.cs

@ -178,9 +178,9 @@ internal class Convolution2PassProcessor<TPixel> : ImageProcessor<TPixel>
ref Vector4 sourceBase = ref MemoryMarshal.GetReference(sourceBuffer);
ref Vector4 targetStart = ref MemoryMarshal.GetReference(targetBuffer);
ref Vector4 targetEnd = ref Unsafe.Add(ref targetStart, sourceBuffer.Length);
ref Vector4 targetEnd = ref Unsafe.Add(ref targetStart, (uint)sourceBuffer.Length);
ref float kernelBase = ref this.kernel[0];
ref float kernelEnd = ref Unsafe.Add(ref kernelBase, kernelSize);
ref float kernelEnd = ref Unsafe.Add(ref kernelBase, (uint)kernelSize);
ref int sampleColumnBase = ref MemoryMarshal.GetReference(this.map.GetColumnOffsetSpan());
while (Unsafe.IsAddressLessThan(ref targetStart, ref targetEnd))
@ -190,7 +190,7 @@ internal class Convolution2PassProcessor<TPixel> : ImageProcessor<TPixel>
while (Unsafe.IsAddressLessThan(ref kernelStart, ref kernelEnd))
{
Vector4 sample = Unsafe.Add(ref sourceBase, sampleColumnStart - boundsX);
Vector4 sample = Unsafe.Add(ref sourceBase, (uint)(sampleColumnStart - boundsX));
targetStart += kernelStart * sample;
@ -199,7 +199,7 @@ internal class Convolution2PassProcessor<TPixel> : ImageProcessor<TPixel>
}
targetStart = ref Unsafe.Add(ref targetStart, 1);
sampleColumnBase = ref Unsafe.Add(ref sampleColumnBase, kernelSize);
sampleColumnBase = ref Unsafe.Add(ref sampleColumnBase, (uint)kernelSize);
}
// Now we need to copy the original alpha values from the source row.
@ -242,9 +242,9 @@ internal class Convolution2PassProcessor<TPixel> : ImageProcessor<TPixel>
ref Vector4 sourceBase = ref MemoryMarshal.GetReference(sourceBuffer);
ref Vector4 targetStart = ref MemoryMarshal.GetReference(targetBuffer);
ref Vector4 targetEnd = ref Unsafe.Add(ref targetStart, sourceBuffer.Length);
ref Vector4 targetEnd = ref Unsafe.Add(ref targetStart, (uint)sourceBuffer.Length);
ref float kernelBase = ref this.kernel[0];
ref float kernelEnd = ref Unsafe.Add(ref kernelBase, kernelSize);
ref float kernelEnd = ref Unsafe.Add(ref kernelBase, (uint)kernelSize);
ref int sampleColumnBase = ref MemoryMarshal.GetReference(this.map.GetColumnOffsetSpan());
while (Unsafe.IsAddressLessThan(ref targetStart, ref targetEnd))
@ -254,7 +254,7 @@ internal class Convolution2PassProcessor<TPixel> : ImageProcessor<TPixel>
while (Unsafe.IsAddressLessThan(ref kernelStart, ref kernelEnd))
{
Vector4 sample = Unsafe.Add(ref sourceBase, sampleColumnStart - boundsX);
Vector4 sample = Unsafe.Add(ref sourceBase, (uint)(sampleColumnStart - boundsX));
targetStart += kernelStart * sample;
@ -263,7 +263,7 @@ internal class Convolution2PassProcessor<TPixel> : ImageProcessor<TPixel>
}
targetStart = ref Unsafe.Add(ref targetStart, 1);
sampleColumnBase = ref Unsafe.Add(ref sampleColumnBase, kernelSize);
sampleColumnBase = ref Unsafe.Add(ref sampleColumnBase, (uint)kernelSize);
}
Numerics.UnPremultiply(targetBuffer);
@ -335,14 +335,14 @@ internal class Convolution2PassProcessor<TPixel> : ImageProcessor<TPixel>
Span<Vector4> sourceBuffer = span[..this.bounds.Width];
Span<Vector4> targetBuffer = span[this.bounds.Width..];
ref int sampleRowBase = ref Unsafe.Add(ref MemoryMarshal.GetReference(this.map.GetRowOffsetSpan()), (y - this.bounds.Y) * kernelSize);
ref int sampleRowBase = ref Unsafe.Add(ref MemoryMarshal.GetReference(this.map.GetRowOffsetSpan()), (uint)((y - this.bounds.Y) * kernelSize));
// Clear the target buffer for each row run.
targetBuffer.Clear();
ref Vector4 targetBase = ref MemoryMarshal.GetReference(targetBuffer);
ref float kernelStart = ref this.kernel[0];
ref float kernelEnd = ref Unsafe.Add(ref kernelStart, kernelSize);
ref float kernelEnd = ref Unsafe.Add(ref kernelStart, (uint)kernelSize);
Span<TPixel> sourceRow;
while (Unsafe.IsAddressLessThan(ref kernelStart, ref kernelEnd))
@ -353,7 +353,7 @@ internal class Convolution2PassProcessor<TPixel> : ImageProcessor<TPixel>
PixelOperations<TPixel>.Instance.ToVector4(this.configuration, sourceRow, sourceBuffer);
ref Vector4 sourceBase = ref MemoryMarshal.GetReference(sourceBuffer);
ref Vector4 sourceEnd = ref Unsafe.Add(ref sourceBase, sourceBuffer.Length);
ref Vector4 sourceEnd = ref Unsafe.Add(ref sourceBase, (uint)sourceBuffer.Length);
ref Vector4 targetStart = ref targetBase;
float factor = kernelStart;
@ -374,7 +374,7 @@ internal class Convolution2PassProcessor<TPixel> : ImageProcessor<TPixel>
PixelOperations<TPixel>.Instance.ToVector4(this.configuration, sourceRow, sourceBuffer);
{
ref Vector4 sourceBase = ref MemoryMarshal.GetReference(sourceBuffer);
ref Vector4 sourceEnd = ref Unsafe.Add(ref sourceBase, sourceBuffer.Length);
ref Vector4 sourceEnd = ref Unsafe.Add(ref sourceBase, (uint)sourceBuffer.Length);
while (Unsafe.IsAddressLessThan(ref sourceBase, ref sourceEnd))
{
@ -400,14 +400,14 @@ internal class Convolution2PassProcessor<TPixel> : ImageProcessor<TPixel>
Span<Vector4> sourceBuffer = span[..this.bounds.Width];
Span<Vector4> targetBuffer = span[this.bounds.Width..];
ref int sampleRowBase = ref Unsafe.Add(ref MemoryMarshal.GetReference(this.map.GetRowOffsetSpan()), (y - this.bounds.Y) * kernelSize);
ref int sampleRowBase = ref Unsafe.Add(ref MemoryMarshal.GetReference(this.map.GetRowOffsetSpan()), (uint)((y - this.bounds.Y) * kernelSize));
// Clear the target buffer for each row run.
targetBuffer.Clear();
ref Vector4 targetBase = ref MemoryMarshal.GetReference(targetBuffer);
ref float kernelStart = ref this.kernel[0];
ref float kernelEnd = ref Unsafe.Add(ref kernelStart, kernelSize);
ref float kernelEnd = ref Unsafe.Add(ref kernelStart, (uint)kernelSize);
Span<TPixel> sourceRow;
while (Unsafe.IsAddressLessThan(ref kernelStart, ref kernelEnd))
@ -420,7 +420,7 @@ internal class Convolution2PassProcessor<TPixel> : ImageProcessor<TPixel>
Numerics.Premultiply(sourceBuffer);
ref Vector4 sourceBase = ref MemoryMarshal.GetReference(sourceBuffer);
ref Vector4 sourceEnd = ref Unsafe.Add(ref sourceBase, sourceBuffer.Length);
ref Vector4 sourceEnd = ref Unsafe.Add(ref sourceBase, (uint)sourceBuffer.Length);
ref Vector4 targetStart = ref targetBase;
float factor = kernelStart;

20
src/ImageSharp/Processing/Processors/Convolution/ConvolutionProcessor{TPixel}.cs

@ -135,7 +135,7 @@ internal class ConvolutionProcessor<TPixel> : ImageProcessor<TPixel>
for (int kY = 0; kY < state.Kernel.Rows; kY++)
{
// Get the precalculated source sample row for this kernel row and copy to our buffer.
int offsetY = Unsafe.Add(ref sampleRowBase, kY);
int offsetY = Unsafe.Add(ref sampleRowBase, (uint)kY);
sourceRow = this.sourcePixels.DangerousGetRowSpan(offsetY).Slice(boundsX, boundsWidth);
PixelOperations<TPixel>.Instance.ToVector4(this.configuration, sourceRow, sourceBuffer);
@ -144,12 +144,12 @@ internal class ConvolutionProcessor<TPixel> : ImageProcessor<TPixel>
for (int x = 0; x < sourceBuffer.Length; x++)
{
ref int sampleColumnBase = ref state.GetSampleColumn(x);
ref Vector4 target = ref Unsafe.Add(ref targetBase, x);
ref Vector4 target = ref Unsafe.Add(ref targetBase, (uint)x);
for (int kX = 0; kX < state.Kernel.Columns; kX++)
{
int offsetX = Unsafe.Add(ref sampleColumnBase, kX) - boundsX;
Vector4 sample = Unsafe.Add(ref sourceBase, offsetX);
int offsetX = Unsafe.Add(ref sampleColumnBase, (uint)kX) - boundsX;
Vector4 sample = Unsafe.Add(ref sourceBase, (uint)offsetX);
target += state.Kernel[kY, kX] * sample;
}
}
@ -161,8 +161,8 @@ internal class ConvolutionProcessor<TPixel> : ImageProcessor<TPixel>
for (int x = 0; x < sourceRow.Length; x++)
{
ref Vector4 target = ref Unsafe.Add(ref targetBase, x);
target.W = Unsafe.Add(ref MemoryMarshal.GetReference(sourceBuffer), x).W;
ref Vector4 target = ref Unsafe.Add(ref targetBase, (uint)x);
target.W = Unsafe.Add(ref MemoryMarshal.GetReference(sourceBuffer), (uint)x).W;
}
}
else
@ -174,7 +174,7 @@ internal class ConvolutionProcessor<TPixel> : ImageProcessor<TPixel>
for (int kY = 0; kY < state.Kernel.Rows; kY++)
{
// Get the precalculated source sample row for this kernel row and copy to our buffer.
int offsetY = Unsafe.Add(ref sampleRowBase, kY);
int offsetY = Unsafe.Add(ref sampleRowBase, (uint)kY);
Span<TPixel> sourceRow = this.sourcePixels.DangerousGetRowSpan(offsetY).Slice(boundsX, boundsWidth);
PixelOperations<TPixel>.Instance.ToVector4(this.configuration, sourceRow, sourceBuffer);
@ -184,12 +184,12 @@ internal class ConvolutionProcessor<TPixel> : ImageProcessor<TPixel>
for (int x = 0; x < sourceBuffer.Length; x++)
{
ref int sampleColumnBase = ref state.GetSampleColumn(x);
ref Vector4 target = ref Unsafe.Add(ref targetBase, x);
ref Vector4 target = ref Unsafe.Add(ref targetBase, (uint)x);
for (int kX = 0; kX < state.Kernel.Columns; kX++)
{
int offsetX = Unsafe.Add(ref sampleColumnBase, kX) - boundsX;
Vector4 sample = Unsafe.Add(ref sourceBase, offsetX);
int offsetX = Unsafe.Add(ref sampleColumnBase, (uint)kX) - boundsX;
Vector4 sample = Unsafe.Add(ref sourceBase, (uint)offsetX);
target += state.Kernel[kY, kX] * sample;
}
}

4
src/ImageSharp/Processing/Processors/Convolution/ConvolutionState.cs

@ -35,9 +35,9 @@ internal readonly ref struct ConvolutionState
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly ref int GetSampleRow(int row)
=> ref Unsafe.Add(ref MemoryMarshal.GetReference(this.rowOffsetMap), row * this.kernelHeight);
=> ref Unsafe.Add(ref MemoryMarshal.GetReference(this.rowOffsetMap), (uint)(row * this.kernelHeight));
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly ref int GetSampleColumn(int column)
=> ref Unsafe.Add(ref MemoryMarshal.GetReference(this.columnOffsetMap), column * this.kernelWidth);
=> ref Unsafe.Add(ref MemoryMarshal.GetReference(this.columnOffsetMap), (uint)(column * this.kernelWidth));
}

4
src/ImageSharp/Processing/Processors/Convolution/EdgeDetectorCompassProcessor{TPixel}.cs

@ -123,8 +123,8 @@ internal class EdgeDetectorCompassProcessor<TPixel> : ImageProcessor<TPixel>
for (int x = this.minX; x < this.maxX; x++)
{
// Grab the max components of the two pixels
ref TPixel currentPassPixel = ref Unsafe.Add(ref passPixelsBase, x);
ref TPixel currentTargetPixel = ref Unsafe.Add(ref targetPixelsBase, x);
ref TPixel currentPassPixel = ref Unsafe.Add(ref passPixelsBase, (uint)x);
ref TPixel currentTargetPixel = ref Unsafe.Add(ref targetPixelsBase, (uint)x);
var pixelValue = Vector4.Max(currentPassPixel.ToVector4(), currentTargetPixel.ToVector4());

6
src/ImageSharp/Processing/Processors/Convolution/Kernel.cs

@ -49,7 +49,7 @@ internal readonly ref struct Kernel<T>
{
this.CheckCoordinates(row, column);
ref T vBase = ref MemoryMarshal.GetReference(this.values);
return Unsafe.Add(ref vBase, (row * this.Columns) + column);
return Unsafe.Add(ref vBase, (uint)((row * this.Columns) + column));
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@ -57,7 +57,7 @@ internal readonly ref struct Kernel<T>
{
this.CheckCoordinates(row, column);
ref T vBase = ref MemoryMarshal.GetReference(this.values);
Unsafe.Add(ref vBase, (row * this.Columns) + column) = value;
Unsafe.Add(ref vBase, (uint)((row * this.Columns) + column)) = value;
}
}
@ -66,7 +66,7 @@ internal readonly ref struct Kernel<T>
{
this.CheckIndex(index);
ref T vBase = ref MemoryMarshal.GetReference(this.values);
Unsafe.Add(ref vBase, index) = value;
Unsafe.Add(ref vBase, (uint)index) = value;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]

2
src/ImageSharp/Processing/Processors/Convolution/KernelSamplingMap.cs

@ -92,7 +92,7 @@ internal sealed class KernelSamplingMap : IDisposable
int chunkBase = chunk * kernelSize;
for (int i = 0; i < kernelSize; i++)
{
Unsafe.Add(ref spanBase, chunkBase + i) = chunk + i + min - radius;
Unsafe.Add(ref spanBase, (uint)(chunkBase + i)) = chunk + i + min - radius;
}
}

4
src/ImageSharp/Processing/Processors/Convolution/MedianConvolutionState.cs

@ -36,9 +36,9 @@ internal readonly ref struct MedianConvolutionState
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly ref int GetSampleRow(int row)
=> ref Unsafe.Add(ref MemoryMarshal.GetReference(this.rowOffsetMap), row * this.kernelHeight);
=> ref Unsafe.Add(ref MemoryMarshal.GetReference(this.rowOffsetMap), (uint)(row * this.kernelHeight));
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly ref int GetSampleColumn(int column)
=> ref Unsafe.Add(ref MemoryMarshal.GetReference(this.columnOffsetMap), column * this.kernelWidth);
=> ref Unsafe.Add(ref MemoryMarshal.GetReference(this.columnOffsetMap), (uint)(column * this.kernelWidth));
}

14
src/ImageSharp/Processing/Processors/Convolution/MedianRowOperation{TPixel}.cs

@ -75,7 +75,7 @@ internal readonly struct MedianRowOperation<TPixel> : IRowOperation<Vector4>
// First convert the required source rows to Vector4.
for (int i = 0; i < this.kernelSize; i++)
{
int currentYIndex = Unsafe.Add(ref sampleRowBase, i);
int currentYIndex = Unsafe.Add(ref sampleRowBase, (uint)i);
Span<TPixel> sourceRow = this.sourcePixels.DangerousGetRowSpan(currentYIndex).Slice(boundsX, boundsWidth);
Span<Vector4> sourceVectorRow = sourceVectorBuffer.Slice(i * boundsWidth, boundsWidth);
PixelOperations<TPixel>.Instance.ToVector4(this.configuration, sourceRow, sourceVectorRow);
@ -87,15 +87,15 @@ internal readonly struct MedianRowOperation<TPixel> : IRowOperation<Vector4>
{
int index = 0;
ref int sampleColumnBase = ref state.GetSampleColumn(x);
ref Vector4 target = ref Unsafe.Add(ref targetBase, x);
ref Vector4 target = ref Unsafe.Add(ref targetBase, (uint)x);
for (int kY = 0; kY < state.Kernel.Rows; kY++)
{
Span<Vector4> sourceRow = sourceVectorBuffer[(kY * boundsWidth)..];
ref Vector4 sourceRowBase = ref MemoryMarshal.GetReference(sourceRow);
for (int kX = 0; kX < state.Kernel.Columns; kX++)
{
int currentXIndex = Unsafe.Add(ref sampleColumnBase, kX) - boundsX;
Vector4 pixel = Unsafe.Add(ref sourceRowBase, currentXIndex);
int currentXIndex = Unsafe.Add(ref sampleColumnBase, (uint)kX) - boundsX;
Vector4 pixel = Unsafe.Add(ref sourceRowBase, (uint)currentXIndex);
state.Kernel.SetValue(index, pixel);
index++;
}
@ -111,15 +111,15 @@ internal readonly struct MedianRowOperation<TPixel> : IRowOperation<Vector4>
{
int index = 0;
ref int sampleColumnBase = ref state.GetSampleColumn(x);
ref Vector4 target = ref Unsafe.Add(ref targetBase, x);
ref Vector4 target = ref Unsafe.Add(ref targetBase, (uint)x);
for (int kY = 0; kY < state.Kernel.Rows; kY++)
{
Span<Vector4> sourceRow = sourceVectorBuffer[(kY * boundsWidth)..];
ref Vector4 sourceRowBase = ref MemoryMarshal.GetReference(sourceRow);
for (int kX = 0; kX < state.Kernel.Columns; kX++)
{
int currentXIndex = Unsafe.Add(ref sampleColumnBase, kX) - boundsX;
Vector4 pixel = Unsafe.Add(ref sourceRowBase, currentXIndex);
int currentXIndex = Unsafe.Add(ref sampleColumnBase, (uint)kX) - boundsX;
Vector4 pixel = Unsafe.Add(ref sourceRowBase, (uint)currentXIndex);
state.Kernel.SetValue(index, pixel);
index++;
}

16
src/ImageSharp/Processing/Processors/Convolution/Parameters/BokehBlurKernelDataProvider.cs

@ -134,7 +134,7 @@ internal static class BokehBlurKernelDataProvider
ref Vector4 baseRef = ref MemoryMarshal.GetReference(kernelParameters.AsSpan());
for (int i = 0; i < kernelParameters.Length; i++)
{
ref Vector4 paramsRef = ref Unsafe.Add(ref baseRef, i);
ref Vector4 paramsRef = ref Unsafe.Add(ref baseRef, (uint)i);
kernels[i] = CreateComplex1DKernel(radius, kernelSize, kernelsScale, paramsRef.X, paramsRef.Y);
}
@ -167,7 +167,7 @@ internal static class BokehBlurKernelDataProvider
value *= value;
// Fill in the complex kernel values
Unsafe.Add(ref baseRef, i) = new Complex64(
Unsafe.Add(ref baseRef, (uint)i) = new Complex64(
MathF.Exp(-a * value) * MathF.Cos(b * value),
MathF.Exp(-a * value) * MathF.Sin(b * value));
}
@ -190,17 +190,17 @@ internal static class BokehBlurKernelDataProvider
for (int i = 0; i < kernelParameters.Length; i++)
{
ref Complex64[] kernelRef = ref Unsafe.Add(ref baseKernelsRef, i);
ref Complex64[] kernelRef = ref Unsafe.Add(ref baseKernelsRef, (uint)i);
int length = kernelRef.Length;
ref Complex64 valueRef = ref kernelRef[0];
ref Vector4 paramsRef = ref Unsafe.Add(ref baseParamsRef, i);
ref Vector4 paramsRef = ref Unsafe.Add(ref baseParamsRef, (uint)i);
for (int j = 0; j < length; j++)
{
for (int k = 0; k < length; k++)
{
ref Complex64 jRef = ref Unsafe.Add(ref valueRef, j);
ref Complex64 kRef = ref Unsafe.Add(ref valueRef, k);
ref Complex64 jRef = ref Unsafe.Add(ref valueRef, (uint)j);
ref Complex64 kRef = ref Unsafe.Add(ref valueRef, (uint)k);
total +=
(paramsRef.Z * ((jRef.Real * kRef.Real) - (jRef.Imaginary * kRef.Imaginary)))
+ (paramsRef.W * ((jRef.Real * kRef.Imaginary) + (jRef.Imaginary * kRef.Real)));
@ -212,13 +212,13 @@ internal static class BokehBlurKernelDataProvider
float scalar = 1f / MathF.Sqrt(total);
for (int i = 0; i < kernelsSpan.Length; i++)
{
ref Complex64[] kernelsRef = ref Unsafe.Add(ref baseKernelsRef, i);
ref Complex64[] kernelsRef = ref Unsafe.Add(ref baseKernelsRef, (uint)i);
int length = kernelsRef.Length;
ref Complex64 valueRef = ref kernelsRef[0];
for (int j = 0; j < length; j++)
{
Unsafe.Add(ref valueRef, j) *= scalar;
Unsafe.Add(ref valueRef, (uint)j) *= scalar;
}
}
}

2
src/ImageSharp/Processing/Processors/Convolution/ReadOnlyKernel.cs

@ -41,7 +41,7 @@ internal readonly ref struct ReadOnlyKernel
{
this.CheckCoordinates(row, column);
ref float vBase = ref MemoryMarshal.GetReference(this.values);
return Unsafe.Add(ref vBase, (row * this.Columns) + column);
return Unsafe.Add(ref vBase, (uint)((row * this.Columns) + column));
}
}

6
src/ImageSharp/Processing/Processors/Dithering/ErrorDither.cs

@ -114,8 +114,8 @@ public readonly partial struct ErrorDither : IDither, IEquatable<ErrorDither>, I
for (int x = bounds.Left; x < bounds.Right; x++)
{
TPixel sourcePixel = Unsafe.Add(ref sourceRowRef, x);
Unsafe.Add(ref destinationRowRef, x - offsetX) = quantizer.GetQuantizedColor(sourcePixel, out TPixel transformed);
TPixel sourcePixel = Unsafe.Add(ref sourceRowRef, (uint)x);
Unsafe.Add(ref destinationRowRef, (uint)(x - offsetX)) = quantizer.GetQuantizedColor(sourcePixel, out TPixel transformed);
this.Dither(source, bounds, sourcePixel, transformed, x, y, scale);
}
}
@ -142,7 +142,7 @@ public readonly partial struct ErrorDither : IDither, IEquatable<ErrorDither>, I
ref TPixel sourceRowRef = ref MemoryMarshal.GetReference(sourceBuffer.DangerousGetRowSpan(y));
for (int x = bounds.Left; x < bounds.Right; x++)
{
ref TPixel sourcePixel = ref Unsafe.Add(ref sourceRowRef, x);
ref TPixel sourcePixel = ref Unsafe.Add(ref sourceRowRef, (uint)x);
TPixel transformed = Unsafe.AsRef(processor).GetPaletteColor(sourcePixel);
this.Dither(source, bounds, sourcePixel, transformed, x, y, scale);
sourcePixel = transformed;

24
src/ImageSharp/Processing/Processors/Effects/OilPaintingProcessor{TPixel}.cs

@ -107,9 +107,9 @@ internal class OilPaintingProcessor<TPixel> : ImageProcessor<TPixel>
ref float binsRef = ref bins.GetReference();
ref int intensityBinRef = ref Unsafe.As<float, int>(ref binsRef);
ref float redBinRef = ref Unsafe.Add(ref binsRef, this.levels);
ref float blueBinRef = ref Unsafe.Add(ref redBinRef, this.levels);
ref float greenBinRef = ref Unsafe.Add(ref blueBinRef, this.levels);
ref float redBinRef = ref Unsafe.Add(ref binsRef, (uint)this.levels);
ref float blueBinRef = ref Unsafe.Add(ref redBinRef, (uint)this.levels);
ref float greenBinRef = ref Unsafe.Add(ref blueBinRef, (uint)this.levels);
for (int y = rows.Min; y < rows.Max; y++)
{
@ -148,21 +148,21 @@ internal class OilPaintingProcessor<TPixel> : ImageProcessor<TPixel>
int currentIntensity = (int)MathF.Round((sourceBlue + sourceGreen + sourceRed) / 3F * (this.levels - 1));
Unsafe.Add(ref intensityBinRef, currentIntensity)++;
Unsafe.Add(ref redBinRef, currentIntensity) += sourceRed;
Unsafe.Add(ref blueBinRef, currentIntensity) += sourceBlue;
Unsafe.Add(ref greenBinRef, currentIntensity) += sourceGreen;
Unsafe.Add(ref intensityBinRef, (uint)currentIntensity)++;
Unsafe.Add(ref redBinRef, (uint)currentIntensity) += sourceRed;
Unsafe.Add(ref blueBinRef, (uint)currentIntensity) += sourceBlue;
Unsafe.Add(ref greenBinRef, (uint)currentIntensity) += sourceGreen;
if (Unsafe.Add(ref intensityBinRef, currentIntensity) > maxIntensity)
if (Unsafe.Add(ref intensityBinRef, (uint)currentIntensity) > maxIntensity)
{
maxIntensity = Unsafe.Add(ref intensityBinRef, currentIntensity);
maxIntensity = Unsafe.Add(ref intensityBinRef, (uint)currentIntensity);
maxIndex = currentIntensity;
}
}
float red = MathF.Abs(Unsafe.Add(ref redBinRef, maxIndex) / maxIntensity);
float blue = MathF.Abs(Unsafe.Add(ref blueBinRef, maxIndex) / maxIntensity);
float green = MathF.Abs(Unsafe.Add(ref greenBinRef, maxIndex) / maxIntensity);
float red = MathF.Abs(Unsafe.Add(ref redBinRef, (uint)maxIndex) / maxIntensity);
float blue = MathF.Abs(Unsafe.Add(ref blueBinRef, (uint)maxIndex) / maxIntensity);
float green = MathF.Abs(Unsafe.Add(ref greenBinRef, (uint)maxIndex) / maxIntensity);
float alpha = sourceRowVector4Span[x].W;
targetRowVector4Span[x] = new Vector4(red, green, blue, alpha);

2
src/ImageSharp/Processing/Processors/Filters/OpaqueProcessor{TPixel}.cs

@ -61,7 +61,7 @@ internal sealed class OpaqueProcessor<TPixel> : ImageProcessor<TPixel>
for (int x = 0; x < this.bounds.Width; x++)
{
ref Vector4 v = ref Unsafe.Add(ref baseRef, x);
ref Vector4 v = ref Unsafe.Add(ref baseRef, (uint)x);
v.W = 1F;
}

10
src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationSlidingWindowProcessor{TPixel}.cs

@ -256,8 +256,8 @@ internal class AdaptiveHistogramEqualizationSlidingWindowProcessor<TPixel> : His
{
for (nint idx = 0; idx < length; idx++)
{
int luminance = ColorNumerics.GetBT709Luminance(ref Unsafe.Add(ref greyValuesBase, idx), luminanceLevels);
Unsafe.Add(ref histogramBase, luminance)++;
int luminance = ColorNumerics.GetBT709Luminance(ref Unsafe.Add(ref greyValuesBase, (uint)idx), luminanceLevels);
Unsafe.Add(ref histogramBase, (uint)luminance)++;
}
}
@ -273,8 +273,8 @@ internal class AdaptiveHistogramEqualizationSlidingWindowProcessor<TPixel> : His
{
for (int idx = 0; idx < length; idx++)
{
int luminance = ColorNumerics.GetBT709Luminance(ref Unsafe.Add(ref greyValuesBase, idx), luminanceLevels);
Unsafe.Add(ref histogramBase, luminance)--;
int luminance = ColorNumerics.GetBT709Luminance(ref Unsafe.Add(ref greyValuesBase, (uint)idx), luminanceLevels);
Unsafe.Add(ref histogramBase, (uint)luminance)--;
}
}
@ -382,7 +382,7 @@ internal class AdaptiveHistogramEqualizationSlidingWindowProcessor<TPixel> : His
// Map the current pixel to the new equalized value.
int luminance = GetLuminance(this.source[x, y], this.processor.LuminanceLevels);
float luminanceEqualized = Unsafe.Add(ref cdfBase, luminance) / numberOfPixelsMinusCdfMin;
float luminanceEqualized = Unsafe.Add(ref cdfBase, (uint)luminance) / numberOfPixelsMinusCdfMin;
this.targetPixels[x, y].FromVector4(new Vector4(luminanceEqualized, luminanceEqualized, luminanceEqualized, this.source[x, y].ToVector4().W));
// Remove top most row from the histogram, mirroring rows which exceeds the borders.

10
src/ImageSharp/Processing/Processors/Normalization/AutoLevelProcessor{TPixel}.cs

@ -148,12 +148,12 @@ internal class AutoLevelProcessor<TPixel> : HistogramEqualizationProcessor<TPixe
for (int x = 0; x < this.bounds.Width; x++)
{
var vector = Unsafe.Add(ref vectorRef, x);
var vector = Unsafe.Add(ref vectorRef, (uint)x);
int luminance = ColorNumerics.GetBT709Luminance(ref vector, levels);
float scaledLuminance = Unsafe.Add(ref cdfBase, luminance) / noOfPixelsMinusCdfMin;
float scaledLuminance = Unsafe.Add(ref cdfBase, (uint)luminance) / noOfPixelsMinusCdfMin;
float scalingFactor = scaledLuminance * levels / luminance;
Vector4 scaledVector = new Vector4(scalingFactor * vector.X, scalingFactor * vector.Y, scalingFactor * vector.Z, vector.W);
Unsafe.Add(ref vectorRef, x) = scaledVector;
Unsafe.Add(ref vectorRef, (uint)x) = scaledVector;
}
PixelOperations<TPixel>.Instance.FromVector4Destructive(this.configuration, vectorBuffer, pixelRow);
@ -209,7 +209,7 @@ internal class AutoLevelProcessor<TPixel> : HistogramEqualizationProcessor<TPixe
for (int x = 0; x < this.bounds.Width; x++)
{
var vector = Unsafe.Add(ref vectorRef, x) * levelsMinusOne;
var vector = Unsafe.Add(ref vectorRef, (uint)x) * levelsMinusOne;
uint originalX = (uint)MathF.Round(vector.X);
float scaledX = Unsafe.Add(ref cdfBase, originalX) / noOfPixelsMinusCdfMin;
@ -217,7 +217,7 @@ internal class AutoLevelProcessor<TPixel> : HistogramEqualizationProcessor<TPixe
float scaledY = Unsafe.Add(ref cdfBase, originalY) / noOfPixelsMinusCdfMin;
uint originalZ = (uint)MathF.Round(vector.Z);
float scaledZ = Unsafe.Add(ref cdfBase, originalZ) / noOfPixelsMinusCdfMin;
Unsafe.Add(ref vectorRef, x) = new Vector4(scaledX, scaledY, scaledZ, vector.W);
Unsafe.Add(ref vectorRef, (uint)x) = new Vector4(scaledX, scaledY, scaledZ, vector.W);
}
PixelOperations<TPixel>.Instance.FromVector4Destructive(this.configuration, vectorBuffer, pixelRow);

6
src/ImageSharp/Processing/Processors/Normalization/GlobalHistogramEqualizationProcessor{TPixel}.cs

@ -129,10 +129,10 @@ internal class GlobalHistogramEqualizationProcessor<TPixel> : HistogramEqualizat
for (int x = 0; x < this.bounds.Width; x++)
{
var vector = Unsafe.Add(ref vectorRef, x);
var vector = Unsafe.Add(ref vectorRef, (uint)x);
int luminance = ColorNumerics.GetBT709Luminance(ref vector, levels);
float luminanceEqualized = Unsafe.Add(ref cdfBase, luminance) / noOfPixelsMinusCdfMin;
Unsafe.Add(ref vectorRef, x) = new Vector4(luminanceEqualized, luminanceEqualized, luminanceEqualized, vector.W);
float luminanceEqualized = Unsafe.Add(ref cdfBase, (uint)luminance) / noOfPixelsMinusCdfMin;
Unsafe.Add(ref vectorRef, (uint)x) = new Vector4(luminanceEqualized, luminanceEqualized, luminanceEqualized, vector.W);
}
PixelOperations<TPixel>.Instance.FromVector4Destructive(this.configuration, vectorBuffer, pixelRow);

4
src/ImageSharp/Processing/Processors/Normalization/GrayscaleLevelsRowOperation{TPixel}.cs

@ -56,9 +56,9 @@ internal readonly struct GrayscaleLevelsRowOperation<TPixel> : IRowOperation<Vec
for (int x = 0; x < this.bounds.Width; x++)
{
var vector = Unsafe.Add(ref vectorRef, x);
var vector = Unsafe.Add(ref vectorRef, (uint)x);
int luminance = ColorNumerics.GetBT709Luminance(ref vector, levels);
Interlocked.Increment(ref Unsafe.Add(ref histogramBase, luminance));
Interlocked.Increment(ref Unsafe.Add(ref histogramBase, (uint)luminance));
}
}
}

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

Loading…
Cancel
Save