Browse Source

PR feedback + use nuint instead of nint

pull/2401/head
Günther Foidl 3 years ago
parent
commit
f746e686df
  1. 26
      src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLab.cs
  2. 26
      src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLch.cs
  3. 26
      src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLchuv.cs
  4. 26
      src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLuv.cs
  5. 26
      src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieXyy.cs
  6. 26
      src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieXyz.cs
  7. 26
      src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Cmyk.cs
  8. 26
      src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Hsl.cs
  9. 26
      src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Hsv.cs
  10. 26
      src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.HunterLab.cs
  11. 26
      src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.LinearRgb.cs
  12. 26
      src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Lms.cs
  13. 26
      src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Rgb.cs
  14. 24
      src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.YCbCr.cs
  15. 2
      src/ImageSharp/ColorSpaces/Conversion/Implementation/VonKriesChromaticAdaptation.cs
  16. 6
      src/ImageSharp/Common/Helpers/HexConverter.cs
  17. 22
      src/ImageSharp/Common/Helpers/Shuffle/IComponentShuffle.cs
  18. 12
      src/ImageSharp/Common/Helpers/Shuffle/IPad3Shuffle4.cs
  19. 10
      src/ImageSharp/Common/Helpers/Shuffle/IShuffle3.cs
  20. 10
      src/ImageSharp/Common/Helpers/Shuffle/IShuffle4Slice3.cs
  21. 8
      src/ImageSharp/Common/Helpers/SimdUtils.ExtendedIntrinsics.cs
  22. 4
      src/ImageSharp/Common/Helpers/SimdUtils.FallbackIntrinsics128.cs
  23. 48
      src/ImageSharp/Common/Helpers/SimdUtils.HwIntrinsics.cs
  24. 14
      src/ImageSharp/Common/Helpers/SimdUtils.Pack.cs
  25. 46
      src/ImageSharp/Common/Helpers/SimdUtils.Shuffle.cs
  26. 8
      src/ImageSharp/Compression/Zlib/DeflaterHuffman.cs
  27. 8
      src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs
  28. 8
      src/ImageSharp/Formats/ImageExtensions.Save.tt
  29. 4
      src/ImageSharp/Formats/Jpeg/Components/Block8x8F.Generated.cs
  30. 4
      src/ImageSharp/Formats/Jpeg/Components/Block8x8F.Generated.tt
  31. 6
      src/ImageSharp/Formats/Jpeg/Components/Block8x8F.Intrinsic.cs
  32. 28
      src/ImageSharp/Formats/Jpeg/Components/Block8x8F.ScaledCopy.cs
  33. 22
      src/ImageSharp/Formats/Jpeg/Components/Block8x8F.cs
  34. 8
      src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.CmykAvx.cs
  35. 8
      src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.CmykVector.cs
  36. 8
      src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.GrayScaleAvx.cs
  37. 2
      src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.GrayScaleScalar.cs
  38. 8
      src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.GrayScaleVector.cs
  39. 4
      src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.RgbArm.cs
  40. 4
      src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.RgbAvx.cs
  41. 4
      src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.RgbVector.cs
  42. 8
      src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YCbCrAvx.cs
  43. 8
      src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YCbCrVector.cs
  44. 8
      src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YccKAvx.cs
  45. 8
      src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YccKVector.cs
  46. 16
      src/ImageSharp/Formats/Jpeg/Components/Decoder/ArithmeticScanDecoder.cs
  47. 22
      src/ImageSharp/Formats/Jpeg/Components/Decoder/ComponentProcessors/DownScalingComponentProcessor2.cs
  48. 22
      src/ImageSharp/Formats/Jpeg/Components/Decoder/ComponentProcessors/DownScalingComponentProcessor4.cs
  49. 12
      src/ImageSharp/Formats/Jpeg/Components/Decoder/ComponentProcessors/DownScalingComponentProcessor8.cs
  50. 28
      src/ImageSharp/Formats/Jpeg/Components/Encoder/ComponentProcessor.cs
  51. 32
      src/ImageSharp/Formats/Jpeg/Components/Encoder/HuffmanScanEncoder.cs
  52. 4
      src/ImageSharp/Formats/Jpeg/Components/FloatingPointDCT.cs
  53. 2
      src/ImageSharp/Formats/Jpeg/Components/ScaledFloatingPointDCT.cs
  54. 26
      src/ImageSharp/Formats/Png/Filters/AverageFilter.cs
  55. 26
      src/ImageSharp/Formats/Png/Filters/PaethFilter.cs
  56. 26
      src/ImageSharp/Formats/Png/Filters/SubFilter.cs
  57. 30
      src/ImageSharp/Formats/Png/Filters/UpFilter.cs
  58. 28
      src/ImageSharp/Formats/Png/PngDecoderCore.cs
  59. 4
      src/ImageSharp/Formats/Png/PngEncoderCore.cs
  60. 187
      src/ImageSharp/Formats/Png/PngScanlineProcessor.cs
  61. 2
      src/ImageSharp/Formats/Tiff/Compression/Decompressors/T6TiffCompression.cs
  62. 2
      src/ImageSharp/Formats/Tiff/Compression/TiffBaseCompression.cs
  63. 14
      src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZero1TiffColor{TPixel}.cs
  64. 14
      src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero1TiffColor{TPixel}.cs
  65. 2
      src/ImageSharp/Formats/Tiff/TiffDecoderCore.cs
  66. 16
      src/ImageSharp/Formats/Webp/AlphaDecoder.cs
  67. 24
      src/ImageSharp/Formats/Webp/Lossless/ColorSpaceTransformUtils.cs
  68. 94
      src/ImageSharp/Formats/Webp/Lossless/LosslessUtils.cs
  69. 4
      src/ImageSharp/Formats/Webp/Lossless/Vp8LHistogram.cs
  70. 10
      src/ImageSharp/Formats/Webp/Lossy/LossyUtils.cs
  71. 6
      src/ImageSharp/Formats/Webp/Lossy/QuantEnc.cs
  72. 44
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Abgr32.PixelOperations.Generated.cs
  73. 44
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Argb32.PixelOperations.Generated.cs
  74. 44
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Bgr24.PixelOperations.Generated.cs
  75. 44
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Bgra32.PixelOperations.Generated.cs
  76. 24
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Bgra5551.PixelOperations.Generated.cs
  77. 24
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/L16.PixelOperations.Generated.cs
  78. 24
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/L8.PixelOperations.Generated.cs
  79. 24
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/La16.PixelOperations.Generated.cs
  80. 24
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/La32.PixelOperations.Generated.cs
  81. 44
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Rgb24.PixelOperations.Generated.cs
  82. 24
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Rgb48.PixelOperations.Generated.cs
  83. 44
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Rgba32.PixelOperations.Generated.cs
  84. 24
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Rgba64.PixelOperations.Generated.cs
  85. 2
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/_Common.ttinclude
  86. 4
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/RgbaVector.PixelOperations.cs
  87. 52
      src/ImageSharp/PixelFormats/PixelOperations{TPixel}.Generated.cs
  88. 4
      src/ImageSharp/PixelFormats/PixelOperations{TPixel}.Generated.tt
  89. 4
      src/ImageSharp/PixelFormats/PixelOperations{TPixel}.cs
  90. 8
      src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationSlidingWindowProcessor{TPixel}.cs
  91. 10
      src/ImageSharp/Processing/Processors/Normalization/HistogramEqualizationProcessor{TPixel}.cs
  92. 2
      src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeKernelMap.cs
  93. 16
      src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeWorker.cs
  94. 6
      tests/ImageSharp.Benchmarks/Bulk/FromVector4.cs
  95. 4
      tests/ImageSharp.Benchmarks/Bulk/PremultiplyVector4.cs
  96. 12
      tests/ImageSharp.Benchmarks/Bulk/ToVector4_Rgba32.cs
  97. 4
      tests/ImageSharp.Benchmarks/Bulk/UnPremultiplyVector4.cs
  98. 10
      tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_CopyTo1x1.cs
  99. 8
      tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_Round.cs
  100. 10
      tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertFromRgba32.cs

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

@ -37,7 +37,7 @@ public partial class ColorSpaceConverter
ref CieLch sourceRef = ref MemoryMarshal.GetReference(source); ref CieLch sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLab destRef = ref MemoryMarshal.GetReference(destination); ref CieLab destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref CieLch sp = ref Unsafe.Add(ref sourceRef, i); ref CieLch sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLab dp = ref Unsafe.Add(ref destRef, 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 CieLchuv sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLab destRef = ref MemoryMarshal.GetReference(destination); ref CieLab destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref CieLchuv sp = ref Unsafe.Add(ref sourceRef, i); ref CieLchuv sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLab dp = ref Unsafe.Add(ref destRef, 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 CieLuv sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLab destRef = ref MemoryMarshal.GetReference(destination); ref CieLab destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref CieLuv sp = ref Unsafe.Add(ref sourceRef, i); ref CieLuv sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLab dp = ref Unsafe.Add(ref destRef, 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 CieXyy sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLab destRef = ref MemoryMarshal.GetReference(destination); ref CieLab destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref CieXyy sp = ref Unsafe.Add(ref sourceRef, i); ref CieXyy sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLab dp = ref Unsafe.Add(ref destRef, 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 CieXyz sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLab destRef = ref MemoryMarshal.GetReference(destination); ref CieLab destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref CieXyz sp = ref Unsafe.Add(ref sourceRef, i); ref CieXyz sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLab dp = ref Unsafe.Add(ref destRef, 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 Cmyk sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLab destRef = ref MemoryMarshal.GetReference(destination); ref CieLab destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref Cmyk sp = ref Unsafe.Add(ref sourceRef, i); ref Cmyk sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLab dp = ref Unsafe.Add(ref destRef, 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 Hsl sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLab destRef = ref MemoryMarshal.GetReference(destination); ref CieLab destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref Hsl sp = ref Unsafe.Add(ref sourceRef, i); ref Hsl sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLab dp = ref Unsafe.Add(ref destRef, 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 Hsv sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLab destRef = ref MemoryMarshal.GetReference(destination); ref CieLab destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref Hsv sp = ref Unsafe.Add(ref sourceRef, i); ref Hsv sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLab dp = ref Unsafe.Add(ref destRef, 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 HunterLab sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLab destRef = ref MemoryMarshal.GetReference(destination); ref CieLab destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref HunterLab sp = ref Unsafe.Add(ref sourceRef, i); ref HunterLab sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLab dp = ref Unsafe.Add(ref destRef, 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 Lms sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLab destRef = ref MemoryMarshal.GetReference(destination); ref CieLab destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref Lms sp = ref Unsafe.Add(ref sourceRef, i); ref Lms sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLab dp = ref Unsafe.Add(ref destRef, 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 LinearRgb sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLab destRef = ref MemoryMarshal.GetReference(destination); ref CieLab destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref LinearRgb sp = ref Unsafe.Add(ref sourceRef, i); ref LinearRgb sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLab dp = ref Unsafe.Add(ref destRef, 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 Rgb sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLab destRef = ref MemoryMarshal.GetReference(destination); ref CieLab destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref Rgb sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLab dp = ref Unsafe.Add(ref destRef, 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 YCbCr sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLab destRef = ref MemoryMarshal.GetReference(destination); ref CieLab destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref YCbCr sp = ref Unsafe.Add(ref sourceRef, i); ref YCbCr sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLab dp = ref Unsafe.Add(ref destRef, 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 CieLab sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLch destRef = ref MemoryMarshal.GetReference(destination); ref CieLch destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref CieLab sp = ref Unsafe.Add(ref sourceRef, i); ref CieLab sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLch dp = ref Unsafe.Add(ref destRef, 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 CieLchuv sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLch destRef = ref MemoryMarshal.GetReference(destination); ref CieLch destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref CieLchuv sp = ref Unsafe.Add(ref sourceRef, i); ref CieLchuv sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLch dp = ref Unsafe.Add(ref destRef, 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 CieLuv sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLch destRef = ref MemoryMarshal.GetReference(destination); ref CieLch destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref CieLuv sp = ref Unsafe.Add(ref sourceRef, i); ref CieLuv sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLch dp = ref Unsafe.Add(ref destRef, 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 CieXyy sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLch destRef = ref MemoryMarshal.GetReference(destination); ref CieLch destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref CieXyy sp = ref Unsafe.Add(ref sourceRef, i); ref CieXyy sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLch dp = ref Unsafe.Add(ref destRef, 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 CieXyz sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLch destRef = ref MemoryMarshal.GetReference(destination); ref CieLch destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref CieXyz sp = ref Unsafe.Add(ref sourceRef, i); ref CieXyz sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLch dp = ref Unsafe.Add(ref destRef, 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 Cmyk sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLch destRef = ref MemoryMarshal.GetReference(destination); ref CieLch destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref Cmyk sp = ref Unsafe.Add(ref sourceRef, i); ref Cmyk sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLch dp = ref Unsafe.Add(ref destRef, 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 Hsl sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLch destRef = ref MemoryMarshal.GetReference(destination); ref CieLch destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref Hsl sp = ref Unsafe.Add(ref sourceRef, i); ref Hsl sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLch dp = ref Unsafe.Add(ref destRef, 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 Hsv sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLch destRef = ref MemoryMarshal.GetReference(destination); ref CieLch destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref Hsv sp = ref Unsafe.Add(ref sourceRef, i); ref Hsv sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLch dp = ref Unsafe.Add(ref destRef, 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 HunterLab sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLch destRef = ref MemoryMarshal.GetReference(destination); ref CieLch destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref HunterLab sp = ref Unsafe.Add(ref sourceRef, i); ref HunterLab sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLch dp = ref Unsafe.Add(ref destRef, 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 LinearRgb sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLch destRef = ref MemoryMarshal.GetReference(destination); ref CieLch destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref LinearRgb sp = ref Unsafe.Add(ref sourceRef, i); ref LinearRgb sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLch dp = ref Unsafe.Add(ref destRef, 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 Lms sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLch destRef = ref MemoryMarshal.GetReference(destination); ref CieLch destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref Lms sp = ref Unsafe.Add(ref sourceRef, i); ref Lms sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLch dp = ref Unsafe.Add(ref destRef, 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 Rgb sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLch destRef = ref MemoryMarshal.GetReference(destination); ref CieLch destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref Rgb sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLch dp = ref Unsafe.Add(ref destRef, 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 YCbCr sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLch destRef = ref MemoryMarshal.GetReference(destination); ref CieLch destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref YCbCr sp = ref Unsafe.Add(ref sourceRef, i); ref YCbCr sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLch dp = ref Unsafe.Add(ref destRef, 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 CieLab sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination); ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref CieLab sp = ref Unsafe.Add(ref sourceRef, i); ref CieLab sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLchuv dp = ref Unsafe.Add(ref destRef, 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 CieLch sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination); ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref CieLch sp = ref Unsafe.Add(ref sourceRef, i); ref CieLch sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLchuv dp = ref Unsafe.Add(ref destRef, 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 CieLuv sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination); ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref CieLuv sp = ref Unsafe.Add(ref sourceRef, i); ref CieLuv sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLchuv dp = ref Unsafe.Add(ref destRef, 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 CieXyy sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination); ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref CieXyy sp = ref Unsafe.Add(ref sourceRef, i); ref CieXyy sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLchuv dp = ref Unsafe.Add(ref destRef, 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 CieXyz sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination); ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref CieXyz sp = ref Unsafe.Add(ref sourceRef, i); ref CieXyz sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLchuv dp = ref Unsafe.Add(ref destRef, 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 Cmyk sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination); ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref Cmyk sp = ref Unsafe.Add(ref sourceRef, i); ref Cmyk sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLchuv dp = ref Unsafe.Add(ref destRef, 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 Hsl sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination); ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref Hsl sp = ref Unsafe.Add(ref sourceRef, i); ref Hsl sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLchuv dp = ref Unsafe.Add(ref destRef, 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 Hsv sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination); ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref Hsv sp = ref Unsafe.Add(ref sourceRef, i); ref Hsv sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLchuv dp = ref Unsafe.Add(ref destRef, 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 HunterLab sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination); ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref HunterLab sp = ref Unsafe.Add(ref sourceRef, i); ref HunterLab sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLchuv dp = ref Unsafe.Add(ref destRef, 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 LinearRgb sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination); ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref LinearRgb sp = ref Unsafe.Add(ref sourceRef, i); ref LinearRgb sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLchuv dp = ref Unsafe.Add(ref destRef, 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 Lms sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination); ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref Lms sp = ref Unsafe.Add(ref sourceRef, i); ref Lms sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLchuv dp = ref Unsafe.Add(ref destRef, 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 Rgb sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination); ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref Rgb sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLchuv dp = ref Unsafe.Add(ref destRef, 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 YCbCr sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination); ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref YCbCr sp = ref Unsafe.Add(ref sourceRef, i); ref YCbCr sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLchuv dp = ref Unsafe.Add(ref destRef, 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 CieLab sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLuv destRef = ref MemoryMarshal.GetReference(destination); ref CieLuv destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref CieLab sp = ref Unsafe.Add(ref sourceRef, i); ref CieLab sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLuv dp = ref Unsafe.Add(ref destRef, 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 CieLch sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLuv destRef = ref MemoryMarshal.GetReference(destination); ref CieLuv destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref CieLch sp = ref Unsafe.Add(ref sourceRef, i); ref CieLch sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLuv dp = ref Unsafe.Add(ref destRef, 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 CieLchuv sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLuv destRef = ref MemoryMarshal.GetReference(destination); ref CieLuv destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref CieLchuv sp = ref Unsafe.Add(ref sourceRef, i); ref CieLchuv sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLuv dp = ref Unsafe.Add(ref destRef, 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 CieXyy sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLuv destRef = ref MemoryMarshal.GetReference(destination); ref CieLuv destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref CieXyy sp = ref Unsafe.Add(ref sourceRef, i); ref CieXyy sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLuv dp = ref Unsafe.Add(ref destRef, 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 CieXyz sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLuv destRef = ref MemoryMarshal.GetReference(destination); ref CieLuv destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref CieXyz sp = ref Unsafe.Add(ref sourceRef, i); ref CieXyz sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLuv dp = ref Unsafe.Add(ref destRef, 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 Cmyk sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLuv destRef = ref MemoryMarshal.GetReference(destination); ref CieLuv destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref Cmyk sp = ref Unsafe.Add(ref sourceRef, i); ref Cmyk sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLuv dp = ref Unsafe.Add(ref destRef, 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 Hsl sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLuv destRef = ref MemoryMarshal.GetReference(destination); ref CieLuv destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref Hsl sp = ref Unsafe.Add(ref sourceRef, i); ref Hsl sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLuv dp = ref Unsafe.Add(ref destRef, 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 Hsv sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLuv destRef = ref MemoryMarshal.GetReference(destination); ref CieLuv destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref Hsv sp = ref Unsafe.Add(ref sourceRef, i); ref Hsv sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLuv dp = ref Unsafe.Add(ref destRef, 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 HunterLab sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLuv destRef = ref MemoryMarshal.GetReference(destination); ref CieLuv destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref HunterLab sp = ref Unsafe.Add(ref sourceRef, i); ref HunterLab sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLuv dp = ref Unsafe.Add(ref destRef, 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 Lms sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLuv destRef = ref MemoryMarshal.GetReference(destination); ref CieLuv destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref Lms sp = ref Unsafe.Add(ref sourceRef, i); ref Lms sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLuv dp = ref Unsafe.Add(ref destRef, 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 LinearRgb sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLuv destRef = ref MemoryMarshal.GetReference(destination); ref CieLuv destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref LinearRgb sp = ref Unsafe.Add(ref sourceRef, i); ref LinearRgb sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLuv dp = ref Unsafe.Add(ref destRef, 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 Rgb sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLuv destRef = ref MemoryMarshal.GetReference(destination); ref CieLuv destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref Rgb sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLuv dp = ref Unsafe.Add(ref destRef, 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 YCbCr sourceRef = ref MemoryMarshal.GetReference(source);
ref CieLuv destRef = ref MemoryMarshal.GetReference(destination); ref CieLuv destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref YCbCr sp = ref Unsafe.Add(ref sourceRef, i); ref YCbCr sp = ref Unsafe.Add(ref sourceRef, i);
ref CieLuv dp = ref Unsafe.Add(ref destRef, 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 CieLab sourceRef = ref MemoryMarshal.GetReference(source);
ref CieXyy destRef = ref MemoryMarshal.GetReference(destination); ref CieXyy destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref CieLab sp = ref Unsafe.Add(ref sourceRef, i); ref CieLab sp = ref Unsafe.Add(ref sourceRef, i);
ref CieXyy dp = ref Unsafe.Add(ref destRef, 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 CieLch sourceRef = ref MemoryMarshal.GetReference(source);
ref CieXyy destRef = ref MemoryMarshal.GetReference(destination); ref CieXyy destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref CieLch sp = ref Unsafe.Add(ref sourceRef, i); ref CieLch sp = ref Unsafe.Add(ref sourceRef, i);
ref CieXyy dp = ref Unsafe.Add(ref destRef, 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 CieLchuv sourceRef = ref MemoryMarshal.GetReference(source);
ref CieXyy destRef = ref MemoryMarshal.GetReference(destination); ref CieXyy destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref CieLchuv sp = ref Unsafe.Add(ref sourceRef, i); ref CieLchuv sp = ref Unsafe.Add(ref sourceRef, i);
ref CieXyy dp = ref Unsafe.Add(ref destRef, 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 CieLuv sourceRef = ref MemoryMarshal.GetReference(source);
ref CieXyy destRef = ref MemoryMarshal.GetReference(destination); ref CieXyy destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref CieLuv sp = ref Unsafe.Add(ref sourceRef, i); ref CieLuv sp = ref Unsafe.Add(ref sourceRef, i);
ref CieXyy dp = ref Unsafe.Add(ref destRef, 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 CieXyz sourceRef = ref MemoryMarshal.GetReference(source);
ref CieXyy destRef = ref MemoryMarshal.GetReference(destination); ref CieXyy destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref CieXyz sp = ref Unsafe.Add(ref sourceRef, i); ref CieXyz sp = ref Unsafe.Add(ref sourceRef, i);
ref CieXyy dp = ref Unsafe.Add(ref destRef, 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 Cmyk sourceRef = ref MemoryMarshal.GetReference(source);
ref CieXyy destRef = ref MemoryMarshal.GetReference(destination); ref CieXyy destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref Cmyk sp = ref Unsafe.Add(ref sourceRef, i); ref Cmyk sp = ref Unsafe.Add(ref sourceRef, i);
ref CieXyy dp = ref Unsafe.Add(ref destRef, 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 Hsl sourceRef = ref MemoryMarshal.GetReference(source);
ref CieXyy destRef = ref MemoryMarshal.GetReference(destination); ref CieXyy destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref Hsl sp = ref Unsafe.Add(ref sourceRef, i); ref Hsl sp = ref Unsafe.Add(ref sourceRef, i);
ref CieXyy dp = ref Unsafe.Add(ref destRef, 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 Hsv sourceRef = ref MemoryMarshal.GetReference(source);
ref CieXyy destRef = ref MemoryMarshal.GetReference(destination); ref CieXyy destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref Hsv sp = ref Unsafe.Add(ref sourceRef, i); ref Hsv sp = ref Unsafe.Add(ref sourceRef, i);
ref CieXyy dp = ref Unsafe.Add(ref destRef, 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 HunterLab sourceRef = ref MemoryMarshal.GetReference(source);
ref CieXyy destRef = ref MemoryMarshal.GetReference(destination); ref CieXyy destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref HunterLab sp = ref Unsafe.Add(ref sourceRef, i); ref HunterLab sp = ref Unsafe.Add(ref sourceRef, i);
ref CieXyy dp = ref Unsafe.Add(ref destRef, 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 LinearRgb sourceRef = ref MemoryMarshal.GetReference(source);
ref CieXyy destRef = ref MemoryMarshal.GetReference(destination); ref CieXyy destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref LinearRgb sp = ref Unsafe.Add(ref sourceRef, i); ref LinearRgb sp = ref Unsafe.Add(ref sourceRef, i);
ref CieXyy dp = ref Unsafe.Add(ref destRef, 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 Lms sourceRef = ref MemoryMarshal.GetReference(source);
ref CieXyy destRef = ref MemoryMarshal.GetReference(destination); ref CieXyy destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref Lms sp = ref Unsafe.Add(ref sourceRef, i); ref Lms sp = ref Unsafe.Add(ref sourceRef, i);
ref CieXyy dp = ref Unsafe.Add(ref destRef, 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 Rgb sourceRef = ref MemoryMarshal.GetReference(source);
ref CieXyy destRef = ref MemoryMarshal.GetReference(destination); ref CieXyy destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref Rgb sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb sp = ref Unsafe.Add(ref sourceRef, i);
ref CieXyy dp = ref Unsafe.Add(ref destRef, 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 YCbCr sourceRef = ref MemoryMarshal.GetReference(source);
ref CieXyy destRef = ref MemoryMarshal.GetReference(destination); ref CieXyy destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref YCbCr sp = ref Unsafe.Add(ref sourceRef, i); ref YCbCr sp = ref Unsafe.Add(ref sourceRef, i);
ref CieXyy dp = ref Unsafe.Add(ref destRef, 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 CieLab sourceRef = ref MemoryMarshal.GetReference(source);
ref CieXyz destRef = ref MemoryMarshal.GetReference(destination); ref CieXyz destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref CieLab sp = ref Unsafe.Add(ref sourceRef, i); ref CieLab sp = ref Unsafe.Add(ref sourceRef, i);
ref CieXyz dp = ref Unsafe.Add(ref destRef, 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 CieLch sourceRef = ref MemoryMarshal.GetReference(source);
ref CieXyz destRef = ref MemoryMarshal.GetReference(destination); ref CieXyz destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref CieLch sp = ref Unsafe.Add(ref sourceRef, i); ref CieLch sp = ref Unsafe.Add(ref sourceRef, i);
ref CieXyz dp = ref Unsafe.Add(ref destRef, 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 CieLchuv sourceRef = ref MemoryMarshal.GetReference(source);
ref CieXyz destRef = ref MemoryMarshal.GetReference(destination); ref CieXyz destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref CieLchuv sp = ref Unsafe.Add(ref sourceRef, i); ref CieLchuv sp = ref Unsafe.Add(ref sourceRef, i);
ref CieXyz dp = ref Unsafe.Add(ref destRef, 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 CieLuv sourceRef = ref MemoryMarshal.GetReference(source);
ref CieXyz destRef = ref MemoryMarshal.GetReference(destination); ref CieXyz destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref CieLuv sp = ref Unsafe.Add(ref sourceRef, i); ref CieLuv sp = ref Unsafe.Add(ref sourceRef, i);
ref CieXyz dp = ref Unsafe.Add(ref destRef, 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 CieXyy sourceRef = ref MemoryMarshal.GetReference(source);
ref CieXyz destRef = ref MemoryMarshal.GetReference(destination); ref CieXyz destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref CieXyy sp = ref Unsafe.Add(ref sourceRef, i); ref CieXyy sp = ref Unsafe.Add(ref sourceRef, i);
ref CieXyz dp = ref Unsafe.Add(ref destRef, 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 Cmyk sourceRef = ref MemoryMarshal.GetReference(source);
ref CieXyz destRef = ref MemoryMarshal.GetReference(destination); ref CieXyz destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref Cmyk sp = ref Unsafe.Add(ref sourceRef, i); ref Cmyk sp = ref Unsafe.Add(ref sourceRef, i);
ref CieXyz dp = ref Unsafe.Add(ref destRef, 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 Hsl sourceRef = ref MemoryMarshal.GetReference(source);
ref CieXyz destRef = ref MemoryMarshal.GetReference(destination); ref CieXyz destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref Hsl sp = ref Unsafe.Add(ref sourceRef, i); ref Hsl sp = ref Unsafe.Add(ref sourceRef, i);
ref CieXyz dp = ref Unsafe.Add(ref destRef, 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 Hsv sourceRef = ref MemoryMarshal.GetReference(source);
ref CieXyz destRef = ref MemoryMarshal.GetReference(destination); ref CieXyz destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref Hsv sp = ref Unsafe.Add(ref sourceRef, i); ref Hsv sp = ref Unsafe.Add(ref sourceRef, i);
ref CieXyz dp = ref Unsafe.Add(ref destRef, 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 HunterLab sourceRef = ref MemoryMarshal.GetReference(source);
ref CieXyz destRef = ref MemoryMarshal.GetReference(destination); ref CieXyz destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref HunterLab sp = ref Unsafe.Add(ref sourceRef, i); ref HunterLab sp = ref Unsafe.Add(ref sourceRef, i);
ref CieXyz dp = ref Unsafe.Add(ref destRef, 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 LinearRgb sourceRef = ref MemoryMarshal.GetReference(source);
ref CieXyz destRef = ref MemoryMarshal.GetReference(destination); ref CieXyz destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref LinearRgb sp = ref Unsafe.Add(ref sourceRef, i); ref LinearRgb sp = ref Unsafe.Add(ref sourceRef, i);
ref CieXyz dp = ref Unsafe.Add(ref destRef, 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 Lms sourceRef = ref MemoryMarshal.GetReference(source);
ref CieXyz destRef = ref MemoryMarshal.GetReference(destination); ref CieXyz destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref Lms sp = ref Unsafe.Add(ref sourceRef, i); ref Lms sp = ref Unsafe.Add(ref sourceRef, i);
ref CieXyz dp = ref Unsafe.Add(ref destRef, 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 Rgb sourceRef = ref MemoryMarshal.GetReference(source);
ref CieXyz destRef = ref MemoryMarshal.GetReference(destination); ref CieXyz destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref Rgb sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb sp = ref Unsafe.Add(ref sourceRef, i);
ref CieXyz dp = ref Unsafe.Add(ref destRef, 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 YCbCr sourceRef = ref MemoryMarshal.GetReference(source);
ref CieXyz destRef = ref MemoryMarshal.GetReference(destination); ref CieXyz destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref YCbCr sp = ref Unsafe.Add(ref sourceRef, i); ref YCbCr sp = ref Unsafe.Add(ref sourceRef, i);
ref CieXyz dp = ref Unsafe.Add(ref destRef, 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 CieLab sourceRef = ref MemoryMarshal.GetReference(source);
ref Cmyk destRef = ref MemoryMarshal.GetReference(destination); ref Cmyk destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref CieLab sp = ref Unsafe.Add(ref sourceRef, i); ref CieLab sp = ref Unsafe.Add(ref sourceRef, i);
ref Cmyk dp = ref Unsafe.Add(ref destRef, 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 CieLch sourceRef = ref MemoryMarshal.GetReference(source);
ref Cmyk destRef = ref MemoryMarshal.GetReference(destination); ref Cmyk destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref CieLch sp = ref Unsafe.Add(ref sourceRef, i); ref CieLch sp = ref Unsafe.Add(ref sourceRef, i);
ref Cmyk dp = ref Unsafe.Add(ref destRef, 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 CieLchuv sourceRef = ref MemoryMarshal.GetReference(source);
ref Cmyk destRef = ref MemoryMarshal.GetReference(destination); ref Cmyk destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref CieLchuv sp = ref Unsafe.Add(ref sourceRef, i); ref CieLchuv sp = ref Unsafe.Add(ref sourceRef, i);
ref Cmyk dp = ref Unsafe.Add(ref destRef, 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 CieLuv sourceRef = ref MemoryMarshal.GetReference(source);
ref Cmyk destRef = ref MemoryMarshal.GetReference(destination); ref Cmyk destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref CieLuv sp = ref Unsafe.Add(ref sourceRef, i); ref CieLuv sp = ref Unsafe.Add(ref sourceRef, i);
ref Cmyk dp = ref Unsafe.Add(ref destRef, 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 CieXyy sourceRef = ref MemoryMarshal.GetReference(source);
ref Cmyk destRef = ref MemoryMarshal.GetReference(destination); ref Cmyk destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref CieXyy sp = ref Unsafe.Add(ref sourceRef, i); ref CieXyy sp = ref Unsafe.Add(ref sourceRef, i);
ref Cmyk dp = ref Unsafe.Add(ref destRef, 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 CieXyz sourceRef = ref MemoryMarshal.GetReference(source);
ref Cmyk destRef = ref MemoryMarshal.GetReference(destination); ref Cmyk destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref CieXyz sp = ref Unsafe.Add(ref sourceRef, i); ref CieXyz sp = ref Unsafe.Add(ref sourceRef, i);
ref Cmyk dp = ref Unsafe.Add(ref destRef, 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 Hsl sourceRef = ref MemoryMarshal.GetReference(source);
ref Cmyk destRef = ref MemoryMarshal.GetReference(destination); ref Cmyk destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref Hsl sp = ref Unsafe.Add(ref sourceRef, i); ref Hsl sp = ref Unsafe.Add(ref sourceRef, i);
ref Cmyk dp = ref Unsafe.Add(ref destRef, 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 Hsv sourceRef = ref MemoryMarshal.GetReference(source);
ref Cmyk destRef = ref MemoryMarshal.GetReference(destination); ref Cmyk destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref Hsv sp = ref Unsafe.Add(ref sourceRef, i); ref Hsv sp = ref Unsafe.Add(ref sourceRef, i);
ref Cmyk dp = ref Unsafe.Add(ref destRef, 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 HunterLab sourceRef = ref MemoryMarshal.GetReference(source);
ref Cmyk destRef = ref MemoryMarshal.GetReference(destination); ref Cmyk destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref HunterLab sp = ref Unsafe.Add(ref sourceRef, i); ref HunterLab sp = ref Unsafe.Add(ref sourceRef, i);
ref Cmyk dp = ref Unsafe.Add(ref destRef, 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 LinearRgb sourceRef = ref MemoryMarshal.GetReference(source);
ref Cmyk destRef = ref MemoryMarshal.GetReference(destination); ref Cmyk destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref LinearRgb sp = ref Unsafe.Add(ref sourceRef, i); ref LinearRgb sp = ref Unsafe.Add(ref sourceRef, i);
ref Cmyk dp = ref Unsafe.Add(ref destRef, 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 Lms sourceRef = ref MemoryMarshal.GetReference(source);
ref Cmyk destRef = ref MemoryMarshal.GetReference(destination); ref Cmyk destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref Lms sp = ref Unsafe.Add(ref sourceRef, i); ref Lms sp = ref Unsafe.Add(ref sourceRef, i);
ref Cmyk dp = ref Unsafe.Add(ref destRef, 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 Rgb sourceRef = ref MemoryMarshal.GetReference(source);
ref Cmyk destRef = ref MemoryMarshal.GetReference(destination); ref Cmyk destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref Rgb sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb sp = ref Unsafe.Add(ref sourceRef, i);
ref Cmyk dp = ref Unsafe.Add(ref destRef, 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 YCbCr sourceRef = ref MemoryMarshal.GetReference(source);
ref Cmyk destRef = ref MemoryMarshal.GetReference(destination); ref Cmyk destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref YCbCr sp = ref Unsafe.Add(ref sourceRef, i); ref YCbCr sp = ref Unsafe.Add(ref sourceRef, i);
ref Cmyk dp = ref Unsafe.Add(ref destRef, 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 CieLab sourceRef = ref MemoryMarshal.GetReference(source);
ref Hsl destRef = ref MemoryMarshal.GetReference(destination); ref Hsl destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref CieLab sp = ref Unsafe.Add(ref sourceRef, i); ref CieLab sp = ref Unsafe.Add(ref sourceRef, i);
ref Hsl dp = ref Unsafe.Add(ref destRef, 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 CieLch sourceRef = ref MemoryMarshal.GetReference(source);
ref Hsl destRef = ref MemoryMarshal.GetReference(destination); ref Hsl destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref CieLch sp = ref Unsafe.Add(ref sourceRef, i); ref CieLch sp = ref Unsafe.Add(ref sourceRef, i);
ref Hsl dp = ref Unsafe.Add(ref destRef, 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 CieLchuv sourceRef = ref MemoryMarshal.GetReference(source);
ref Hsl destRef = ref MemoryMarshal.GetReference(destination); ref Hsl destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref CieLchuv sp = ref Unsafe.Add(ref sourceRef, i); ref CieLchuv sp = ref Unsafe.Add(ref sourceRef, i);
ref Hsl dp = ref Unsafe.Add(ref destRef, 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 CieLuv sourceRef = ref MemoryMarshal.GetReference(source);
ref Hsl destRef = ref MemoryMarshal.GetReference(destination); ref Hsl destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref CieLuv sp = ref Unsafe.Add(ref sourceRef, i); ref CieLuv sp = ref Unsafe.Add(ref sourceRef, i);
ref Hsl dp = ref Unsafe.Add(ref destRef, 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 CieXyy sourceRef = ref MemoryMarshal.GetReference(source);
ref Hsl destRef = ref MemoryMarshal.GetReference(destination); ref Hsl destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref CieXyy sp = ref Unsafe.Add(ref sourceRef, i); ref CieXyy sp = ref Unsafe.Add(ref sourceRef, i);
ref Hsl dp = ref Unsafe.Add(ref destRef, 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 CieXyz sourceRef = ref MemoryMarshal.GetReference(source);
ref Hsl destRef = ref MemoryMarshal.GetReference(destination); ref Hsl destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref CieXyz sp = ref Unsafe.Add(ref sourceRef, i); ref CieXyz sp = ref Unsafe.Add(ref sourceRef, i);
ref Hsl dp = ref Unsafe.Add(ref destRef, 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 Cmyk sourceRef = ref MemoryMarshal.GetReference(source);
ref Hsl destRef = ref MemoryMarshal.GetReference(destination); ref Hsl destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref Cmyk sp = ref Unsafe.Add(ref sourceRef, i); ref Cmyk sp = ref Unsafe.Add(ref sourceRef, i);
ref Hsl dp = ref Unsafe.Add(ref destRef, 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 Hsv sourceRef = ref MemoryMarshal.GetReference(source);
ref Hsl destRef = ref MemoryMarshal.GetReference(destination); ref Hsl destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref Hsv sp = ref Unsafe.Add(ref sourceRef, i); ref Hsv sp = ref Unsafe.Add(ref sourceRef, i);
ref Hsl dp = ref Unsafe.Add(ref destRef, 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 HunterLab sourceRef = ref MemoryMarshal.GetReference(source);
ref Hsl destRef = ref MemoryMarshal.GetReference(destination); ref Hsl destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref HunterLab sp = ref Unsafe.Add(ref sourceRef, i); ref HunterLab sp = ref Unsafe.Add(ref sourceRef, i);
ref Hsl dp = ref Unsafe.Add(ref destRef, 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 LinearRgb sourceRef = ref MemoryMarshal.GetReference(source);
ref Hsl destRef = ref MemoryMarshal.GetReference(destination); ref Hsl destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref LinearRgb sp = ref Unsafe.Add(ref sourceRef, i); ref LinearRgb sp = ref Unsafe.Add(ref sourceRef, i);
ref Hsl dp = ref Unsafe.Add(ref destRef, 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 Lms sourceRef = ref MemoryMarshal.GetReference(source);
ref Hsl destRef = ref MemoryMarshal.GetReference(destination); ref Hsl destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref Lms sp = ref Unsafe.Add(ref sourceRef, i); ref Lms sp = ref Unsafe.Add(ref sourceRef, i);
ref Hsl dp = ref Unsafe.Add(ref destRef, 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 Rgb sourceRef = ref MemoryMarshal.GetReference(source);
ref Hsl destRef = ref MemoryMarshal.GetReference(destination); ref Hsl destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref Rgb sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb sp = ref Unsafe.Add(ref sourceRef, i);
ref Hsl dp = ref Unsafe.Add(ref destRef, 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 YCbCr sourceRef = ref MemoryMarshal.GetReference(source);
ref Hsl destRef = ref MemoryMarshal.GetReference(destination); ref Hsl destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref YCbCr sp = ref Unsafe.Add(ref sourceRef, i); ref YCbCr sp = ref Unsafe.Add(ref sourceRef, i);
ref Hsl dp = ref Unsafe.Add(ref destRef, 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 CieLab sourceRef = ref MemoryMarshal.GetReference(source);
ref Hsv destRef = ref MemoryMarshal.GetReference(destination); ref Hsv destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref CieLab sp = ref Unsafe.Add(ref sourceRef, i); ref CieLab sp = ref Unsafe.Add(ref sourceRef, i);
ref Hsv dp = ref Unsafe.Add(ref destRef, 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 CieLch sourceRef = ref MemoryMarshal.GetReference(source);
ref Hsv destRef = ref MemoryMarshal.GetReference(destination); ref Hsv destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref CieLch sp = ref Unsafe.Add(ref sourceRef, i); ref CieLch sp = ref Unsafe.Add(ref sourceRef, i);
ref Hsv dp = ref Unsafe.Add(ref destRef, 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 CieLchuv sourceRef = ref MemoryMarshal.GetReference(source);
ref Hsv destRef = ref MemoryMarshal.GetReference(destination); ref Hsv destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref CieLchuv sp = ref Unsafe.Add(ref sourceRef, i); ref CieLchuv sp = ref Unsafe.Add(ref sourceRef, i);
ref Hsv dp = ref Unsafe.Add(ref destRef, 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 CieLuv sourceRef = ref MemoryMarshal.GetReference(source);
ref Hsv destRef = ref MemoryMarshal.GetReference(destination); ref Hsv destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref CieLuv sp = ref Unsafe.Add(ref sourceRef, i); ref CieLuv sp = ref Unsafe.Add(ref sourceRef, i);
ref Hsv dp = ref Unsafe.Add(ref destRef, 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 CieXyy sourceRef = ref MemoryMarshal.GetReference(source);
ref Hsv destRef = ref MemoryMarshal.GetReference(destination); ref Hsv destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref CieXyy sp = ref Unsafe.Add(ref sourceRef, i); ref CieXyy sp = ref Unsafe.Add(ref sourceRef, i);
ref Hsv dp = ref Unsafe.Add(ref destRef, 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 CieXyz sourceRef = ref MemoryMarshal.GetReference(source);
ref Hsv destRef = ref MemoryMarshal.GetReference(destination); ref Hsv destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref CieXyz sp = ref Unsafe.Add(ref sourceRef, i); ref CieXyz sp = ref Unsafe.Add(ref sourceRef, i);
ref Hsv dp = ref Unsafe.Add(ref destRef, 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 Cmyk sourceRef = ref MemoryMarshal.GetReference(source);
ref Hsv destRef = ref MemoryMarshal.GetReference(destination); ref Hsv destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref Cmyk sp = ref Unsafe.Add(ref sourceRef, i); ref Cmyk sp = ref Unsafe.Add(ref sourceRef, i);
ref Hsv dp = ref Unsafe.Add(ref destRef, 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 Hsl sourceRef = ref MemoryMarshal.GetReference(source);
ref Hsv destRef = ref MemoryMarshal.GetReference(destination); ref Hsv destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref Hsl sp = ref Unsafe.Add(ref sourceRef, i); ref Hsl sp = ref Unsafe.Add(ref sourceRef, i);
ref Hsv dp = ref Unsafe.Add(ref destRef, 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 HunterLab sourceRef = ref MemoryMarshal.GetReference(source);
ref Hsv destRef = ref MemoryMarshal.GetReference(destination); ref Hsv destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref HunterLab sp = ref Unsafe.Add(ref sourceRef, i); ref HunterLab sp = ref Unsafe.Add(ref sourceRef, i);
ref Hsv dp = ref Unsafe.Add(ref destRef, 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 LinearRgb sourceRef = ref MemoryMarshal.GetReference(source);
ref Hsv destRef = ref MemoryMarshal.GetReference(destination); ref Hsv destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref LinearRgb sp = ref Unsafe.Add(ref sourceRef, i); ref LinearRgb sp = ref Unsafe.Add(ref sourceRef, i);
ref Hsv dp = ref Unsafe.Add(ref destRef, 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 Lms sourceRef = ref MemoryMarshal.GetReference(source);
ref Hsv destRef = ref MemoryMarshal.GetReference(destination); ref Hsv destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref Lms sp = ref Unsafe.Add(ref sourceRef, i); ref Lms sp = ref Unsafe.Add(ref sourceRef, i);
ref Hsv dp = ref Unsafe.Add(ref destRef, 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 Rgb sourceRef = ref MemoryMarshal.GetReference(source);
ref Hsv destRef = ref MemoryMarshal.GetReference(destination); ref Hsv destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref Rgb sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb sp = ref Unsafe.Add(ref sourceRef, i);
ref Hsv dp = ref Unsafe.Add(ref destRef, 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 YCbCr sourceRef = ref MemoryMarshal.GetReference(source);
ref Hsv destRef = ref MemoryMarshal.GetReference(destination); ref Hsv destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref YCbCr sp = ref Unsafe.Add(ref sourceRef, i); ref YCbCr sp = ref Unsafe.Add(ref sourceRef, i);
ref Hsv dp = ref Unsafe.Add(ref destRef, 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 CieLab sourceRef = ref MemoryMarshal.GetReference(source);
ref HunterLab destRef = ref MemoryMarshal.GetReference(destination); ref HunterLab destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref CieLab sp = ref Unsafe.Add(ref sourceRef, i); ref CieLab sp = ref Unsafe.Add(ref sourceRef, i);
ref HunterLab dp = ref Unsafe.Add(ref destRef, 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 CieLch sourceRef = ref MemoryMarshal.GetReference(source);
ref HunterLab destRef = ref MemoryMarshal.GetReference(destination); ref HunterLab destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref CieLch sp = ref Unsafe.Add(ref sourceRef, i); ref CieLch sp = ref Unsafe.Add(ref sourceRef, i);
ref HunterLab dp = ref Unsafe.Add(ref destRef, 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 CieLchuv sourceRef = ref MemoryMarshal.GetReference(source);
ref HunterLab destRef = ref MemoryMarshal.GetReference(destination); ref HunterLab destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref CieLchuv sp = ref Unsafe.Add(ref sourceRef, i); ref CieLchuv sp = ref Unsafe.Add(ref sourceRef, i);
ref HunterLab dp = ref Unsafe.Add(ref destRef, 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 CieLuv sourceRef = ref MemoryMarshal.GetReference(source);
ref HunterLab destRef = ref MemoryMarshal.GetReference(destination); ref HunterLab destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref CieLuv sp = ref Unsafe.Add(ref sourceRef, i); ref CieLuv sp = ref Unsafe.Add(ref sourceRef, i);
ref HunterLab dp = ref Unsafe.Add(ref destRef, 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 CieXyy sourceRef = ref MemoryMarshal.GetReference(source);
ref HunterLab destRef = ref MemoryMarshal.GetReference(destination); ref HunterLab destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref CieXyy sp = ref Unsafe.Add(ref sourceRef, i); ref CieXyy sp = ref Unsafe.Add(ref sourceRef, i);
ref HunterLab dp = ref Unsafe.Add(ref destRef, 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 CieXyz sourceRef = ref MemoryMarshal.GetReference(source);
ref HunterLab destRef = ref MemoryMarshal.GetReference(destination); ref HunterLab destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref CieXyz sp = ref Unsafe.Add(ref sourceRef, i); ref CieXyz sp = ref Unsafe.Add(ref sourceRef, i);
ref HunterLab dp = ref Unsafe.Add(ref destRef, 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 Cmyk sourceRef = ref MemoryMarshal.GetReference(source);
ref HunterLab destRef = ref MemoryMarshal.GetReference(destination); ref HunterLab destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref Cmyk sp = ref Unsafe.Add(ref sourceRef, i); ref Cmyk sp = ref Unsafe.Add(ref sourceRef, i);
ref HunterLab dp = ref Unsafe.Add(ref destRef, 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 Hsl sourceRef = ref MemoryMarshal.GetReference(source);
ref HunterLab destRef = ref MemoryMarshal.GetReference(destination); ref HunterLab destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref Hsl sp = ref Unsafe.Add(ref sourceRef, i); ref Hsl sp = ref Unsafe.Add(ref sourceRef, i);
ref HunterLab dp = ref Unsafe.Add(ref destRef, 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 Hsv sourceRef = ref MemoryMarshal.GetReference(source);
ref HunterLab destRef = ref MemoryMarshal.GetReference(destination); ref HunterLab destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref Hsv sp = ref Unsafe.Add(ref sourceRef, i); ref Hsv sp = ref Unsafe.Add(ref sourceRef, i);
ref HunterLab dp = ref Unsafe.Add(ref destRef, 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 LinearRgb sourceRef = ref MemoryMarshal.GetReference(source);
ref HunterLab destRef = ref MemoryMarshal.GetReference(destination); ref HunterLab destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref LinearRgb sp = ref Unsafe.Add(ref sourceRef, i); ref LinearRgb sp = ref Unsafe.Add(ref sourceRef, i);
ref HunterLab dp = ref Unsafe.Add(ref destRef, 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 Lms sourceRef = ref MemoryMarshal.GetReference(source);
ref HunterLab destRef = ref MemoryMarshal.GetReference(destination); ref HunterLab destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref Lms sp = ref Unsafe.Add(ref sourceRef, i); ref Lms sp = ref Unsafe.Add(ref sourceRef, i);
ref HunterLab dp = ref Unsafe.Add(ref destRef, 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 Rgb sourceRef = ref MemoryMarshal.GetReference(source);
ref HunterLab destRef = ref MemoryMarshal.GetReference(destination); ref HunterLab destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref Rgb sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb sp = ref Unsafe.Add(ref sourceRef, i);
ref HunterLab dp = ref Unsafe.Add(ref destRef, 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 YCbCr sourceRef = ref MemoryMarshal.GetReference(source);
ref HunterLab destRef = ref MemoryMarshal.GetReference(destination); ref HunterLab destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref YCbCr sp = ref Unsafe.Add(ref sourceRef, i); ref YCbCr sp = ref Unsafe.Add(ref sourceRef, i);
ref HunterLab dp = ref Unsafe.Add(ref destRef, 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 CieLab sourceRef = ref MemoryMarshal.GetReference(source);
ref LinearRgb destRef = ref MemoryMarshal.GetReference(destination); ref LinearRgb destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref CieLab sp = ref Unsafe.Add(ref sourceRef, i); ref CieLab sp = ref Unsafe.Add(ref sourceRef, i);
ref LinearRgb dp = ref Unsafe.Add(ref destRef, 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 CieLch sourceRef = ref MemoryMarshal.GetReference(source);
ref LinearRgb destRef = ref MemoryMarshal.GetReference(destination); ref LinearRgb destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref CieLch sp = ref Unsafe.Add(ref sourceRef, i); ref CieLch sp = ref Unsafe.Add(ref sourceRef, i);
ref LinearRgb dp = ref Unsafe.Add(ref destRef, 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 CieLchuv sourceRef = ref MemoryMarshal.GetReference(source);
ref LinearRgb destRef = ref MemoryMarshal.GetReference(destination); ref LinearRgb destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref CieLchuv sp = ref Unsafe.Add(ref sourceRef, i); ref CieLchuv sp = ref Unsafe.Add(ref sourceRef, i);
ref LinearRgb dp = ref Unsafe.Add(ref destRef, 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 CieLuv sourceRef = ref MemoryMarshal.GetReference(source);
ref LinearRgb destRef = ref MemoryMarshal.GetReference(destination); ref LinearRgb destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref CieLuv sp = ref Unsafe.Add(ref sourceRef, i); ref CieLuv sp = ref Unsafe.Add(ref sourceRef, i);
ref LinearRgb dp = ref Unsafe.Add(ref destRef, 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 CieXyy sourceRef = ref MemoryMarshal.GetReference(source);
ref LinearRgb destRef = ref MemoryMarshal.GetReference(destination); ref LinearRgb destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref CieXyy sp = ref Unsafe.Add(ref sourceRef, i); ref CieXyy sp = ref Unsafe.Add(ref sourceRef, i);
ref LinearRgb dp = ref Unsafe.Add(ref destRef, 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 CieXyz sourceRef = ref MemoryMarshal.GetReference(source);
ref LinearRgb destRef = ref MemoryMarshal.GetReference(destination); ref LinearRgb destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref CieXyz sp = ref Unsafe.Add(ref sourceRef, i); ref CieXyz sp = ref Unsafe.Add(ref sourceRef, i);
ref LinearRgb dp = ref Unsafe.Add(ref destRef, 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 Cmyk sourceRef = ref MemoryMarshal.GetReference(source);
ref LinearRgb destRef = ref MemoryMarshal.GetReference(destination); ref LinearRgb destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref Cmyk sp = ref Unsafe.Add(ref sourceRef, i); ref Cmyk sp = ref Unsafe.Add(ref sourceRef, i);
ref LinearRgb dp = ref Unsafe.Add(ref destRef, 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 Hsl sourceRef = ref MemoryMarshal.GetReference(source);
ref LinearRgb destRef = ref MemoryMarshal.GetReference(destination); ref LinearRgb destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref Hsl sp = ref Unsafe.Add(ref sourceRef, i); ref Hsl sp = ref Unsafe.Add(ref sourceRef, i);
ref LinearRgb dp = ref Unsafe.Add(ref destRef, 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 Hsv sourceRef = ref MemoryMarshal.GetReference(source);
ref LinearRgb destRef = ref MemoryMarshal.GetReference(destination); ref LinearRgb destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref Hsv sp = ref Unsafe.Add(ref sourceRef, i); ref Hsv sp = ref Unsafe.Add(ref sourceRef, i);
ref LinearRgb dp = ref Unsafe.Add(ref destRef, 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 HunterLab sourceRef = ref MemoryMarshal.GetReference(source);
ref LinearRgb destRef = ref MemoryMarshal.GetReference(destination); ref LinearRgb destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref HunterLab sp = ref Unsafe.Add(ref sourceRef, i); ref HunterLab sp = ref Unsafe.Add(ref sourceRef, i);
ref LinearRgb dp = ref Unsafe.Add(ref destRef, 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 Lms sourceRef = ref MemoryMarshal.GetReference(source);
ref LinearRgb destRef = ref MemoryMarshal.GetReference(destination); ref LinearRgb destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref Lms sp = ref Unsafe.Add(ref sourceRef, i); ref Lms sp = ref Unsafe.Add(ref sourceRef, i);
ref LinearRgb dp = ref Unsafe.Add(ref destRef, 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 Rgb sourceRef = ref MemoryMarshal.GetReference(source);
ref LinearRgb destRef = ref MemoryMarshal.GetReference(destination); ref LinearRgb destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref Rgb sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb sp = ref Unsafe.Add(ref sourceRef, i);
ref LinearRgb dp = ref Unsafe.Add(ref destRef, 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 YCbCr sourceRef = ref MemoryMarshal.GetReference(source);
ref LinearRgb destRef = ref MemoryMarshal.GetReference(destination); ref LinearRgb destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref YCbCr sp = ref Unsafe.Add(ref sourceRef, i); ref YCbCr sp = ref Unsafe.Add(ref sourceRef, i);
ref LinearRgb dp = ref Unsafe.Add(ref destRef, i); ref LinearRgb dp = ref Unsafe.Add(ref destRef, i);

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

@ -24,7 +24,7 @@ public partial class ColorSpaceConverter
ref CieLab sourceRef = ref MemoryMarshal.GetReference(source); ref CieLab sourceRef = ref MemoryMarshal.GetReference(source);
ref Lms destRef = ref MemoryMarshal.GetReference(destination); ref Lms destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref CieLab sp = ref Unsafe.Add(ref sourceRef, i); ref CieLab sp = ref Unsafe.Add(ref sourceRef, i);
ref Lms dp = ref Unsafe.Add(ref destRef, 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 CieLch sourceRef = ref MemoryMarshal.GetReference(source);
ref Lms destRef = ref MemoryMarshal.GetReference(destination); ref Lms destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref CieLch sp = ref Unsafe.Add(ref sourceRef, i); ref CieLch sp = ref Unsafe.Add(ref sourceRef, i);
ref Lms dp = ref Unsafe.Add(ref destRef, 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 CieLchuv sourceRef = ref MemoryMarshal.GetReference(source);
ref Lms destRef = ref MemoryMarshal.GetReference(destination); ref Lms destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref CieLchuv sp = ref Unsafe.Add(ref sourceRef, i); ref CieLchuv sp = ref Unsafe.Add(ref sourceRef, i);
ref Lms dp = ref Unsafe.Add(ref destRef, 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 CieLuv sourceRef = ref MemoryMarshal.GetReference(source);
ref Lms destRef = ref MemoryMarshal.GetReference(destination); ref Lms destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref CieLuv sp = ref Unsafe.Add(ref sourceRef, i); ref CieLuv sp = ref Unsafe.Add(ref sourceRef, i);
ref Lms dp = ref Unsafe.Add(ref destRef, 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 CieXyy sourceRef = ref MemoryMarshal.GetReference(source);
ref Lms destRef = ref MemoryMarshal.GetReference(destination); ref Lms destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref CieXyy sp = ref Unsafe.Add(ref sourceRef, i); ref CieXyy sp = ref Unsafe.Add(ref sourceRef, i);
ref Lms dp = ref Unsafe.Add(ref destRef, 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 CieXyz sourceRef = ref MemoryMarshal.GetReference(source);
ref Lms destRef = ref MemoryMarshal.GetReference(destination); ref Lms destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref CieXyz sp = ref Unsafe.Add(ref sourceRef, i); ref CieXyz sp = ref Unsafe.Add(ref sourceRef, i);
ref Lms dp = ref Unsafe.Add(ref destRef, 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 Cmyk sourceRef = ref MemoryMarshal.GetReference(source);
ref Lms destRef = ref MemoryMarshal.GetReference(destination); ref Lms destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref Cmyk sp = ref Unsafe.Add(ref sourceRef, i); ref Cmyk sp = ref Unsafe.Add(ref sourceRef, i);
ref Lms dp = ref Unsafe.Add(ref destRef, 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 Hsl sourceRef = ref MemoryMarshal.GetReference(source);
ref Lms destRef = ref MemoryMarshal.GetReference(destination); ref Lms destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref Hsl sp = ref Unsafe.Add(ref sourceRef, i); ref Hsl sp = ref Unsafe.Add(ref sourceRef, i);
ref Lms dp = ref Unsafe.Add(ref destRef, 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 Hsv sourceRef = ref MemoryMarshal.GetReference(source);
ref Lms destRef = ref MemoryMarshal.GetReference(destination); ref Lms destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref Hsv sp = ref Unsafe.Add(ref sourceRef, i); ref Hsv sp = ref Unsafe.Add(ref sourceRef, i);
ref Lms dp = ref Unsafe.Add(ref destRef, 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 HunterLab sourceRef = ref MemoryMarshal.GetReference(source);
ref Lms destRef = ref MemoryMarshal.GetReference(destination); ref Lms destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref HunterLab sp = ref Unsafe.Add(ref sourceRef, i); ref HunterLab sp = ref Unsafe.Add(ref sourceRef, i);
ref Lms dp = ref Unsafe.Add(ref destRef, 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 LinearRgb sourceRef = ref MemoryMarshal.GetReference(source);
ref Lms destRef = ref MemoryMarshal.GetReference(destination); ref Lms destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref LinearRgb sp = ref Unsafe.Add(ref sourceRef, i); ref LinearRgb sp = ref Unsafe.Add(ref sourceRef, i);
ref Lms dp = ref Unsafe.Add(ref destRef, 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 Rgb sourceRef = ref MemoryMarshal.GetReference(source);
ref Lms destRef = ref MemoryMarshal.GetReference(destination); ref Lms destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref Rgb sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb sp = ref Unsafe.Add(ref sourceRef, i);
ref Lms dp = ref Unsafe.Add(ref destRef, 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 YCbCr sourceRef = ref MemoryMarshal.GetReference(source);
ref Lms destRef = ref MemoryMarshal.GetReference(destination); ref Lms destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref YCbCr sp = ref Unsafe.Add(ref sourceRef, i); ref YCbCr sp = ref Unsafe.Add(ref sourceRef, i);
ref Lms dp = ref Unsafe.Add(ref destRef, 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 CieLab sourceRef = ref MemoryMarshal.GetReference(source);
ref Rgb destRef = ref MemoryMarshal.GetReference(destination); ref Rgb destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref CieLab sp = ref Unsafe.Add(ref sourceRef, i); ref CieLab sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgb dp = ref Unsafe.Add(ref destRef, 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 CieLch sourceRef = ref MemoryMarshal.GetReference(source);
ref Rgb destRef = ref MemoryMarshal.GetReference(destination); ref Rgb destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref CieLch sp = ref Unsafe.Add(ref sourceRef, i); ref CieLch sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgb dp = ref Unsafe.Add(ref destRef, 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 CieLchuv sourceRef = ref MemoryMarshal.GetReference(source);
ref Rgb destRef = ref MemoryMarshal.GetReference(destination); ref Rgb destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref CieLchuv sp = ref Unsafe.Add(ref sourceRef, i); ref CieLchuv sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgb dp = ref Unsafe.Add(ref destRef, 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 CieLuv sourceRef = ref MemoryMarshal.GetReference(source);
ref Rgb destRef = ref MemoryMarshal.GetReference(destination); ref Rgb destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref CieLuv sp = ref Unsafe.Add(ref sourceRef, i); ref CieLuv sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgb dp = ref Unsafe.Add(ref destRef, 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 CieXyy sourceRef = ref MemoryMarshal.GetReference(source);
ref Rgb destRef = ref MemoryMarshal.GetReference(destination); ref Rgb destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref CieXyy sp = ref Unsafe.Add(ref sourceRef, i); ref CieXyy sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgb dp = ref Unsafe.Add(ref destRef, 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 CieXyz sourceRef = ref MemoryMarshal.GetReference(source);
ref Rgb destRef = ref MemoryMarshal.GetReference(destination); ref Rgb destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref CieXyz sp = ref Unsafe.Add(ref sourceRef, i); ref CieXyz sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgb dp = ref Unsafe.Add(ref destRef, 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 Cmyk sourceRef = ref MemoryMarshal.GetReference(source);
ref Rgb destRef = ref MemoryMarshal.GetReference(destination); ref Rgb destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref Cmyk sp = ref Unsafe.Add(ref sourceRef, i); ref Cmyk sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgb dp = ref Unsafe.Add(ref destRef, 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 Hsv sourceRef = ref MemoryMarshal.GetReference(source);
ref Rgb destRef = ref MemoryMarshal.GetReference(destination); ref Rgb destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref Hsv sp = ref Unsafe.Add(ref sourceRef, i); ref Hsv sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgb dp = ref Unsafe.Add(ref destRef, 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 Hsl sourceRef = ref MemoryMarshal.GetReference(source);
ref Rgb destRef = ref MemoryMarshal.GetReference(destination); ref Rgb destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref Hsl sp = ref Unsafe.Add(ref sourceRef, i); ref Hsl sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgb dp = ref Unsafe.Add(ref destRef, 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 HunterLab sourceRef = ref MemoryMarshal.GetReference(source);
ref Rgb destRef = ref MemoryMarshal.GetReference(destination); ref Rgb destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref HunterLab sp = ref Unsafe.Add(ref sourceRef, i); ref HunterLab sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgb dp = ref Unsafe.Add(ref destRef, 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 LinearRgb sourceRef = ref MemoryMarshal.GetReference(source);
ref Rgb destRef = ref MemoryMarshal.GetReference(destination); ref Rgb destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref LinearRgb sp = ref Unsafe.Add(ref sourceRef, i); ref LinearRgb sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgb dp = ref Unsafe.Add(ref destRef, 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 Lms sourceRef = ref MemoryMarshal.GetReference(source);
ref Rgb destRef = ref MemoryMarshal.GetReference(destination); ref Rgb destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref Lms sp = ref Unsafe.Add(ref sourceRef, i); ref Lms sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgb dp = ref Unsafe.Add(ref destRef, 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 YCbCr sourceRef = ref MemoryMarshal.GetReference(source);
ref Rgb destRef = ref MemoryMarshal.GetReference(destination); ref Rgb destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref YCbCr sp = ref Unsafe.Add(ref sourceRef, i); ref YCbCr sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgb dp = ref Unsafe.Add(ref destRef, 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 CieLab sourceRef = ref MemoryMarshal.GetReference(source);
ref YCbCr destRef = ref MemoryMarshal.GetReference(destination); ref YCbCr destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref CieLab sp = ref Unsafe.Add(ref sourceRef, i); ref CieLab sp = ref Unsafe.Add(ref sourceRef, i);
ref YCbCr dp = ref Unsafe.Add(ref destRef, 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 CieLch sourceRef = ref MemoryMarshal.GetReference(source);
ref YCbCr destRef = ref MemoryMarshal.GetReference(destination); ref YCbCr destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref CieLch sp = ref Unsafe.Add(ref sourceRef, i); ref CieLch sp = ref Unsafe.Add(ref sourceRef, i);
ref YCbCr dp = ref Unsafe.Add(ref destRef, 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 CieLuv sourceRef = ref MemoryMarshal.GetReference(source);
ref YCbCr destRef = ref MemoryMarshal.GetReference(destination); ref YCbCr destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref CieLuv sp = ref Unsafe.Add(ref sourceRef, i); ref CieLuv sp = ref Unsafe.Add(ref sourceRef, i);
ref YCbCr dp = ref Unsafe.Add(ref destRef, 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 CieXyy sourceRef = ref MemoryMarshal.GetReference(source);
ref YCbCr destRef = ref MemoryMarshal.GetReference(destination); ref YCbCr destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref CieXyy sp = ref Unsafe.Add(ref sourceRef, i); ref CieXyy sp = ref Unsafe.Add(ref sourceRef, i);
ref YCbCr dp = ref Unsafe.Add(ref destRef, 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 CieXyz sourceRef = ref MemoryMarshal.GetReference(source);
ref YCbCr destRef = ref MemoryMarshal.GetReference(destination); ref YCbCr destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref CieXyz sp = ref Unsafe.Add(ref sourceRef, i); ref CieXyz sp = ref Unsafe.Add(ref sourceRef, i);
ref YCbCr dp = ref Unsafe.Add(ref destRef, 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 Cmyk sourceRef = ref MemoryMarshal.GetReference(source);
ref YCbCr destRef = ref MemoryMarshal.GetReference(destination); ref YCbCr destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref Cmyk sp = ref Unsafe.Add(ref sourceRef, i); ref Cmyk sp = ref Unsafe.Add(ref sourceRef, i);
ref YCbCr dp = ref Unsafe.Add(ref destRef, 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 Hsl sourceRef = ref MemoryMarshal.GetReference(source);
ref YCbCr destRef = ref MemoryMarshal.GetReference(destination); ref YCbCr destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref Hsl sp = ref Unsafe.Add(ref sourceRef, i); ref Hsl sp = ref Unsafe.Add(ref sourceRef, i);
ref YCbCr dp = ref Unsafe.Add(ref destRef, 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 Hsv sourceRef = ref MemoryMarshal.GetReference(source);
ref YCbCr destRef = ref MemoryMarshal.GetReference(destination); ref YCbCr destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref Hsv sp = ref Unsafe.Add(ref sourceRef, i); ref Hsv sp = ref Unsafe.Add(ref sourceRef, i);
ref YCbCr dp = ref Unsafe.Add(ref destRef, 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 HunterLab sourceRef = ref MemoryMarshal.GetReference(source);
ref YCbCr destRef = ref MemoryMarshal.GetReference(destination); ref YCbCr destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref HunterLab sp = ref Unsafe.Add(ref sourceRef, i); ref HunterLab sp = ref Unsafe.Add(ref sourceRef, i);
ref YCbCr dp = ref Unsafe.Add(ref destRef, 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 LinearRgb sourceRef = ref MemoryMarshal.GetReference(source);
ref YCbCr destRef = ref MemoryMarshal.GetReference(destination); ref YCbCr destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref LinearRgb sp = ref Unsafe.Add(ref sourceRef, i); ref LinearRgb sp = ref Unsafe.Add(ref sourceRef, i);
ref YCbCr dp = ref Unsafe.Add(ref destRef, 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 Lms sourceRef = ref MemoryMarshal.GetReference(source);
ref YCbCr destRef = ref MemoryMarshal.GetReference(destination); ref YCbCr destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref Lms sp = ref Unsafe.Add(ref sourceRef, i); ref Lms sp = ref Unsafe.Add(ref sourceRef, i);
ref YCbCr dp = ref Unsafe.Add(ref destRef, 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 Rgb sourceRef = ref MemoryMarshal.GetReference(source);
ref YCbCr destRef = ref MemoryMarshal.GetReference(destination); ref YCbCr destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref Rgb sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb sp = ref Unsafe.Add(ref sourceRef, i);
ref YCbCr dp = ref Unsafe.Add(ref destRef, 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 sourceRef = ref MemoryMarshal.GetReference(source);
ref CieXyz destRef = ref MemoryMarshal.GetReference(destination); ref CieXyz destRef = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref CieXyz sp = ref Unsafe.Add(ref sourceRef, i); ref CieXyz sp = ref Unsafe.Add(ref sourceRef, i);
ref CieXyz dp = ref Unsafe.Add(ref destRef, i); ref CieXyz dp = ref Unsafe.Add(ref destRef, i);

6
src/ImageSharp/Common/Helpers/HexConverter.cs

@ -16,12 +16,12 @@ internal static class HexConverter
/// <returns>The number of bytes written to <paramref name="bytes"/>.</returns> /// <returns>The number of bytes written to <paramref name="bytes"/>.</returns>
public static int HexStringToBytes(ReadOnlySpan<char> chars, Span<byte> bytes) public static int HexStringToBytes(ReadOnlySpan<char> chars, Span<byte> bytes)
{ {
if ((chars.Length & 1 /* bit-hack for % 2 */) != 0) if (Numerics.Modulo2(chars.Length) != 0)
{ {
throw new ArgumentException("Input string length must be a multiple of 2", nameof(chars)); throw new ArgumentException("Input string length must be a multiple of 2", nameof(chars));
} }
if ((bytes.Length << 1 /* bit-hack for * 2 */) < chars.Length) if ((bytes.Length << 1 /* bit-hack for *2 */) < chars.Length)
{ {
throw new ArgumentException("Output span must be at least half the length of the input string"); throw new ArgumentException("Output span must be at least half the length of the input string");
} }
@ -55,7 +55,7 @@ internal static class HexConverter
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 255 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 255
}; };
return c >= charToHexLookup.Length ? 0xFF : charToHexLookup[c]; return (uint)c >= (uint)charToHexLookup.Length ? 0xFF : charToHexLookup[c];
} }
// See https://source.dot.net/#System.Private.CoreLib/HexConverter.cs,4681d45a0aa0b361 // See https://source.dot.net/#System.Private.CoreLib/HexConverter.cs,4681d45a0aa0b361

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

@ -61,14 +61,14 @@ internal readonly struct DefaultShuffle4 : IShuffle4
ref byte sBase = ref MemoryMarshal.GetReference(source); ref byte sBase = ref MemoryMarshal.GetReference(source);
ref byte dBase = ref MemoryMarshal.GetReference(dest); ref byte dBase = ref MemoryMarshal.GetReference(dest);
Shuffle.InverseMMShuffle(this.Control, out int p3, out int p2, out int p1, out int p0); Shuffle.InverseMMShuffle(this.Control, out uint p3, out uint p2, out uint p1, out uint p0);
for (nint i = 0; i < (uint)source.Length; i += 4) for (nuint i = 0; i < (uint)source.Length; i += 4)
{ {
Unsafe.Add(ref dBase, i + 0) = Unsafe.Add(ref sBase, (nint)(uint)p0 + i); Unsafe.Add(ref dBase, i + 0) = Unsafe.Add(ref sBase, p0 + i);
Unsafe.Add(ref dBase, i + 1) = Unsafe.Add(ref sBase, (nint)(uint)p1 + i); Unsafe.Add(ref dBase, i + 1) = Unsafe.Add(ref sBase, p1 + i);
Unsafe.Add(ref dBase, i + 2) = Unsafe.Add(ref sBase, (nint)(uint)p2 + i); Unsafe.Add(ref dBase, i + 2) = Unsafe.Add(ref sBase, p2 + i);
Unsafe.Add(ref dBase, i + 3) = Unsafe.Add(ref sBase, (nint)(uint)p3 + i); Unsafe.Add(ref dBase, i + 3) = Unsafe.Add(ref sBase, p3 + i);
} }
} }
} }
@ -86,7 +86,7 @@ internal readonly struct WXYZShuffle4 : IShuffle4
ref uint dBase = ref Unsafe.As<byte, uint>(ref MemoryMarshal.GetReference(dest)); ref uint dBase = ref Unsafe.As<byte, uint>(ref MemoryMarshal.GetReference(dest));
int n = (int)((uint)source.Length / 4); int n = (int)((uint)source.Length / 4);
for (nint i = 0; i < (uint)n; i++) for (nuint i = 0; i < (uint)n; i++)
{ {
uint packed = Unsafe.Add(ref sBase, 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)); ref uint dBase = ref Unsafe.As<byte, uint>(ref MemoryMarshal.GetReference(dest));
int n = (int)((uint)source.Length / 4); int n = (int)((uint)source.Length / 4);
for (nint i = 0; i < (uint)n; i++) for (nuint i = 0; i < (uint)n; i++)
{ {
uint packed = Unsafe.Add(ref sBase, 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)); ref uint dBase = ref Unsafe.As<byte, uint>(ref MemoryMarshal.GetReference(dest));
int n = (int)((uint)source.Length / 4); int n = (int)((uint)source.Length / 4);
for (nint i = 0; i < (uint)n; i++) for (nuint i = 0; i < (uint)n; i++)
{ {
uint packed = Unsafe.Add(ref sBase, 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)); ref uint dBase = ref Unsafe.As<byte, uint>(ref MemoryMarshal.GetReference(dest));
int n = (int)((uint)source.Length / 4); int n = (int)((uint)source.Length / 4);
for (nint i = 0; i < (uint)n; i++) for (nuint i = 0; i < (uint)n; i++)
{ {
uint packed = Unsafe.Add(ref sBase, 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)); ref uint dBase = ref Unsafe.As<byte, uint>(ref MemoryMarshal.GetReference(dest));
int n = (int)((uint)source.Length / 4); int n = (int)((uint)source.Length / 4);
for (nint i = 0; i < (uint)n; i++) for (nuint i = 0; i < (uint)n; i++)
{ {
uint packed = Unsafe.Add(ref sBase, i); uint packed = Unsafe.Add(ref sBase, i);

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

@ -29,21 +29,21 @@ internal readonly struct DefaultPad3Shuffle4 : IPad3Shuffle4
ref byte sBase = ref MemoryMarshal.GetReference(source); ref byte sBase = ref MemoryMarshal.GetReference(source);
ref byte dBase = ref MemoryMarshal.GetReference(dest); ref byte dBase = ref MemoryMarshal.GetReference(dest);
Shuffle.InverseMMShuffle(this.Control, out int p3, out int p2, out int p1, out int p0); Shuffle.InverseMMShuffle(this.Control, out uint p3, out uint p2, out uint p1, out uint p0);
Span<byte> temp = stackalloc byte[4]; Span<byte> temp = stackalloc byte[4];
ref byte t = ref MemoryMarshal.GetReference(temp); ref byte t = ref MemoryMarshal.GetReference(temp);
ref uint tu = ref Unsafe.As<byte, uint>(ref t); ref uint tu = ref Unsafe.As<byte, uint>(ref t);
for (nint i = 0, j = 0; i < (uint)source.Length; i += 3, j += 4) for (nuint i = 0, j = 0; i < (uint)source.Length; i += 3, j += 4)
{ {
ref byte s = ref Unsafe.Add(ref sBase, i); ref byte s = ref Unsafe.Add(ref sBase, i);
tu = Unsafe.As<byte, uint>(ref s) | 0xFF000000; tu = Unsafe.As<byte, uint>(ref s) | 0xFF000000;
Unsafe.Add(ref dBase, j + 0) = Unsafe.Add(ref t, (uint)p0); Unsafe.Add(ref dBase, j + 0) = Unsafe.Add(ref t, p0);
Unsafe.Add(ref dBase, j + 1) = Unsafe.Add(ref t, (uint)p1); Unsafe.Add(ref dBase, j + 1) = Unsafe.Add(ref t, p1);
Unsafe.Add(ref dBase, j + 2) = Unsafe.Add(ref t, (uint)p2); Unsafe.Add(ref dBase, j + 2) = Unsafe.Add(ref t, p2);
Unsafe.Add(ref dBase, j + 3) = Unsafe.Add(ref t, (uint)p3); Unsafe.Add(ref dBase, j + 3) = Unsafe.Add(ref t, p3);
} }
} }
} }

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

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

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

@ -29,13 +29,13 @@ internal readonly struct DefaultShuffle4Slice3 : IShuffle4Slice3
ref byte sBase = ref MemoryMarshal.GetReference(source); ref byte sBase = ref MemoryMarshal.GetReference(source);
ref byte dBase = ref MemoryMarshal.GetReference(dest); ref byte dBase = ref MemoryMarshal.GetReference(dest);
Shuffle.InverseMMShuffle(this.Control, out _, out int p2, out int p1, out int p0); Shuffle.InverseMMShuffle(this.Control, out _, out uint p2, out uint p1, out uint p0);
for (nint i = 0, j = 0; i < (uint)dest.Length; i += 3, j += 4) for (nuint i = 0, j = 0; i < (uint)dest.Length; i += 3, j += 4)
{ {
Unsafe.Add(ref dBase, i + 0) = Unsafe.Add(ref sBase, (nint)(uint)p0 + j); Unsafe.Add(ref dBase, i + 0) = Unsafe.Add(ref sBase, p0 + j);
Unsafe.Add(ref dBase, i + 1) = Unsafe.Add(ref sBase, (nint)(uint)p1 + j); Unsafe.Add(ref dBase, i + 1) = Unsafe.Add(ref sBase, p1 + j);
Unsafe.Add(ref dBase, i + 2) = Unsafe.Add(ref sBase, (nint)(uint)p2 + j); Unsafe.Add(ref dBase, i + 2) = Unsafe.Add(ref sBase, p2 + j);
} }
} }
} }

8
src/ImageSharp/Common/Helpers/SimdUtils.ExtendedIntrinsics.cs

@ -97,12 +97,12 @@ internal static partial class SimdUtils
{ {
VerifySpanInput(source, dest, Vector<byte>.Count); VerifySpanInput(source, dest, Vector<byte>.Count);
nint n = (nint)(uint)dest.Length / Vector<byte>.Count; nuint n = (uint)(dest.Length / Vector<byte>.Count);
ref Vector<byte> sourceBase = ref Unsafe.As<byte, Vector<byte>>(ref MemoryMarshal.GetReference(source)); ref Vector<byte> sourceBase = ref Unsafe.As<byte, Vector<byte>>(ref MemoryMarshal.GetReference(source));
ref Vector<float> destBase = ref Unsafe.As<float, Vector<float>>(ref MemoryMarshal.GetReference(dest)); ref Vector<float> destBase = ref Unsafe.As<float, Vector<float>>(ref MemoryMarshal.GetReference(dest));
for (nint i = 0; i < n; i++) for (nuint i = 0; i < n; i++)
{ {
Vector<byte> b = Unsafe.Add(ref sourceBase, i); Vector<byte> b = Unsafe.Add(ref sourceBase, i);
@ -132,13 +132,13 @@ internal static partial class SimdUtils
{ {
VerifySpanInput(source, dest, Vector<byte>.Count); VerifySpanInput(source, dest, Vector<byte>.Count);
nint n = (nint)(uint)dest.Length / Vector<byte>.Count; nuint n = (uint)(dest.Length / Vector<byte>.Count);
ref Vector<float> sourceBase = ref Vector<float> sourceBase =
ref Unsafe.As<float, Vector<float>>(ref MemoryMarshal.GetReference(source)); ref Unsafe.As<float, Vector<float>>(ref MemoryMarshal.GetReference(source));
ref Vector<byte> destBase = ref Unsafe.As<byte, Vector<byte>>(ref MemoryMarshal.GetReference(dest)); ref Vector<byte> destBase = ref Unsafe.As<byte, Vector<byte>>(ref MemoryMarshal.GetReference(dest));
for (nint i = 0; i < n; i++) for (nuint i = 0; i < n; i++)
{ {
ref Vector<float> s = ref Unsafe.Add(ref sourceBase, i * 4); ref Vector<float> s = ref Unsafe.Add(ref sourceBase, i * 4);

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

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

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

@ -221,7 +221,7 @@ internal static partial class SimdUtils
ref Vector256<float> destBase = ref Vector256<float> destBase =
ref Unsafe.As<float, Vector256<float>>(ref MemoryMarshal.GetReference(dest)); ref Unsafe.As<float, Vector256<float>>(ref MemoryMarshal.GetReference(dest));
nint n = (nint)(uint)dest.Length / Vector256<float>.Count; nint n = (nint)(uint)(dest.Length / Vector256<float>.Count);
nint m = Numerics.Modulo4(n); nint m = Numerics.Modulo4(n);
nint u = n - m; nint u = n - m;
@ -391,9 +391,9 @@ internal static partial class SimdUtils
ref Vector128<byte> destBase = ref Vector128<byte> destBase =
ref Unsafe.As<byte, Vector128<byte>>(ref MemoryMarshal.GetReference(dest)); ref Unsafe.As<byte, Vector128<byte>>(ref MemoryMarshal.GetReference(dest));
nint n = (nint)(uint)source.Length / Vector128<byte>.Count; nuint n = (uint)(source.Length / Vector128<byte>.Count);
for (nint i = 0; i < n; i += 3) for (nuint i = 0; i < n; i += 3)
{ {
ref Vector128<byte> vs = ref Unsafe.Add(ref sourceBase, i); ref Vector128<byte> vs = ref Unsafe.Add(ref sourceBase, i);
@ -454,9 +454,9 @@ internal static partial class SimdUtils
ref Vector128<byte> destBase = ref Vector128<byte> destBase =
ref Unsafe.As<byte, Vector128<byte>>(ref MemoryMarshal.GetReference(dest)); ref Unsafe.As<byte, Vector128<byte>>(ref MemoryMarshal.GetReference(dest));
nint n = (nint)(uint)source.Length / Vector128<byte>.Count; nuint n = (uint)(source.Length / Vector128<byte>.Count);
for (nint i = 0, j = 0; i < n; i += 3, j += 4) for (nuint i = 0, j = 0; i < n; i += 3, j += 4)
{ {
ref Vector128<byte> v0 = ref Unsafe.Add(ref sourceBase, i); ref Vector128<byte> v0 = ref Unsafe.Add(ref sourceBase, i);
Vector128<byte> v1 = Unsafe.Add(ref v0, 1); Vector128<byte> v1 = Unsafe.Add(ref v0, 1);
@ -498,9 +498,9 @@ internal static partial class SimdUtils
ref Vector128<byte> destBase = ref Vector128<byte> destBase =
ref Unsafe.As<byte, Vector128<byte>>(ref MemoryMarshal.GetReference(dest)); ref Unsafe.As<byte, Vector128<byte>>(ref MemoryMarshal.GetReference(dest));
nint n = (nint)(uint)source.Length / Vector128<byte>.Count; nuint n = (uint)(source.Length / Vector128<byte>.Count);
for (nint i = 0, j = 0; i < n; i += 4, j += 3) for (nuint i = 0, j = 0; i < n; i += 4, j += 3)
{ {
ref Vector128<byte> vs = ref Unsafe.Add(ref sourceBase, i); ref Vector128<byte> vs = ref Unsafe.Add(ref sourceBase, i);
@ -650,16 +650,16 @@ internal static partial class SimdUtils
{ {
VerifySpanInput(source, dest, Vector256<byte>.Count); VerifySpanInput(source, dest, Vector256<byte>.Count);
nint n = (nint)(uint)dest.Length / Vector256<byte>.Count; nuint n = (uint)(dest.Length / Vector256<byte>.Count);
ref Vector256<float> destBase = ref Vector256<float> destBase =
ref Unsafe.As<float, Vector256<float>>(ref MemoryMarshal.GetReference(dest)); ref Unsafe.As<float, Vector256<float>>(ref MemoryMarshal.GetReference(dest));
var scale = Vector256.Create(1 / (float)byte.MaxValue); var scale = Vector256.Create(1 / (float)byte.MaxValue);
for (nint i = 0; i < n; i++) for (nuint i = 0; i < n; i++)
{ {
nint si = Vector256<byte>.Count * i; nuint si = (uint)Vector256<byte>.Count * i;
Vector256<int> i0 = Avx2.ConvertToVector256Int32(sourceBase + si); Vector256<int> i0 = Avx2.ConvertToVector256Int32(sourceBase + si);
Vector256<int> i1 = Avx2.ConvertToVector256Int32(sourceBase + si + Vector256<int>.Count); Vector256<int> i1 = Avx2.ConvertToVector256Int32(sourceBase + si + Vector256<int>.Count);
Vector256<int> i2 = Avx2.ConvertToVector256Int32(sourceBase + si + (Vector256<int>.Count * 2)); Vector256<int> i2 = Avx2.ConvertToVector256Int32(sourceBase + si + (Vector256<int>.Count * 2));
@ -683,7 +683,7 @@ internal static partial class SimdUtils
// Sse // Sse
VerifySpanInput(source, dest, Vector128<byte>.Count); VerifySpanInput(source, dest, Vector128<byte>.Count);
nint n = (nint)(uint)dest.Length / Vector128<byte>.Count; nuint n = (uint)(dest.Length / Vector128<byte>.Count);
ref Vector128<float> destBase = ref Vector128<float> destBase =
ref Unsafe.As<float, Vector128<float>>(ref MemoryMarshal.GetReference(dest)); ref Unsafe.As<float, Vector128<float>>(ref MemoryMarshal.GetReference(dest));
@ -691,9 +691,9 @@ internal static partial class SimdUtils
var scale = Vector128.Create(1 / (float)byte.MaxValue); var scale = Vector128.Create(1 / (float)byte.MaxValue);
Vector128<byte> zero = Vector128<byte>.Zero; Vector128<byte> zero = Vector128<byte>.Zero;
for (nint i = 0; i < n; i++) for (nuint i = 0; i < n; i++)
{ {
nint si = Vector128<byte>.Count * i; nuint si = (uint)Vector128<byte>.Count * i;
Vector128<int> i0, i1, i2, i3; Vector128<int> i0, i1, i2, i3;
if (Sse41.IsSupported) if (Sse41.IsSupported)
@ -782,7 +782,7 @@ internal static partial class SimdUtils
{ {
VerifySpanInput(source, dest, Vector256<byte>.Count); VerifySpanInput(source, dest, Vector256<byte>.Count);
nint n = (nint)(uint)dest.Length / Vector256<byte>.Count; nuint n = (uint)(dest.Length / Vector256<byte>.Count);
ref Vector256<float> sourceBase = ref Vector256<float> sourceBase =
ref Unsafe.As<float, Vector256<float>>(ref MemoryMarshal.GetReference(source)); ref Unsafe.As<float, Vector256<float>>(ref MemoryMarshal.GetReference(source));
@ -794,7 +794,7 @@ internal static partial class SimdUtils
ref byte maskBase = ref MemoryMarshal.GetReference(PermuteMaskDeinterleave8x32); ref byte maskBase = ref MemoryMarshal.GetReference(PermuteMaskDeinterleave8x32);
Vector256<int> mask = Unsafe.As<byte, Vector256<int>>(ref maskBase); Vector256<int> mask = Unsafe.As<byte, Vector256<int>>(ref maskBase);
for (nint i = 0; i < n; i++) for (nuint i = 0; i < n; i++)
{ {
ref Vector256<float> s = ref Unsafe.Add(ref sourceBase, i * 4); ref Vector256<float> s = ref Unsafe.Add(ref sourceBase, i * 4);
@ -821,7 +821,7 @@ internal static partial class SimdUtils
// Sse // Sse
VerifySpanInput(source, dest, Vector128<byte>.Count); VerifySpanInput(source, dest, Vector128<byte>.Count);
nint n = (nint)(uint)dest.Length / Vector128<byte>.Count; nuint n = (uint)(dest.Length / Vector128<byte>.Count);
ref Vector128<float> sourceBase = ref Vector128<float> sourceBase =
ref Unsafe.As<float, Vector128<float>>(ref MemoryMarshal.GetReference(source)); ref Unsafe.As<float, Vector128<float>>(ref MemoryMarshal.GetReference(source));
@ -831,7 +831,7 @@ internal static partial class SimdUtils
var scale = Vector128.Create((float)byte.MaxValue); var scale = Vector128.Create((float)byte.MaxValue);
for (nint i = 0; i < n; i++) for (nuint i = 0; i < n; i++)
{ {
ref Vector128<float> s = ref Unsafe.Add(ref sourceBase, i * 4); ref Vector128<float> s = ref Unsafe.Add(ref sourceBase, i * 4);
@ -864,7 +864,7 @@ internal static partial class SimdUtils
ref Vector256<byte> bBase = ref Unsafe.As<byte, Vector256<byte>>(ref MemoryMarshal.GetReference(blueChannel)); ref Vector256<byte> bBase = ref Unsafe.As<byte, Vector256<byte>>(ref MemoryMarshal.GetReference(blueChannel));
ref byte dBase = ref Unsafe.As<Rgb24, byte>(ref MemoryMarshal.GetReference(destination)); ref byte dBase = ref Unsafe.As<Rgb24, byte>(ref MemoryMarshal.GetReference(destination));
nint count = (nint)(uint)redChannel.Length / Vector256<byte>.Count; nuint count = (uint)(redChannel.Length / Vector256<byte>.Count);
ref byte control1Bytes = ref MemoryMarshal.GetReference(PermuteMaskEvenOdd8x32); ref byte control1Bytes = ref MemoryMarshal.GetReference(PermuteMaskEvenOdd8x32);
Vector256<uint> control1 = Unsafe.As<byte, Vector256<uint>>(ref control1Bytes); Vector256<uint> control1 = Unsafe.As<byte, Vector256<uint>>(ref control1Bytes);
@ -875,7 +875,7 @@ internal static partial class SimdUtils
Vector256<byte> shuffleAlpha = Unsafe.As<byte, Vector256<byte>>(ref MemoryMarshal.GetReference(ShuffleMaskShiftAlpha)); Vector256<byte> shuffleAlpha = Unsafe.As<byte, Vector256<byte>>(ref MemoryMarshal.GetReference(ShuffleMaskShiftAlpha));
for (nint i = 0; i < count; i++) for (nuint i = 0; i < count; i++)
{ {
Vector256<byte> r0 = Unsafe.Add(ref rBase, i); Vector256<byte> r0 = Unsafe.Add(ref rBase, i);
Vector256<byte> g0 = Unsafe.Add(ref gBase, i); Vector256<byte> g0 = Unsafe.Add(ref gBase, i);
@ -936,12 +936,12 @@ internal static partial class SimdUtils
ref Vector256<byte> bBase = ref Unsafe.As<byte, Vector256<byte>>(ref MemoryMarshal.GetReference(blueChannel)); ref Vector256<byte> bBase = ref Unsafe.As<byte, Vector256<byte>>(ref MemoryMarshal.GetReference(blueChannel));
ref Vector256<byte> dBase = ref Unsafe.As<Rgba32, Vector256<byte>>(ref MemoryMarshal.GetReference(destination)); ref Vector256<byte> dBase = ref Unsafe.As<Rgba32, Vector256<byte>>(ref MemoryMarshal.GetReference(destination));
nint count = (nint)(uint)redChannel.Length / Vector256<byte>.Count; nuint count = (uint)(redChannel.Length / Vector256<byte>.Count);
ref byte control1Bytes = ref MemoryMarshal.GetReference(PermuteMaskEvenOdd8x32); ref byte control1Bytes = ref MemoryMarshal.GetReference(PermuteMaskEvenOdd8x32);
Vector256<uint> control1 = Unsafe.As<byte, Vector256<uint>>(ref control1Bytes); Vector256<uint> control1 = Unsafe.As<byte, Vector256<uint>>(ref control1Bytes);
var a = Vector256.Create((byte)255); var a = Vector256.Create((byte)255);
for (nint i = 0; i < count; i++) for (nuint i = 0; i < count; i++)
{ {
Vector256<byte> r0 = Unsafe.Add(ref rBase, i); Vector256<byte> r0 = Unsafe.Add(ref rBase, i);
Vector256<byte> g0 = Unsafe.Add(ref gBase, i); Vector256<byte> g0 = Unsafe.Add(ref gBase, i);
@ -994,8 +994,8 @@ internal static partial class SimdUtils
Vector256<float> r, g, b; Vector256<float> r, g, b;
const int bytesPerRgbStride = 24; const int bytesPerRgbStride = 24;
int count = (int)((uint)source.Length / 8); nuint count = (uint)source.Length / 8;
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < count; i++)
{ {
rgb = Avx2.PermuteVar8x32(Unsafe.AddByteOffset(ref rgbByteSpan, (uint)(bytesPerRgbStride * i)).AsUInt32(), extractToLanesMask).AsByte(); rgb = Avx2.PermuteVar8x32(Unsafe.AddByteOffset(ref rgbByteSpan, (uint)(bytesPerRgbStride * i)).AsUInt32(), extractToLanesMask).AsByte();
@ -1013,7 +1013,7 @@ internal static partial class SimdUtils
Unsafe.Add(ref destBRef, i) = b; Unsafe.Add(ref destBRef, i) = b;
} }
int sliceCount = count * 8; int sliceCount = (int)(count * 8);
redChannel = redChannel.Slice(sliceCount); redChannel = redChannel.Slice(sliceCount);
greenChannel = greenChannel.Slice(sliceCount); greenChannel = greenChannel.Slice(sliceCount);
blueChannel = blueChannel.Slice(sliceCount); blueChannel = blueChannel.Slice(sliceCount);

14
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 ByteTuple4 b = ref Unsafe.As<byte, ByteTuple4>(ref MemoryMarshal.GetReference(blueChannel));
ref Rgb24 rgb = ref MemoryMarshal.GetReference(destination); ref Rgb24 rgb = ref MemoryMarshal.GetReference(destination);
uint count = (uint)redChannel.Length / 4; nuint count = (uint)redChannel.Length / 4;
for (nint i = 0; i < count; i++) for (nuint i = 0; i < count; i++)
{ {
ref Rgb24 d0 = ref Unsafe.Add(ref rgb, i * 4); ref Rgb24 d0 = ref Unsafe.Add(ref rgb, i * 4);
ref Rgb24 d1 = ref Unsafe.Add(ref d0, 1); ref Rgb24 d1 = ref Unsafe.Add(ref d0, 1);
@ -133,9 +133,9 @@ internal static partial class SimdUtils
ref ByteTuple4 b = ref Unsafe.As<byte, ByteTuple4>(ref MemoryMarshal.GetReference(blueChannel)); ref ByteTuple4 b = ref Unsafe.As<byte, ByteTuple4>(ref MemoryMarshal.GetReference(blueChannel));
ref Rgba32 rgb = ref MemoryMarshal.GetReference(destination); ref Rgba32 rgb = ref MemoryMarshal.GetReference(destination);
uint count = (uint)redChannel.Length / 4; nuint count = (uint)redChannel.Length / 4;
destination.Fill(new Rgba32(0, 0, 0, 255)); destination.Fill(new Rgba32(0, 0, 0, 255));
for (nint i = 0; i < count; i++) for (nuint i = 0; i < count; i++)
{ {
ref Rgba32 d0 = ref Unsafe.Add(ref rgb, i * 4); ref Rgba32 d0 = ref Unsafe.Add(ref rgb, i * 4);
ref Rgba32 d1 = ref Unsafe.Add(ref d0, 1); ref Rgba32 d1 = ref Unsafe.Add(ref d0, 1);
@ -181,7 +181,7 @@ internal static partial class SimdUtils
ref byte b = ref MemoryMarshal.GetReference(blueChannel); ref byte b = ref MemoryMarshal.GetReference(blueChannel);
ref Rgb24 rgb = ref MemoryMarshal.GetReference(destination); ref Rgb24 rgb = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)destination.Length; i++) for (nuint i = 0; i < (uint)destination.Length; i++)
{ {
ref Rgb24 d = ref Unsafe.Add(ref rgb, i); ref Rgb24 d = ref Unsafe.Add(ref rgb, i);
d.R = Unsafe.Add(ref r, 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 byte b = ref MemoryMarshal.GetReference(blueChannel);
ref Rgba32 rgba = ref MemoryMarshal.GetReference(destination); ref Rgba32 rgba = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)destination.Length; i++) for (nuint i = 0; i < (uint)destination.Length; i++)
{ {
ref Rgba32 d = ref Unsafe.Add(ref rgba, i); ref Rgba32 d = ref Unsafe.Add(ref rgba, i);
d.R = Unsafe.Add(ref r, 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 float b = ref MemoryMarshal.GetReference(blueChannel);
ref Rgb24 rgb = ref MemoryMarshal.GetReference(source); ref Rgb24 rgb = ref MemoryMarshal.GetReference(source);
for (nint i = 0; i < (uint)source.Length; i++) for (nuint i = 0; i < (uint)source.Length; i++)
{ {
ref Rgb24 src = ref Unsafe.Add(ref rgb, i); ref Rgb24 src = ref Unsafe.Add(ref rgb, i);
Unsafe.Add(ref r, i) = src.R; Unsafe.Add(ref r, i) = src.R;

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

@ -145,14 +145,14 @@ internal static partial class SimdUtils
{ {
ref float sBase = ref MemoryMarshal.GetReference(source); ref float sBase = ref MemoryMarshal.GetReference(source);
ref float dBase = ref MemoryMarshal.GetReference(dest); ref float dBase = ref MemoryMarshal.GetReference(dest);
Shuffle.InverseMMShuffle(control, out int p3, out int p2, out int p1, out int p0); Shuffle.InverseMMShuffle(control, out uint p3, out uint p2, out uint p1, out uint p0);
for (nint i = 0; i < (uint)source.Length; i += 4) for (nuint i = 0; i < (uint)source.Length; i += 4)
{ {
Unsafe.Add(ref dBase, i + 0) = Unsafe.Add(ref sBase, (nint)(uint)p0 + i); Unsafe.Add(ref dBase, i + 0) = Unsafe.Add(ref sBase, p0 + i);
Unsafe.Add(ref dBase, i + 1) = Unsafe.Add(ref sBase, (nint)(uint)p1 + i); Unsafe.Add(ref dBase, i + 1) = Unsafe.Add(ref sBase, p1 + i);
Unsafe.Add(ref dBase, i + 2) = Unsafe.Add(ref sBase, (nint)(uint)p2 + i); Unsafe.Add(ref dBase, i + 2) = Unsafe.Add(ref sBase, p2 + i);
Unsafe.Add(ref dBase, i + 3) = Unsafe.Add(ref sBase, (nint)(uint)p3 + i); Unsafe.Add(ref dBase, i + 3) = Unsafe.Add(ref sBase, p3 + i);
} }
} }
@ -492,34 +492,34 @@ internal static partial class SimdUtils
{ {
InverseMMShuffle( InverseMMShuffle(
control, control,
out int p3, out uint p3,
out int p2, out uint p2,
out int p1, out uint p1,
out int p0); out uint p0);
ref byte spanBase = ref MemoryMarshal.GetReference(span); ref byte spanBase = ref MemoryMarshal.GetReference(span);
for (int i = 0; i < span.Length; i += 4) for (nuint i = 0; i < (uint)span.Length; i += 4)
{ {
Unsafe.Add(ref spanBase, (uint)(i + 0)) = (byte)(p0 + i); Unsafe.Add(ref spanBase, i + 0) = (byte)(p0 + i);
Unsafe.Add(ref spanBase, (uint)(i + 1)) = (byte)(p1 + i); Unsafe.Add(ref spanBase, i + 1) = (byte)(p1 + i);
Unsafe.Add(ref spanBase, (uint)(i + 2)) = (byte)(p2 + i); Unsafe.Add(ref spanBase, i + 2) = (byte)(p2 + i);
Unsafe.Add(ref spanBase, (uint)(i + 3)) = (byte)(p3 + i); Unsafe.Add(ref spanBase, i + 3) = (byte)(p3 + i);
} }
} }
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
public static void InverseMMShuffle( public static void InverseMMShuffle(
byte control, byte control,
out int p3, out uint p3,
out int p2, out uint p2,
out int p1, out uint p1,
out int p0) out uint p0)
{ {
p3 = (control >> 6) & 0x3; p3 = (uint)((control >> 6) & 0x3);
p2 = (control >> 4) & 0x3; p2 = (uint)((control >> 4) & 0x3);
p1 = (control >> 2) & 0x3; p1 = (uint)((control >> 2) & 0x3);
p0 = (control >> 0) & 0x3; p0 = (uint)((control >> 0) & 0x3);
} }
} }
} }

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

@ -286,13 +286,13 @@ internal sealed unsafe class DeflaterHuffman : IDisposable
int static_len = this.extraBits; int static_len = this.extraBits;
ref byte staticLLengthRef = ref MemoryMarshal.GetReference(StaticLLength); ref byte staticLLengthRef = ref MemoryMarshal.GetReference(StaticLLength);
for (nint i = 0; i < LiteralNumber; i++) for (nuint i = 0; i < LiteralNumber; i++)
{ {
static_len += this.literalTree.Frequencies[i] * Unsafe.Add(ref staticLLengthRef, i); static_len += this.literalTree.Frequencies[i] * Unsafe.Add(ref staticLLengthRef, i);
} }
ref byte staticDLengthRef = ref MemoryMarshal.GetReference(StaticDLength); ref byte staticDLengthRef = ref MemoryMarshal.GetReference(StaticDLength);
for (nint i = 0; i < DistanceNumber; i++) for (nuint i = 0; i < DistanceNumber; i++)
{ {
static_len += this.distTree.Frequencies[i] * Unsafe.Add(ref staticDLengthRef, i); static_len += this.distTree.Frequencies[i] * Unsafe.Add(ref staticDLengthRef, i);
} }
@ -625,10 +625,10 @@ internal sealed unsafe class DeflaterHuffman : IDisposable
ref int valuesRef = ref MemoryMarshal.GetReference(valuesMemoryOwner.Memory.Span); ref int valuesRef = ref MemoryMarshal.GetReference(valuesMemoryOwner.Memory.Span);
int numNodes = numLeafs; int numNodes = numLeafs;
for (nint i = 0; i < (uint)heapLen; i++) for (nuint i = 0; i < (uint)heapLen; i++)
{ {
int node = Unsafe.Add(ref heapRef, i); int node = Unsafe.Add(ref heapRef, i);
nint i2 = 2 * i; nuint i2 = 2 * i;
Unsafe.Add(ref childrenRef, i2) = node; Unsafe.Add(ref childrenRef, i2) = node;
Unsafe.Add(ref childrenRef, i2 + 1) = -1; Unsafe.Add(ref childrenRef, i2 + 1) = -1;
Unsafe.Add(ref valuesRef, i) = this.Frequencies[node] << 8; Unsafe.Add(ref valuesRef, i) = this.Frequencies[node] << 8;

8
src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs

@ -123,8 +123,8 @@ internal sealed class BmpEncoderCore : IImageEncoderInternals
BmpMetadata bmpMetadata = metadata.GetBmpMetadata(); BmpMetadata bmpMetadata = metadata.GetBmpMetadata();
this.bitsPerPixel ??= bmpMetadata.BitsPerPixel; this.bitsPerPixel ??= bmpMetadata.BitsPerPixel;
short bpp = (short)this.bitsPerPixel; ushort bpp = (ushort)this.bitsPerPixel;
int bytesPerLine = (int)(4 * ((((uint)image.Width * (ushort)bpp) + 31) / 32)); int bytesPerLine = (int)(4 * ((((uint)image.Width * bpp) + 31) / 32));
this.padding = bytesPerLine - (int)(image.Width * (bpp / 8F)); this.padding = bytesPerLine - (int)(image.Width * (bpp / 8F));
int colorPaletteSize = this.bitsPerPixel switch int colorPaletteSize = this.bitsPerPixel switch
@ -176,7 +176,7 @@ internal sealed class BmpEncoderCore : IImageEncoderInternals
/// <param name="metadata">The metadata.</param> /// <param name="metadata">The metadata.</param>
/// <param name="iccProfileData">The icc profile data.</param> /// <param name="iccProfileData">The icc profile data.</param>
/// <returns>The bitmap information header.</returns> /// <returns>The bitmap information header.</returns>
private BmpInfoHeader CreateBmpInfoHeader(int width, int height, int infoHeaderSize, short bpp, int bytesPerLine, ImageMetadata metadata, byte[]? iccProfileData) private BmpInfoHeader CreateBmpInfoHeader(int width, int height, int infoHeaderSize, ushort bpp, int bytesPerLine, ImageMetadata metadata, byte[]? iccProfileData)
{ {
int hResolution = 0; int hResolution = 0;
int vResolution = 0; int vResolution = 0;
@ -212,7 +212,7 @@ internal sealed class BmpEncoderCore : IImageEncoderInternals
width: width, width: width,
height: height, height: height,
planes: 1, planes: 1,
bitsPerPixel: bpp, bitsPerPixel: (short)bpp,
imageSize: height * bytesPerLine, imageSize: height * bytesPerLine,
xPelsPerMeter: hResolution, xPelsPerMeter: hResolution,
yPelsPerMeter: vResolution, yPelsPerMeter: vResolution,

8
src/ImageSharp/Formats/ImageExtensions.Save.tt

@ -77,7 +77,7 @@ public static partial class ImageExtensions
public static void SaveAs<#= fmt #>(this Image source, string path, <#= fmt #>Encoder encoder) => public static void SaveAs<#= fmt #>(this Image source, string path, <#= fmt #>Encoder encoder) =>
source.Save( source.Save(
path, path,
encoder ?? source.GetConfiguration().ImageFormatsManager.FindEncoder(<#= fmt #>Format.Instance)); encoder ?? source.GetConfiguration().ImageFormatsManager.GetEncoder(<#= fmt #>Format.Instance));
/// <summary> /// <summary>
/// Saves the image to the given stream with the <#= fmt #> format. /// Saves the image to the given stream with the <#= fmt #> format.
@ -91,7 +91,7 @@ public static partial class ImageExtensions
public static Task SaveAs<#= fmt #>Async(this Image source, string path, <#= fmt #>Encoder encoder, CancellationToken cancellationToken = default) public static Task SaveAs<#= fmt #>Async(this Image source, string path, <#= fmt #>Encoder encoder, CancellationToken cancellationToken = default)
=> source.SaveAsync( => source.SaveAsync(
path, path,
encoder ?? source.GetConfiguration().ImageFormatsManager.FindEncoder(<#= fmt #>Format.Instance), encoder ?? source.GetConfiguration().ImageFormatsManager.GetEncoder(<#= fmt #>Format.Instance),
cancellationToken); cancellationToken);
/// <summary> /// <summary>
@ -124,7 +124,7 @@ public static partial class ImageExtensions
public static void SaveAs<#= fmt #>(this Image source, Stream stream, <#= fmt #>Encoder encoder) public static void SaveAs<#= fmt #>(this Image source, Stream stream, <#= fmt #>Encoder encoder)
=> source.Save( => source.Save(
stream, stream,
encoder ?? source.GetConfiguration().ImageFormatsManager.FindEncoder(<#= fmt #>Format.Instance)); encoder ?? source.GetConfiguration().ImageFormatsManager.GetEncoder(<#= fmt #>Format.Instance));
/// <summary> /// <summary>
/// Saves the image to the given stream with the <#= fmt #> format. /// Saves the image to the given stream with the <#= fmt #> format.
@ -138,7 +138,7 @@ public static partial class ImageExtensions
public static Task SaveAs<#= fmt #>Async(this Image source, Stream stream, <#= fmt #>Encoder encoder, CancellationToken cancellationToken = default) public static Task SaveAs<#= fmt #>Async(this Image source, Stream stream, <#= fmt #>Encoder encoder, CancellationToken cancellationToken = default)
=> source.SaveAsync( => source.SaveAsync(
stream, stream,
encoder ?? source.GetConfiguration().ImageFormatsManager.FindEncoder(<#= fmt #>Format.Instance), encoder ?? source.GetConfiguration().ImageFormatsManager.GetEncoder(<#= fmt #>Format.Instance),
cancellationToken); cancellationToken);
<# <#

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

@ -16,7 +16,7 @@ internal partial struct Block8x8F
{ {
var CMin4 = new Vector4(0F); var CMin4 = new Vector4(0F);
var CMax4 = new Vector4(maximum); var CMax4 = new Vector4(maximum);
var COff4 = new Vector4(MathF.Ceiling(maximum * 0.5F)); // /2 var COff4 = new Vector4(MathF.Ceiling(maximum * 0.5F));
this.V0L = Numerics.Clamp(this.V0L + COff4, CMin4, CMax4); this.V0L = Numerics.Clamp(this.V0L + COff4, CMin4, CMax4);
this.V0R = Numerics.Clamp(this.V0R + COff4, CMin4, CMax4); this.V0R = Numerics.Clamp(this.V0R + COff4, CMin4, CMax4);
@ -42,7 +42,7 @@ internal partial struct Block8x8F
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
public void NormalizeColorsAndRoundInPlaceVector8(float maximum) public void NormalizeColorsAndRoundInPlaceVector8(float maximum)
{ {
var off = new Vector<float>(MathF.Ceiling(maximum * 0.5F)); // /2 var off = new Vector<float>(MathF.Ceiling(maximum * 0.5F));
var max = new Vector<float>(maximum); var max = new Vector<float>(maximum);
ref Vector<float> row0 = ref Unsafe.As<Vector4, Vector<float>>(ref this.V0L); ref Vector<float> row0 = ref Unsafe.As<Vector4, Vector<float>>(ref this.V0L);

4
src/ImageSharp/Formats/Jpeg/Components/Block8x8F.Generated.tt

@ -29,7 +29,7 @@ internal partial struct Block8x8F
{ {
var CMin4 = new Vector4(0F); var CMin4 = new Vector4(0F);
var CMax4 = new Vector4(maximum); var CMax4 = new Vector4(maximum);
var COff4 = new Vector4(MathF.Ceiling(maximum * 0.5F)); // /2 var COff4 = new Vector4(MathF.Ceiling(maximum * 0.5F));
<# <#
@ -53,7 +53,7 @@ internal partial struct Block8x8F
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
public void NormalizeColorsAndRoundInPlaceVector8(float maximum) public void NormalizeColorsAndRoundInPlaceVector8(float maximum)
{ {
var off = new Vector<float>(MathF.Ceiling(maximum * 0.5F)); // /2 var off = new Vector<float>(MathF.Ceiling(maximum * 0.5F));
var max = new Vector<float>(maximum); var max = new Vector<float>(maximum);
<# <#

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

@ -41,9 +41,9 @@ internal partial struct Block8x8F
ref Vector256<float> bBase = ref b.V0; ref Vector256<float> bBase = ref b.V0;
ref Vector256<short> destRef = ref dest.V01; ref Vector256<short> destRef = ref dest.V01;
var multiplyIntoInt16ShuffleMask = Vector256.Create(0, 1, 4, 5, 2, 3, 6, 7); Vector256<int> multiplyIntoInt16ShuffleMask = Vector256.Create(0, 1, 4, 5, 2, 3, 6, 7);
for (nint i = 0; i < 8; i += 2) for (nuint i = 0; i < 8; i += 2)
{ {
Vector256<int> row0 = Avx.ConvertToVector256Int32(Avx.Multiply(Unsafe.Add(ref aBase, i + 0), Unsafe.Add(ref bBase, i + 0))); Vector256<int> row0 = Avx.ConvertToVector256Int32(Avx.Multiply(Unsafe.Add(ref aBase, i + 0), Unsafe.Add(ref bBase, i + 0)));
Vector256<int> row1 = Avx.ConvertToVector256Int32(Avx.Multiply(Unsafe.Add(ref aBase, i + 1), Unsafe.Add(ref bBase, i + 1))); Vector256<int> row1 = Avx.ConvertToVector256Int32(Avx.Multiply(Unsafe.Add(ref aBase, i + 1), Unsafe.Add(ref bBase, i + 1)));
@ -64,7 +64,7 @@ internal partial struct Block8x8F
ref Vector128<short> destBase = ref Unsafe.As<Block8x8, Vector128<short>>(ref dest); ref Vector128<short> destBase = ref Unsafe.As<Block8x8, Vector128<short>>(ref dest);
for (nint i = 0; i < 16; i += 2) for (nuint 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> 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<int> right = Sse2.ConvertToVector128Int32(Sse.Multiply(Unsafe.Add(ref aBase, i + 1), Unsafe.Add(ref bBase, i + 1)));

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

@ -30,13 +30,13 @@ internal partial struct Block8x8F
} }
// TODO: Optimize: implement all cases with scale-specific, loopless code! // TODO: Optimize: implement all cases with scale-specific, loopless code!
this.CopyArbitraryScale(ref areaOrigin, areaStride, horizontalScale, verticalScale); this.CopyArbitraryScale(ref areaOrigin, (uint)areaStride, (uint)horizontalScale, (uint)verticalScale);
} }
private void CopyTo2x2Scale(ref float areaOrigin, int areaStride) private void CopyTo2x2Scale(ref float areaOrigin, int areaStride)
{ {
ref Vector2 destBase = ref Unsafe.As<float, Vector2>(ref areaOrigin); ref Vector2 destBase = ref Unsafe.As<float, Vector2>(ref areaOrigin);
int destStride = (int)((uint)areaStride / 2); nuint destStride = (uint)areaStride / 2;
WidenCopyRowImpl2x2(ref this.V0L, ref destBase, 0, destStride); WidenCopyRowImpl2x2(ref this.V0L, ref destBase, 0, destStride);
WidenCopyRowImpl2x2(ref this.V0L, ref destBase, 1, destStride); WidenCopyRowImpl2x2(ref this.V0L, ref destBase, 1, destStride);
@ -48,12 +48,12 @@ internal partial struct Block8x8F
WidenCopyRowImpl2x2(ref this.V0L, ref destBase, 7, destStride); WidenCopyRowImpl2x2(ref this.V0L, ref destBase, 7, destStride);
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
static void WidenCopyRowImpl2x2(ref Vector4 selfBase, ref Vector2 destBase, nint row, nint destStride) static void WidenCopyRowImpl2x2(ref Vector4 selfBase, ref Vector2 destBase, nuint row, nuint destStride)
{ {
ref Vector4 sLeft = ref Unsafe.Add(ref selfBase, 2 * row); ref Vector4 sLeft = ref Unsafe.Add(ref selfBase, 2 * row);
ref Vector4 sRight = ref Unsafe.Add(ref sLeft, 1); ref Vector4 sRight = ref Unsafe.Add(ref sLeft, 1);
nint offset = 2 * row * destStride; nuint offset = 2 * row * destStride;
ref Vector4 dTopLeft = ref Unsafe.As<Vector2, Vector4>(ref Unsafe.Add(ref destBase, offset)); ref Vector4 dTopLeft = ref Unsafe.As<Vector2, Vector4>(ref Unsafe.Add(ref destBase, offset));
ref Vector4 dBottomLeft = ref Unsafe.As<Vector2, Vector4>(ref Unsafe.Add(ref destBase, offset + destStride)); ref Vector4 dBottomLeft = ref Unsafe.As<Vector2, Vector4>(ref Unsafe.Add(ref destBase, offset + destStride));
@ -86,23 +86,23 @@ internal partial struct Block8x8F
} }
[MethodImpl(InliningOptions.ColdPath)] [MethodImpl(InliningOptions.ColdPath)]
private void CopyArbitraryScale(ref float areaOrigin, int areaStride, int horizontalScale, int verticalScale) private void CopyArbitraryScale(ref float areaOrigin, uint areaStride, uint horizontalScale, uint verticalScale)
{ {
for (int y = 0; y < 8; y++) for (nuint y = 0; y < 8; y++)
{ {
int yy = y * verticalScale; nuint yy = y * verticalScale;
int y8 = y * 8; nuint y8 = y * 8;
for (int x = 0; x < 8; x++) for (nuint x = 0; x < 8; x++)
{ {
int xx = x * horizontalScale; nuint xx = x * horizontalScale;
float value = this[y8 + x]; float value = this[(int)(y8 + x)];
nint baseIdx = (nint)(uint)((yy * areaStride) + xx); nuint baseIdx = (uint)((yy * areaStride) + xx);
for (nint i = 0; i < verticalScale; i++, baseIdx += areaStride) for (nuint i = 0; i < verticalScale; i++, baseIdx += areaStride)
{ {
for (nint j = 0; j < (uint)horizontalScale; j++) for (nuint j = 0; j < horizontalScale; j++)
{ {
// area[xx + j, yy + i] = value; // area[xx + j, yy + i] = value;
Unsafe.Add(ref areaOrigin, baseIdx + j) = value; Unsafe.Add(ref areaOrigin, baseIdx + j) = value;

22
src/ImageSharp/Formats/Jpeg/Components/Block8x8F.cs

@ -71,28 +71,34 @@ internal partial struct Block8x8F : IEquatable<Block8x8F>
/// <param name="idx">The index</param> /// <param name="idx">The index</param>
/// <returns>The float value at the specified index</returns> /// <returns>The float value at the specified index</returns>
public float this[int idx] public float this[int idx]
{
get => this[(uint)idx];
set => this[(uint)idx] = value;
}
internal float this[nuint idx]
{ {
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
get get
{ {
DebugGuard.MustBeBetweenOrEqualTo(idx, 0, Size - 1, nameof(idx)); DebugGuard.MustBeBetweenOrEqualTo((int)idx, 0, Size - 1, nameof(idx));
ref float selfRef = ref Unsafe.As<Block8x8F, float>(ref this); ref float selfRef = ref Unsafe.As<Block8x8F, float>(ref this);
return Unsafe.Add(ref selfRef, (nint)(uint)idx); return Unsafe.Add(ref selfRef, idx);
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
set set
{ {
DebugGuard.MustBeBetweenOrEqualTo(idx, 0, Size - 1, nameof(idx)); DebugGuard.MustBeBetweenOrEqualTo((int)idx, 0, Size - 1, nameof(idx));
ref float selfRef = ref Unsafe.As<Block8x8F, float>(ref this); ref float selfRef = ref Unsafe.As<Block8x8F, float>(ref this);
Unsafe.Add(ref selfRef, (nint)(uint)idx) = value; Unsafe.Add(ref selfRef, idx) = value;
} }
} }
public float this[int x, int y] public float this[int x, int y]
{ {
get => this[(y * 8) + x]; get => this[((uint)y * 8) + (uint)x];
set => this[(y * 8) + x] = value; set => this[((uint)y * 8) + (uint)x] = value;
} }
public static Block8x8F Load(Span<float> data) public static Block8x8F Load(Span<float> data)
@ -425,7 +431,7 @@ internal partial struct Block8x8F : IEquatable<Block8x8F>
Vector256<int> targetVector = Vector256.Create(value); Vector256<int> targetVector = Vector256.Create(value);
ref Vector256<float> blockStride = ref this.V0; ref Vector256<float> blockStride = ref this.V0;
for (nint i = 0; i < RowCount; i++) for (nuint i = 0; i < RowCount; i++)
{ {
Vector256<int> areEqual = Avx2.CompareEqual(Avx.ConvertToVector256Int32WithTruncation(Unsafe.Add(ref this.V0, i)), targetVector); Vector256<int> areEqual = Avx2.CompareEqual(Avx.ConvertToVector256Int32WithTruncation(Unsafe.Add(ref this.V0, i)), targetVector);
if (Avx2.MoveMask(areEqual.AsByte()) != equalityMask) if (Avx2.MoveMask(areEqual.AsByte()) != equalityMask)
@ -439,7 +445,7 @@ internal partial struct Block8x8F : IEquatable<Block8x8F>
ref float scalars = ref Unsafe.As<Block8x8F, float>(ref this); ref float scalars = ref Unsafe.As<Block8x8F, float>(ref this);
for (nint i = 0; i < Size; i++) for (nuint i = 0; i < Size; i++)
{ {
if ((int)Unsafe.Add(ref scalars, i) != value) if ((int)Unsafe.Add(ref scalars, i) != value)
{ {

8
src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.CmykAvx.cs

@ -32,8 +32,8 @@ internal abstract partial class JpegColorConverterBase
// Used for the color conversion // Used for the color conversion
var scale = Vector256.Create(1 / (this.MaximumValue * this.MaximumValue)); var scale = Vector256.Create(1 / (this.MaximumValue * this.MaximumValue));
nint n = (nint)(uint)values.Component0.Length / Vector256<float>.Count; nuint n = (uint)(values.Component0.Length / Vector256<float>.Count);
for (nint i = 0; i < n; i++) for (nuint i = 0; i < n; i++)
{ {
ref Vector256<float> c = ref Unsafe.Add(ref c0Base, i); ref Vector256<float> c = ref Unsafe.Add(ref c0Base, i);
ref Vector256<float> m = ref Unsafe.Add(ref c1Base, i); ref Vector256<float> m = ref Unsafe.Add(ref c1Base, i);
@ -71,8 +71,8 @@ internal abstract partial class JpegColorConverterBase
var scale = Vector256.Create(maxValue); var scale = Vector256.Create(maxValue);
nint n = (nint)(uint)values.Component0.Length / Vector256<float>.Count; nuint n = (uint)(values.Component0.Length / Vector256<float>.Count);
for (nint i = 0; i < n; i++) for (nuint i = 0; i < n; i++)
{ {
Vector256<float> ctmp = Avx.Subtract(scale, Unsafe.Add(ref srcR, i)); Vector256<float> ctmp = Avx.Subtract(scale, Unsafe.Add(ref srcR, i));
Vector256<float> mtmp = Avx.Subtract(scale, Unsafe.Add(ref srcG, i)); Vector256<float> mtmp = Avx.Subtract(scale, Unsafe.Add(ref srcG, i));

8
src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.CmykVector.cs

@ -30,8 +30,8 @@ internal abstract partial class JpegColorConverterBase
var scale = new Vector<float>(1 / (this.MaximumValue * this.MaximumValue)); var scale = new Vector<float>(1 / (this.MaximumValue * this.MaximumValue));
nint n = (nint)(uint)values.Component0.Length / Vector<float>.Count; nuint n = (uint)(values.Component0.Length / Vector<float>.Count);
for (nint i = 0; i < n; i++) for (nuint i = 0; i < n; i++)
{ {
ref Vector<float> c = ref Unsafe.Add(ref cBase, i); ref Vector<float> c = ref Unsafe.Add(ref cBase, i);
ref Vector<float> m = ref Unsafe.Add(ref mBase, i); ref Vector<float> m = ref Unsafe.Add(ref mBase, i);
@ -78,8 +78,8 @@ internal abstract partial class JpegColorConverterBase
// Used for the color conversion // Used for the color conversion
var scale = new Vector<float>(maxValue); var scale = new Vector<float>(maxValue);
nint n = (nint)(uint)values.Component0.Length / Vector<float>.Count; nuint n = (uint)(values.Component0.Length / Vector<float>.Count);
for (nint i = 0; i < n; i++) for (nuint i = 0; i < n; i++)
{ {
Vector<float> ctmp = scale - Unsafe.Add(ref srcR, i); Vector<float> ctmp = scale - Unsafe.Add(ref srcR, i);
Vector<float> mtmp = scale - Unsafe.Add(ref srcG, i); Vector<float> mtmp = scale - Unsafe.Add(ref srcG, i);

8
src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.GrayScaleAvx.cs

@ -27,8 +27,8 @@ internal abstract partial class JpegColorConverterBase
// Used for the color conversion // Used for the color conversion
var scale = Vector256.Create(1 / this.MaximumValue); var scale = Vector256.Create(1 / this.MaximumValue);
nint n = (nint)(uint)values.Component0.Length / Vector256<float>.Count; nuint n = (uint)(values.Component0.Length / Vector256<float>.Count);
for (nint i = 0; i < n; i++) for (nuint i = 0; i < n; i++)
{ {
ref Vector256<float> c0 = ref Unsafe.Add(ref c0Base, i); ref Vector256<float> c0 = ref Unsafe.Add(ref c0Base, i);
c0 = Avx.Multiply(c0, scale); c0 = Avx.Multiply(c0, scale);
@ -53,8 +53,8 @@ internal abstract partial class JpegColorConverterBase
var f0587 = Vector256.Create(0.587f); var f0587 = Vector256.Create(0.587f);
var f0114 = Vector256.Create(0.114f); var f0114 = Vector256.Create(0.114f);
nint n = (nint)(uint)values.Component0.Length / Vector256<float>.Count; nuint n = (uint)(values.Component0.Length / Vector256<float>.Count);
for (nint i = 0; i < n; i++) for (nuint i = 0; i < n; i++)
{ {
ref Vector256<float> r = ref Unsafe.Add(ref srcRed, i); ref Vector256<float> r = ref Unsafe.Add(ref srcRed, i);
ref Vector256<float> g = ref Unsafe.Add(ref srcGreen, i); ref Vector256<float> g = ref Unsafe.Add(ref srcGreen, i);

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); ref float valuesRef = ref MemoryMarshal.GetReference(values);
float scale = 1 / maxValue; float scale = 1 / maxValue;
for (nint i = 0; i < (uint)values.Length; i++) for (nuint i = 0; i < (uint)values.Length; i++)
{ {
Unsafe.Add(ref valuesRef, i) *= scale; Unsafe.Add(ref valuesRef, i) *= scale;
} }

8
src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.GrayScaleVector.cs

@ -24,8 +24,8 @@ internal abstract partial class JpegColorConverterBase
var scale = new Vector<float>(1 / this.MaximumValue); var scale = new Vector<float>(1 / this.MaximumValue);
nint n = (nint)(uint)values.Component0.Length / Vector<float>.Count; nuint n = (uint)(values.Component0.Length / Vector<float>.Count);
for (nint i = 0; i < n; i++) for (nuint i = 0; i < n; i++)
{ {
ref Vector<float> c0 = ref Unsafe.Add(ref cBase, i); ref Vector<float> c0 = ref Unsafe.Add(ref cBase, i);
c0 *= scale; c0 *= scale;
@ -53,8 +53,8 @@ internal abstract partial class JpegColorConverterBase
var gMult = new Vector<float>(0.587f); var gMult = new Vector<float>(0.587f);
var bMult = new Vector<float>(0.114f); var bMult = new Vector<float>(0.114f);
nint n = (nint)(uint)values.Component0.Length / Vector<float>.Count; nuint n = (uint)(values.Component0.Length / Vector<float>.Count);
for (nint i = 0; i < n; i++) for (nuint i = 0; i < n; i++)
{ {
Vector<float> r = Unsafe.Add(ref srcR, i); Vector<float> r = Unsafe.Add(ref srcR, i);
Vector<float> g = Unsafe.Add(ref srcR, i); Vector<float> g = Unsafe.Add(ref srcR, i);

4
src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.RgbArm.cs

@ -30,8 +30,8 @@ internal abstract partial class JpegColorConverterBase
// Used for the color conversion // Used for the color conversion
var scale = Vector128.Create(1 / this.MaximumValue); var scale = Vector128.Create(1 / this.MaximumValue);
nint n = (nint)(uint)values.Component0.Length / Vector128<float>.Count; nuint n = (uint)(values.Component0.Length / Vector128<float>.Count);
for (nint i = 0; i < n; i++) for (nuint i = 0; i < n; i++)
{ {
ref Vector128<float> r = ref Unsafe.Add(ref rBase, i); ref Vector128<float> r = ref Unsafe.Add(ref rBase, i);
ref Vector128<float> g = ref Unsafe.Add(ref gBase, i); ref Vector128<float> g = ref Unsafe.Add(ref gBase, i);

4
src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.RgbAvx.cs

@ -29,8 +29,8 @@ internal abstract partial class JpegColorConverterBase
// Used for the color conversion // Used for the color conversion
var scale = Vector256.Create(1 / this.MaximumValue); var scale = Vector256.Create(1 / this.MaximumValue);
nint n = (nint)(uint)values.Component0.Length / Vector256<float>.Count; nuint n = (uint)(values.Component0.Length / Vector256<float>.Count);
for (nint i = 0; i < n; i++) for (nuint i = 0; i < n; i++)
{ {
ref Vector256<float> r = ref Unsafe.Add(ref rBase, i); ref Vector256<float> r = ref Unsafe.Add(ref rBase, i);
ref Vector256<float> g = ref Unsafe.Add(ref gBase, i); ref Vector256<float> g = ref Unsafe.Add(ref gBase, i);

4
src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.RgbVector.cs

@ -28,8 +28,8 @@ internal abstract partial class JpegColorConverterBase
var scale = new Vector<float>(1 / this.MaximumValue); var scale = new Vector<float>(1 / this.MaximumValue);
nint n = (nint)(uint)values.Component0.Length / Vector<float>.Count; nuint n = (uint)(values.Component0.Length / Vector<float>.Count);
for (nint i = 0; i < n; i++) for (nuint i = 0; i < n; i++)
{ {
ref Vector<float> r = ref Unsafe.Add(ref rBase, i); ref Vector<float> r = ref Unsafe.Add(ref rBase, i);
ref Vector<float> g = ref Unsafe.Add(ref gBase, i); ref Vector<float> g = ref Unsafe.Add(ref gBase, i);

8
src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YCbCrAvx.cs

@ -38,8 +38,8 @@ internal abstract partial class JpegColorConverterBase
var bCbMult = Vector256.Create(YCbCrScalar.BCbMult); var bCbMult = Vector256.Create(YCbCrScalar.BCbMult);
// Walking 8 elements at one step: // Walking 8 elements at one step:
nint n = (nint)(uint)values.Component0.Length / Vector256<float>.Count; nuint n = (uint)(values.Component0.Length / Vector256<float>.Count);
for (nint i = 0; i < n; i++) for (nuint i = 0; i < n; i++)
{ {
// y = yVals[i]; // y = yVals[i];
// cb = cbVals[i] - 128F; // cb = cbVals[i] - 128F;
@ -98,8 +98,8 @@ internal abstract partial class JpegColorConverterBase
var fn0081312F = Vector256.Create(-0.081312F); var fn0081312F = Vector256.Create(-0.081312F);
var f05 = Vector256.Create(0.5f); var f05 = Vector256.Create(0.5f);
nint n = (nint)(uint)values.Component0.Length / Vector256<float>.Count; nuint n = (uint)(values.Component0.Length / Vector256<float>.Count);
for (nint i = 0; i < n; i++) for (nuint i = 0; i < n; i++)
{ {
Vector256<float> r = Unsafe.Add(ref srcR, i); Vector256<float> r = Unsafe.Add(ref srcR, i);
Vector256<float> g = Unsafe.Add(ref srcG, i); Vector256<float> g = Unsafe.Add(ref srcG, i);

8
src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YCbCrVector.cs

@ -35,8 +35,8 @@ internal abstract partial class JpegColorConverterBase
var gCrMult = new Vector<float>(-YCbCrScalar.GCrMult); var gCrMult = new Vector<float>(-YCbCrScalar.GCrMult);
var bCbMult = new Vector<float>(YCbCrScalar.BCbMult); var bCbMult = new Vector<float>(YCbCrScalar.BCbMult);
nint n = (nint)(uint)values.Component0.Length / Vector<float>.Count; nuint n = (uint)(values.Component0.Length / Vector<float>.Count);
for (nint i = 0; i < n; i++) for (nuint i = 0; i < n; i++)
{ {
// y = yVals[i]; // y = yVals[i];
// cb = cbVals[i] - 128F; // cb = cbVals[i] - 128F;
@ -103,8 +103,8 @@ internal abstract partial class JpegColorConverterBase
var gCrMult = new Vector<float>(0.418688f); var gCrMult = new Vector<float>(0.418688f);
var bCrMult = new Vector<float>(0.081312f); var bCrMult = new Vector<float>(0.081312f);
nint n = (nint)(uint)values.Component0.Length / Vector<float>.Count; nuint n = (uint)(values.Component0.Length / Vector<float>.Count);
for (nint i = 0; i < n; i++) for (nuint i = 0; i < n; i++)
{ {
Vector<float> r = Unsafe.Add(ref srcR, i); Vector<float> r = Unsafe.Add(ref srcR, i);
Vector<float> g = Unsafe.Add(ref srcG, i); Vector<float> g = Unsafe.Add(ref srcG, i);

8
src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YccKAvx.cs

@ -40,8 +40,8 @@ internal abstract partial class JpegColorConverterBase
var bCbMult = Vector256.Create(YCbCrScalar.BCbMult); var bCbMult = Vector256.Create(YCbCrScalar.BCbMult);
// Walking 8 elements at one step: // Walking 8 elements at one step:
nint n = (nint)(uint)values.Component0.Length / Vector256<float>.Count; nuint n = (uint)(values.Component0.Length / Vector256<float>.Count);
for (nint i = 0; i < n; i++) for (nuint i = 0; i < n; i++)
{ {
// y = yVals[i]; // y = yVals[i];
// cb = cbVals[i] - 128F; // cb = cbVals[i] - 128F;
@ -109,8 +109,8 @@ internal abstract partial class JpegColorConverterBase
var fn0081312F = Vector256.Create(-0.081312F); var fn0081312F = Vector256.Create(-0.081312F);
var f05 = Vector256.Create(0.5f); var f05 = Vector256.Create(0.5f);
nint n = (nint)(uint)values.Component0.Length / Vector256<float>.Count; nuint n = (uint)(values.Component0.Length / Vector256<float>.Count);
for (nint i = 0; i < n; i++) for (nuint i = 0; i < n; i++)
{ {
Vector256<float> r = Avx.Subtract(maxSampleValue, Unsafe.Add(ref srcR, i)); Vector256<float> r = Avx.Subtract(maxSampleValue, Unsafe.Add(ref srcR, i));
Vector256<float> g = Avx.Subtract(maxSampleValue, Unsafe.Add(ref srcG, i)); Vector256<float> g = Avx.Subtract(maxSampleValue, Unsafe.Add(ref srcG, i));

8
src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YccKVector.cs

@ -36,8 +36,8 @@ internal abstract partial class JpegColorConverterBase
var gCrMult = new Vector<float>(-YCbCrScalar.GCrMult); var gCrMult = new Vector<float>(-YCbCrScalar.GCrMult);
var bCbMult = new Vector<float>(YCbCrScalar.BCbMult); var bCbMult = new Vector<float>(YCbCrScalar.BCbMult);
nint n = (nint)(uint)values.Component0.Length / Vector<float>.Count; nuint n = (uint)(values.Component0.Length / Vector<float>.Count);
for (nint i = 0; i < n; i++) for (nuint i = 0; i < n; i++)
{ {
// y = yVals[i]; // y = yVals[i];
// cb = cbVals[i] - 128F; // cb = cbVals[i] - 128F;
@ -107,8 +107,8 @@ internal abstract partial class JpegColorConverterBase
var gCrMult = new Vector<float>(0.418688f); var gCrMult = new Vector<float>(0.418688f);
var bCrMult = new Vector<float>(0.081312f); var bCrMult = new Vector<float>(0.081312f);
nint n = (nint)(uint)values.Component0.Length / Vector<float>.Count; nuint n = (uint)(values.Component0.Length / Vector<float>.Count);
for (nint i = 0; i < n; i++) for (nuint i = 0; i < n; i++)
{ {
Vector<float> r = maxSampleValue - Unsafe.Add(ref srcR, i); Vector<float> r = maxSampleValue - Unsafe.Add(ref srcR, i);
Vector<float> g = maxSampleValue - Unsafe.Add(ref srcG, i); Vector<float> g = maxSampleValue - Unsafe.Add(ref srcG, i);

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

@ -470,7 +470,7 @@ internal class ArithmeticScanDecoder : IJpegScanDecoder
this.DecodeBlockBaseline( this.DecodeBlockBaseline(
component, component,
ref Unsafe.Add(ref blockRef, (nint)(uint)blockCol), ref Unsafe.Add(ref blockRef, (uint)blockCol),
ref acDecodingTable, ref acDecodingTable,
ref dcDecodingTable); ref dcDecodingTable);
} }
@ -521,7 +521,7 @@ internal class ArithmeticScanDecoder : IJpegScanDecoder
this.DecodeBlockBaseline( this.DecodeBlockBaseline(
component, component,
ref Unsafe.Add(ref blockRef, (nint)(uint)k), ref Unsafe.Add(ref blockRef, (uint)k),
ref acDecodingTable, ref acDecodingTable,
ref dcDecodingTable); ref dcDecodingTable);
@ -560,7 +560,7 @@ internal class ArithmeticScanDecoder : IJpegScanDecoder
this.DecodeBlockBaseline( this.DecodeBlockBaseline(
component, component,
ref Unsafe.Add(ref blockRef, (nint)(uint)i), ref Unsafe.Add(ref blockRef, (uint)i),
ref acDecodingTable, ref acDecodingTable,
ref dcDecodingTable); ref dcDecodingTable);
@ -611,7 +611,7 @@ internal class ArithmeticScanDecoder : IJpegScanDecoder
this.DecodeBlockProgressiveDc( this.DecodeBlockProgressiveDc(
component, component,
ref Unsafe.Add(ref blockRef, (nint)(uint)blockCol), ref Unsafe.Add(ref blockRef, (uint)blockCol),
ref dcDecodingTable); ref dcDecodingTable);
} }
} }
@ -653,7 +653,7 @@ internal class ArithmeticScanDecoder : IJpegScanDecoder
this.DecodeBlockProgressiveDc( this.DecodeBlockProgressiveDc(
component, component,
ref Unsafe.Add(ref blockRef, (nint)(uint)i), ref Unsafe.Add(ref blockRef, (uint)i),
ref dcDecodingTable); ref dcDecodingTable);
this.HandleRestart(); this.HandleRestart();
@ -680,7 +680,7 @@ internal class ArithmeticScanDecoder : IJpegScanDecoder
this.DecodeBlockProgressiveAc( this.DecodeBlockProgressiveAc(
component, component,
ref Unsafe.Add(ref blockRef, (nint)(uint)i), ref Unsafe.Add(ref blockRef, (uint)i),
ref acDecodingTable); ref acDecodingTable);
this.HandleRestart(); this.HandleRestart();
@ -717,7 +717,7 @@ internal class ArithmeticScanDecoder : IJpegScanDecoder
// Figure F.21: Decoding nonzero value v. // Figure F.21: Decoding nonzero value v.
// Figure F.22: Decoding the sign of v. // Figure F.22: Decoding the sign of v.
int sign = this.DecodeBinaryDecision(ref reader, ref Unsafe.Add(ref st, 1)); int sign = this.DecodeBinaryDecision(ref reader, ref Unsafe.Add(ref st, 1));
st = ref Unsafe.Add(ref st, (nint)(uint)(2 + sign)); st = ref Unsafe.Add(ref st, (uint)(2 + sign));
// Figure F.23: Decoding the magnitude category of v. // Figure F.23: Decoding the magnitude category of v.
int m = this.DecodeBinaryDecision(ref reader, ref st); int m = this.DecodeBinaryDecision(ref reader, ref st);
@ -967,7 +967,7 @@ internal class ArithmeticScanDecoder : IJpegScanDecoder
// Figure F.21: Decoding nonzero value v // Figure F.21: Decoding nonzero value v
// Figure F.22: Decoding the sign of v // Figure F.22: Decoding the sign of v
int sign = this.DecodeBinaryDecision(ref reader, ref Unsafe.Add(ref st, 1)); int sign = this.DecodeBinaryDecision(ref reader, ref Unsafe.Add(ref st, 1));
st = ref Unsafe.Add(ref st, (nint)(uint)(2 + sign)); st = ref Unsafe.Add(ref st, (uint)(2 + sign));
// Figure F.23: Decoding the magnitude category of v. // Figure F.23: Decoding the magnitude category of v.
int m = this.DecodeBinaryDecision(ref reader, ref st); int m = this.DecodeBinaryDecision(ref reader, ref st);

22
src/ImageSharp/Formats/Jpeg/Components/Decoder/ComponentProcessors/DownScalingComponentProcessor2.cs

@ -67,30 +67,30 @@ internal sealed class DownScalingComponentProcessor2 : ComponentProcessor
public static void ScaledCopyTo(ref Block8x8F block, ref float destRef, int destStrideWidth, int horizontalScale, int verticalScale) public static void ScaledCopyTo(ref Block8x8F block, ref float destRef, int destStrideWidth, int horizontalScale, int verticalScale)
{ {
// TODO: Optimize: implement all cases with scale-specific, loopless code! // TODO: Optimize: implement all cases with scale-specific, loopless code!
CopyArbitraryScale(ref block, ref destRef, destStrideWidth, horizontalScale, verticalScale); CopyArbitraryScale(ref block, ref destRef, (uint)destStrideWidth, (uint)horizontalScale, (uint)verticalScale);
[MethodImpl(InliningOptions.ColdPath)] [MethodImpl(InliningOptions.ColdPath)]
static void CopyArbitraryScale(ref Block8x8F block, ref float areaOrigin, int areaStride, int horizontalScale, int verticalScale) static void CopyArbitraryScale(ref Block8x8F block, ref float areaOrigin, uint areaStride, uint horizontalScale, uint verticalScale)
{ {
for (int y = 0; y < 4; y++) for (nuint y = 0; y < 4; y++)
{ {
int yy = y * verticalScale; nuint yy = y * verticalScale;
int y8 = y * 8; nuint y8 = y * 8;
for (int x = 0; x < 4; x++) for (nuint x = 0; x < 4; x++)
{ {
int xx = x * horizontalScale; nuint xx = x * horizontalScale;
float value = block[y8 + x]; float value = block[y8 + x];
for (int i = 0; i < verticalScale; i++) for (nuint i = 0; i < verticalScale; i++)
{ {
int baseIdx = ((yy + i) * areaStride) + xx; nuint baseIdx = ((yy + i) * areaStride) + xx;
for (int j = 0; j < horizontalScale; j++) for (nuint j = 0; j < horizontalScale; j++)
{ {
// area[xx + j, yy + i] = value; // area[xx + j, yy + i] = value;
Unsafe.Add(ref areaOrigin, (nint)(uint)(baseIdx + j)) = value; Unsafe.Add(ref areaOrigin, baseIdx + j) = value;
} }
} }
} }

22
src/ImageSharp/Formats/Jpeg/Components/Decoder/ComponentProcessors/DownScalingComponentProcessor4.cs

@ -67,30 +67,30 @@ internal sealed class DownScalingComponentProcessor4 : ComponentProcessor
public static void ScaledCopyTo(ref Block8x8F block, ref float destRef, int destStrideWidth, int horizontalScale, int verticalScale) public static void ScaledCopyTo(ref Block8x8F block, ref float destRef, int destStrideWidth, int horizontalScale, int verticalScale)
{ {
// TODO: Optimize: implement all cases with scale-specific, loopless code! // TODO: Optimize: implement all cases with scale-specific, loopless code!
CopyArbitraryScale(ref block, ref destRef, destStrideWidth, horizontalScale, verticalScale); CopyArbitraryScale(ref block, ref destRef, (uint)destStrideWidth, (uint)horizontalScale, (uint)verticalScale);
[MethodImpl(InliningOptions.ColdPath)] [MethodImpl(InliningOptions.ColdPath)]
static void CopyArbitraryScale(ref Block8x8F block, ref float areaOrigin, int areaStride, int horizontalScale, int verticalScale) static void CopyArbitraryScale(ref Block8x8F block, ref float areaOrigin, uint areaStride, uint horizontalScale, uint verticalScale)
{ {
for (int y = 0; y < 2; y++) for (nuint y = 0; y < 2; y++)
{ {
int yy = y * verticalScale; nuint yy = y * verticalScale;
int y8 = y * 8; nuint y8 = y * 8;
for (int x = 0; x < 2; x++) for (nuint x = 0; x < 2; x++)
{ {
int xx = x * horizontalScale; nuint xx = x * horizontalScale;
float value = block[y8 + x]; float value = block[y8 + x];
for (int i = 0; i < verticalScale; i++) for (nuint i = 0; i < verticalScale; i++)
{ {
int baseIdx = ((yy + i) * areaStride) + xx; nuint baseIdx = ((yy + i) * areaStride) + xx;
for (int j = 0; j < horizontalScale; j++) for (nuint j = 0; j < horizontalScale; j++)
{ {
// area[xx + j, yy + i] = value; // area[xx + j, yy + i] = value;
Unsafe.Add(ref areaOrigin, (nint)(uint)(baseIdx + j)) = value; Unsafe.Add(ref areaOrigin, baseIdx + j) = value;
} }
} }
} }

12
src/ImageSharp/Formats/Jpeg/Components/Decoder/ComponentProcessors/DownScalingComponentProcessor8.cs

@ -67,20 +67,20 @@ internal sealed class DownScalingComponentProcessor8 : ComponentProcessor
{ {
destRef = value; destRef = value;
Unsafe.Add(ref destRef, 1) = value; Unsafe.Add(ref destRef, 1) = value;
Unsafe.Add(ref destRef, 0 + (nint)(uint)destStrideWidth) = value; Unsafe.Add(ref destRef, 0 + (uint)destStrideWidth) = value;
Unsafe.Add(ref destRef, 1 + (nint)(uint)destStrideWidth) = value; Unsafe.Add(ref destRef, 1 + (uint)destStrideWidth) = value;
return; return;
} }
// TODO: Optimize: implement all cases with scale-specific, loopless code! // TODO: Optimize: implement all cases with scale-specific, loopless code!
for (int y = 0; y < verticalScale; y++) for (nuint y = 0; y < (uint)verticalScale; y++)
{ {
for (int x = 0; x < horizontalScale; x++) for (nuint x = 0; x < (uint)horizontalScale; x++)
{ {
Unsafe.Add(ref destRef, (nint)(uint)x) = value; Unsafe.Add(ref destRef, x) = value;
} }
destRef = ref Unsafe.Add(ref destRef, (nint)(uint)destStrideWidth); destRef = ref Unsafe.Add(ref destRef, (uint)destStrideWidth);
} }
} }
} }

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

@ -122,8 +122,8 @@ internal class ComponentProcessor : IDisposable
ref Vector256<float> sourceVectorRef = ref Unsafe.As<float, Vector256<float>>(ref MemoryMarshal.GetReference(source)); ref Vector256<float> sourceVectorRef = ref Unsafe.As<float, Vector256<float>>(ref MemoryMarshal.GetReference(source));
// Spans are guaranteed to be multiple of 8 so no extra 'remainder' steps are needed // Spans are guaranteed to be multiple of 8 so no extra 'remainder' steps are needed
nint count = (nint)(uint)source.Length / Vector256<float>.Count; nuint count = (uint)(source.Length / Vector256<float>.Count);
for (nint i = 0; i < count; i++) for (nuint i = 0; i < count; i++)
{ {
Unsafe.Add(ref targetVectorRef, i) = Avx.Add(Unsafe.Add(ref targetVectorRef, i), Unsafe.Add(ref sourceVectorRef, i)); Unsafe.Add(ref targetVectorRef, i) = Avx.Add(Unsafe.Add(ref targetVectorRef, i), Unsafe.Add(ref sourceVectorRef, i));
} }
@ -133,15 +133,15 @@ internal class ComponentProcessor : IDisposable
ref Vector<float> targetVectorRef = ref Unsafe.As<float, Vector<float>>(ref MemoryMarshal.GetReference(target)); ref Vector<float> targetVectorRef = ref Unsafe.As<float, Vector<float>>(ref MemoryMarshal.GetReference(target));
ref Vector<float> sourceVectorRef = ref Unsafe.As<float, Vector<float>>(ref MemoryMarshal.GetReference(source)); ref Vector<float> sourceVectorRef = ref Unsafe.As<float, Vector<float>>(ref MemoryMarshal.GetReference(source));
nint count = (nint)(uint)source.Length / Vector<float>.Count; nuint count = (uint)(source.Length / Vector<float>.Count);
for (nint i = 0; i < count; i++) for (nuint i = 0; i < count; i++)
{ {
Unsafe.Add(ref targetVectorRef, i) += Unsafe.Add(ref sourceVectorRef, i); Unsafe.Add(ref targetVectorRef, i) += Unsafe.Add(ref sourceVectorRef, i);
} }
ref float targetRef = ref MemoryMarshal.GetReference(target); ref float targetRef = ref MemoryMarshal.GetReference(target);
ref float sourceRef = ref MemoryMarshal.GetReference(source); ref float sourceRef = ref MemoryMarshal.GetReference(source);
for (nint i = count * Vector<float>.Count; i < (uint)source.Length; i++) for (nuint i = count * (uint)Vector<float>.Count; i < (uint)source.Length; i++)
{ {
Unsafe.Add(ref targetRef, i) += Unsafe.Add(ref sourceRef, i); Unsafe.Add(ref targetRef, i) += Unsafe.Add(ref sourceRef, i);
} }
@ -166,16 +166,16 @@ internal class ComponentProcessor : IDisposable
source = source.Slice(touchedCount); source = source.Slice(touchedCount);
target = target.Slice(touchedCount / factor); target = target.Slice(touchedCount / factor);
nint length = (nint)(uint)touchedCount / Vector256<float>.Count; nuint length = (uint)(touchedCount / Vector256<float>.Count);
for (int i = 0; i < haddIterationsCount; i++) for (int i = 0; i < haddIterationsCount; i++)
{ {
length /= 2; length /= 2;
for (nint j = 0; j < length; j++) for (nuint j = 0; j < length; j++)
{ {
nint indexLeft = j * 2; nuint indexLeft = j * 2;
nint indexRight = indexLeft + 1; nuint indexRight = indexLeft + 1;
Vector256<float> sum = Avx.HorizontalAdd(Unsafe.Add(ref targetRef, indexLeft), Unsafe.Add(ref targetRef, indexRight)); 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(); Unsafe.Add(ref targetRef, j) = Avx2.Permute4x64(sum.AsDouble(), 0b11_01_10_00).AsSingle();
} }
@ -200,9 +200,9 @@ internal class ComponentProcessor : IDisposable
ref Vector256<float> targetVectorRef = ref Unsafe.As<float, Vector256<float>>(ref MemoryMarshal.GetReference(target)); ref Vector256<float> targetVectorRef = ref Unsafe.As<float, Vector256<float>>(ref MemoryMarshal.GetReference(target));
// Spans are guaranteed to be multiple of 8 so no extra 'remainder' steps are needed // Spans are guaranteed to be multiple of 8 so no extra 'remainder' steps are needed
nint count = (nint)(uint)target.Length / Vector256<float>.Count; nuint count = (uint)(target.Length / Vector256<float>.Count);
var multiplierVector = Vector256.Create(multiplier); var multiplierVector = Vector256.Create(multiplier);
for (nint i = 0; i < count; i++) for (nuint i = 0; i < count; i++)
{ {
Unsafe.Add(ref targetVectorRef, i) = Avx.Multiply(Unsafe.Add(ref targetVectorRef, i), multiplierVector); Unsafe.Add(ref targetVectorRef, i) = Avx.Multiply(Unsafe.Add(ref targetVectorRef, i), multiplierVector);
} }
@ -211,15 +211,15 @@ internal class ComponentProcessor : IDisposable
{ {
ref Vector<float> targetVectorRef = ref Unsafe.As<float, Vector<float>>(ref MemoryMarshal.GetReference(target)); ref Vector<float> targetVectorRef = ref Unsafe.As<float, Vector<float>>(ref MemoryMarshal.GetReference(target));
nint count = (nint)(uint)target.Length / Vector<float>.Count; nuint count = (uint)(target.Length / Vector<float>.Count);
var multiplierVector = new Vector<float>(multiplier); var multiplierVector = new Vector<float>(multiplier);
for (nint i = 0; i < count; i++) for (nuint i = 0; i < count; i++)
{ {
Unsafe.Add(ref targetVectorRef, i) *= multiplierVector; Unsafe.Add(ref targetVectorRef, i) *= multiplierVector;
} }
ref float targetRef = ref MemoryMarshal.GetReference(target); ref float targetRef = ref MemoryMarshal.GetReference(target);
for (nint i = count * Vector<float>.Count; i < (uint)target.Length; i++) for (nuint i = count * (uint)Vector<float>.Count; i < (uint)target.Length; i++)
{ {
Unsafe.Add(ref targetRef, i) *= multiplier; Unsafe.Add(ref targetRef, i) *= multiplier;
} }

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

@ -180,7 +180,7 @@ internal class HuffmanScanEncoder
Span<Block8x8> blockSpan = component.SpectralBlocks.DangerousGetRowSpan(y: 0); Span<Block8x8> blockSpan = component.SpectralBlocks.DangerousGetRowSpan(y: 0);
ref Block8x8 blockRef = ref MemoryMarshal.GetReference(blockSpan); ref Block8x8 blockRef = ref MemoryMarshal.GetReference(blockSpan);
for (nint k = 0; k < (uint)w; k++) for (nuint k = 0; k < (uint)w; k++)
{ {
this.WriteBlock( this.WriteBlock(
component, component,
@ -219,7 +219,7 @@ internal class HuffmanScanEncoder
Span<Block8x8> blockSpan = component.SpectralBlocks.DangerousGetRowSpan(y: i); Span<Block8x8> blockSpan = component.SpectralBlocks.DangerousGetRowSpan(y: i);
ref Block8x8 blockRef = ref MemoryMarshal.GetReference(blockSpan); ref Block8x8 blockRef = ref MemoryMarshal.GetReference(blockSpan);
for (nint k = 0; k < (uint)w; k++) for (nuint k = 0; k < (uint)w; k++)
{ {
this.WriteBlock( this.WriteBlock(
component, component,
@ -246,9 +246,9 @@ internal class HuffmanScanEncoder
private void EncodeScanBaselineInterleaved<TPixel>(JpegFrame frame, SpectralConverter<TPixel> converter, CancellationToken cancellationToken) private void EncodeScanBaselineInterleaved<TPixel>(JpegFrame frame, SpectralConverter<TPixel> converter, CancellationToken cancellationToken)
where TPixel : unmanaged, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
nint mcu = 0; int mcu = 0;
nint mcusPerColumn = frame.McusPerColumn; int mcusPerColumn = frame.McusPerColumn;
nint mcusPerLine = frame.McusPerLine; int mcusPerLine = frame.McusPerLine;
for (int j = 0; j < mcusPerColumn; j++) for (int j = 0; j < mcusPerColumn; j++)
{ {
@ -258,21 +258,21 @@ internal class HuffmanScanEncoder
converter.ConvertStrideBaseline(); converter.ConvertStrideBaseline();
// Encode spectral to binary // Encode spectral to binary
for (nint i = 0; i < mcusPerLine; i++) for (int i = 0; i < mcusPerLine; i++)
{ {
// Scan an interleaved mcu... process components in order // Scan an interleaved mcu... process components in order
nint mcuCol = mcu % mcusPerLine; int mcuCol = mcu % mcusPerLine;
for (nint k = 0; k < frame.Components.Length; k++) for (int k = 0; k < frame.Components.Length; k++)
{ {
Component component = frame.Components[k]; Component component = frame.Components[k];
ref HuffmanLut dcHuffmanTable = ref this.dcHuffmanTables[component.DcTableId]; ref HuffmanLut dcHuffmanTable = ref this.dcHuffmanTables[component.DcTableId];
ref HuffmanLut acHuffmanTable = ref this.acHuffmanTables[component.AcTableId]; ref HuffmanLut acHuffmanTable = ref this.acHuffmanTables[component.AcTableId];
nint h = component.HorizontalSamplingFactor; int h = component.HorizontalSamplingFactor;
int v = component.VerticalSamplingFactor; int v = component.VerticalSamplingFactor;
nint blockColBase = mcuCol * h; nuint blockColBase = (uint)(mcuCol * h);
// Scan out an mcu's worth of this component; that's just determined // Scan out an mcu's worth of this component; that's just determined
// by the basic H and V specified for the component // by the basic H and V specified for the component
@ -281,9 +281,9 @@ internal class HuffmanScanEncoder
Span<Block8x8> blockSpan = component.SpectralBlocks.DangerousGetRowSpan(y); Span<Block8x8> blockSpan = component.SpectralBlocks.DangerousGetRowSpan(y);
ref Block8x8 blockRef = ref MemoryMarshal.GetReference(blockSpan); ref Block8x8 blockRef = ref MemoryMarshal.GetReference(blockSpan);
for (nint x = 0; x < h; x++) for (nuint x = 0; x < (uint)h; x++)
{ {
nint blockCol = blockColBase + x; nuint blockCol = blockColBase + x;
this.WriteBlock( this.WriteBlock(
component, component,
@ -315,8 +315,8 @@ internal class HuffmanScanEncoder
private void EncodeThreeComponentBaselineInterleavedScanNoSubsampling<TPixel>(JpegFrame frame, SpectralConverter<TPixel> converter, CancellationToken cancellationToken) private void EncodeThreeComponentBaselineInterleavedScanNoSubsampling<TPixel>(JpegFrame frame, SpectralConverter<TPixel> converter, CancellationToken cancellationToken)
where TPixel : unmanaged, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
nint mcusPerColumn = frame.McusPerColumn; nuint mcusPerColumn = (uint)frame.McusPerColumn;
nint mcusPerLine = frame.McusPerLine; nuint mcusPerLine = (uint)frame.McusPerLine;
Component c2 = frame.Components[2]; Component c2 = frame.Components[2];
Component c1 = frame.Components[1]; Component c1 = frame.Components[1];
@ -333,7 +333,7 @@ internal class HuffmanScanEncoder
ref Block8x8 c1BlockRef = ref MemoryMarshal.GetReference(c1.SpectralBlocks.DangerousGetRowSpan(y: 0)); ref Block8x8 c1BlockRef = ref MemoryMarshal.GetReference(c1.SpectralBlocks.DangerousGetRowSpan(y: 0));
ref Block8x8 c2BlockRef = ref MemoryMarshal.GetReference(c2.SpectralBlocks.DangerousGetRowSpan(y: 0)); ref Block8x8 c2BlockRef = ref MemoryMarshal.GetReference(c2.SpectralBlocks.DangerousGetRowSpan(y: 0));
for (nint j = 0; j < mcusPerColumn; j++) for (nuint j = 0; j < mcusPerColumn; j++)
{ {
cancellationToken.ThrowIfCancellationRequested(); cancellationToken.ThrowIfCancellationRequested();
@ -341,7 +341,7 @@ internal class HuffmanScanEncoder
converter.ConvertStrideBaseline(); converter.ConvertStrideBaseline();
// Encode spectral to binary // Encode spectral to binary
for (nint i = 0; i < mcusPerLine; i++) for (nuint i = 0; i < mcusPerLine; i++)
{ {
this.WriteBlock( this.WriteBlock(
c0, c0,

4
src/ImageSharp/Formats/Jpeg/Components/FloatingPointDCT.cs

@ -69,7 +69,7 @@ internal static partial class FloatingPointDCT
{ {
ref float tableRef = ref Unsafe.As<Block8x8F, float>(ref quantTable); ref float tableRef = ref Unsafe.As<Block8x8F, float>(ref quantTable);
ref float multipliersRef = ref MemoryMarshal.GetReference<float>(AdjustmentCoefficients); ref float multipliersRef = ref MemoryMarshal.GetReference<float>(AdjustmentCoefficients);
for (nint i = 0; i < Block8x8F.Size; i++) for (nuint i = 0; i < Block8x8F.Size; i++)
{ {
ref float elemRef = ref Unsafe.Add(ref tableRef, i); ref float elemRef = ref Unsafe.Add(ref tableRef, i);
elemRef = 0.125f * elemRef * Unsafe.Add(ref multipliersRef, i); elemRef = 0.125f * elemRef * Unsafe.Add(ref multipliersRef, i);
@ -88,7 +88,7 @@ internal static partial class FloatingPointDCT
{ {
ref float tableRef = ref Unsafe.As<Block8x8F, float>(ref quantTable); ref float tableRef = ref Unsafe.As<Block8x8F, float>(ref quantTable);
ref float multipliersRef = ref MemoryMarshal.GetReference<float>(AdjustmentCoefficients); ref float multipliersRef = ref MemoryMarshal.GetReference<float>(AdjustmentCoefficients);
for (nint i = 0; i < Block8x8F.Size; i++) for (nuint i = 0; i < Block8x8F.Size; i++)
{ {
ref float elemRef = ref Unsafe.Add(ref tableRef, i); ref float elemRef = ref Unsafe.Add(ref tableRef, i);
elemRef = 0.125f / (elemRef * Unsafe.Add(ref multipliersRef, i)); elemRef = 0.125f / (elemRef * Unsafe.Add(ref multipliersRef, i));

2
src/ImageSharp/Formats/Jpeg/Components/ScaledFloatingPointDCT.cs

@ -40,7 +40,7 @@ internal static class ScaledFloatingPointDCT
public static void AdjustToIDCT(ref Block8x8F quantTable) public static void AdjustToIDCT(ref Block8x8F quantTable)
{ {
ref float tableRef = ref Unsafe.As<Block8x8F, float>(ref quantTable); ref float tableRef = ref Unsafe.As<Block8x8F, float>(ref quantTable);
for (nint i = 0; i < Block8x8F.Size; i++) for (nuint i = 0; i < Block8x8F.Size; i++)
{ {
ref float elemRef = ref Unsafe.Add(ref tableRef, i); ref float elemRef = ref Unsafe.Add(ref tableRef, i);
elemRef = 0.125f * elemRef; elemRef = 0.125f * elemRef;

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

@ -42,7 +42,7 @@ internal static class AverageFilter
} }
else else
{ {
DecodeScalar(scanline, previousScanline, (nint)(uint)bytesPerPixel); DecodeScalar(scanline, previousScanline, (uint)bytesPerPixel);
} }
} }
@ -56,7 +56,7 @@ internal static class AverageFilter
Vector128<byte> ones = Vector128.Create((byte)1); Vector128<byte> ones = Vector128.Create((byte)1);
int rb = scanline.Length; int rb = scanline.Length;
nint offset = 1; nuint offset = 1;
while (rb >= 4) while (rb >= 4)
{ {
ref byte scanRef = ref Unsafe.Add(ref scanBaseRef, offset); ref byte scanRef = ref Unsafe.Add(ref scanBaseRef, offset);
@ -88,7 +88,7 @@ internal static class AverageFilter
Vector64<byte> d = Vector64<byte>.Zero; Vector64<byte> d = Vector64<byte>.Zero;
int rb = scanline.Length; int rb = scanline.Length;
nint offset = 1; nuint offset = 1;
const int bytesPerBatch = 4; const int bytesPerBatch = 4;
while (rb >= bytesPerBatch) while (rb >= bytesPerBatch)
{ {
@ -108,12 +108,12 @@ internal static class AverageFilter
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
private static void DecodeScalar(Span<byte> scanline, Span<byte> previousScanline, nint bytesPerPixel) private static void DecodeScalar(Span<byte> scanline, Span<byte> previousScanline, uint bytesPerPixel)
{ {
ref byte scanBaseRef = ref MemoryMarshal.GetReference(scanline); ref byte scanBaseRef = ref MemoryMarshal.GetReference(scanline);
ref byte prevBaseRef = ref MemoryMarshal.GetReference(previousScanline); ref byte prevBaseRef = ref MemoryMarshal.GetReference(previousScanline);
nint x = 1; nuint x = 1;
for (; x <= bytesPerPixel /* Note the <= because x starts at 1 */; ++x) for (; x <= bytesPerPixel /* Note the <= because x starts at 1 */; ++x)
{ {
ref byte scan = ref Unsafe.Add(ref scanBaseRef, x); ref byte scan = ref Unsafe.Add(ref scanBaseRef, x);
@ -139,7 +139,7 @@ internal static class AverageFilter
/// <param name="bytesPerPixel">The bytes per pixel.</param> /// <param name="bytesPerPixel">The bytes per pixel.</param>
/// <param name="sum">The sum of the total variance of the filtered row.</param> /// <param name="sum">The sum of the total variance of the filtered row.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void Encode(ReadOnlySpan<byte> scanline, ReadOnlySpan<byte> previousScanline, Span<byte> result, int bytesPerPixel, out int sum) public static void Encode(ReadOnlySpan<byte> scanline, ReadOnlySpan<byte> previousScanline, Span<byte> result, uint bytesPerPixel, out int sum)
{ {
DebugGuard.MustBeSameSized(scanline, previousScanline, nameof(scanline)); DebugGuard.MustBeSameSized(scanline, previousScanline, nameof(scanline));
DebugGuard.MustBeSizedAtLeast(result, scanline, nameof(result)); DebugGuard.MustBeSizedAtLeast(result, scanline, nameof(result));
@ -152,8 +152,8 @@ internal static class AverageFilter
// Average(x) = Raw(x) - floor((Raw(x-bpp)+Prior(x))/2) // Average(x) = Raw(x) - floor((Raw(x-bpp)+Prior(x))/2)
resultBaseRef = (byte)FilterType.Average; resultBaseRef = (byte)FilterType.Average;
nint x = 0; nuint x = 0;
for (; x < (uint)bytesPerPixel; /* Note: ++x happens in the body to avoid one add operation */) for (; x < bytesPerPixel; /* Note: ++x happens in the body to avoid one add operation */)
{ {
byte scan = Unsafe.Add(ref scanBaseRef, x); byte scan = Unsafe.Add(ref scanBaseRef, x);
byte above = Unsafe.Add(ref prevBaseRef, x); byte above = Unsafe.Add(ref prevBaseRef, x);
@ -169,7 +169,7 @@ internal static class AverageFilter
Vector256<int> sumAccumulator = Vector256<int>.Zero; Vector256<int> sumAccumulator = Vector256<int>.Zero;
Vector256<byte> allBitsSet = Avx2.CompareEqual(sumAccumulator, sumAccumulator).AsByte(); Vector256<byte> allBitsSet = Avx2.CompareEqual(sumAccumulator, sumAccumulator).AsByte();
for (nint xLeft = x - (nint)(uint)bytesPerPixel; x <= (uint)scanline.Length - Vector256<byte>.Count; xLeft += Vector256<byte>.Count) for (nuint xLeft = x - bytesPerPixel; x <= (uint)(scanline.Length - Vector256<byte>.Count); xLeft += (uint)Vector256<byte>.Count)
{ {
Vector256<byte> scan = Unsafe.As<byte, Vector256<byte>>(ref Unsafe.Add(ref scanBaseRef, x)); 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)); Vector256<byte> left = Unsafe.As<byte, Vector256<byte>>(ref Unsafe.Add(ref scanBaseRef, xLeft));
@ -179,7 +179,7 @@ internal static class AverageFilter
Vector256<byte> res = Avx2.Subtract(scan, avg); Vector256<byte> res = Avx2.Subtract(scan, avg);
Unsafe.As<byte, Vector256<byte>>(ref Unsafe.Add(ref resultBaseRef, x + 1)) = res; // +1 to skip filter type Unsafe.As<byte, Vector256<byte>>(ref Unsafe.Add(ref resultBaseRef, x + 1)) = res; // +1 to skip filter type
x += Vector256<byte>.Count; x += (uint)Vector256<byte>.Count;
sumAccumulator = Avx2.Add(sumAccumulator, Avx2.SumAbsoluteDifferences(Avx2.Abs(res.AsSByte()), zero).AsInt32()); sumAccumulator = Avx2.Add(sumAccumulator, Avx2.SumAbsoluteDifferences(Avx2.Abs(res.AsSByte()), zero).AsInt32());
} }
@ -192,7 +192,7 @@ internal static class AverageFilter
Vector128<int> sumAccumulator = Vector128<int>.Zero; Vector128<int> sumAccumulator = Vector128<int>.Zero;
Vector128<byte> allBitsSet = Sse2.CompareEqual(sumAccumulator, sumAccumulator).AsByte(); Vector128<byte> allBitsSet = Sse2.CompareEqual(sumAccumulator, sumAccumulator).AsByte();
for (nint xLeft = x - (nint)(uint)bytesPerPixel; x <= (uint)scanline.Length - Vector128<byte>.Count; xLeft += Vector128<byte>.Count) for (nuint xLeft = x - bytesPerPixel; x <= (uint)(scanline.Length - Vector128<byte>.Count); xLeft += (uint)Vector128<byte>.Count)
{ {
Vector128<byte> scan = Unsafe.As<byte, Vector128<byte>>(ref Unsafe.Add(ref scanBaseRef, x)); 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)); Vector128<byte> left = Unsafe.As<byte, Vector128<byte>>(ref Unsafe.Add(ref scanBaseRef, xLeft));
@ -202,7 +202,7 @@ internal static class AverageFilter
Vector128<byte> res = Sse2.Subtract(scan, avg); Vector128<byte> res = Sse2.Subtract(scan, avg);
Unsafe.As<byte, Vector128<byte>>(ref Unsafe.Add(ref resultBaseRef, x + 1)) = res; // +1 to skip filter type Unsafe.As<byte, Vector128<byte>>(ref Unsafe.Add(ref resultBaseRef, x + 1)) = res; // +1 to skip filter type
x += Vector128<byte>.Count; x += (uint)Vector128<byte>.Count;
Vector128<byte> absRes; Vector128<byte> absRes;
if (Ssse3.IsSupported) if (Ssse3.IsSupported)
@ -221,7 +221,7 @@ internal static class AverageFilter
sum += Numerics.EvenReduceSum(sumAccumulator); sum += Numerics.EvenReduceSum(sumAccumulator);
} }
for (nint xLeft = x - (nint)(uint)bytesPerPixel; x < (uint)scanline.Length; ++xLeft /* Note: ++x happens in the body to avoid one add operation */) for (nuint xLeft = x - 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 scan = Unsafe.Add(ref scanBaseRef, x);
byte left = Unsafe.Add(ref scanBaseRef, xLeft); byte left = Unsafe.Add(ref scanBaseRef, xLeft);

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

@ -45,7 +45,7 @@ internal static class PaethFilter
} }
else else
{ {
DecodeScalar(scanline, previousScanline, bytesPerPixel); DecodeScalar(scanline, previousScanline, (uint)bytesPerPixel);
} }
} }
@ -59,7 +59,7 @@ internal static class PaethFilter
Vector128<byte> d = Vector128<byte>.Zero; Vector128<byte> d = Vector128<byte>.Zero;
int rb = scanline.Length; int rb = scanline.Length;
nint offset = 1; nuint offset = 1;
while (rb >= 4) while (rb >= 4)
{ {
ref byte scanRef = ref Unsafe.Add(ref scanBaseRef, offset); ref byte scanRef = ref Unsafe.Add(ref scanBaseRef, offset);
@ -113,7 +113,7 @@ internal static class PaethFilter
Vector128<byte> d = Vector128<byte>.Zero; Vector128<byte> d = Vector128<byte>.Zero;
int rb = scanline.Length; int rb = scanline.Length;
nint offset = 1; nuint offset = 1;
const int bytesPerBatch = 4; const int bytesPerBatch = 4;
while (rb >= bytesPerBatch) while (rb >= bytesPerBatch)
{ {
@ -179,15 +179,15 @@ internal static class PaethFilter
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [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, uint bytesPerPixel)
{ {
ref byte scanBaseRef = ref MemoryMarshal.GetReference(scanline); ref byte scanBaseRef = ref MemoryMarshal.GetReference(scanline);
ref byte prevBaseRef = ref MemoryMarshal.GetReference(previousScanline); ref byte prevBaseRef = ref MemoryMarshal.GetReference(previousScanline);
// Paeth(x) + PaethPredictor(Raw(x-bpp), Prior(x), Prior(x-bpp)) // Paeth(x) + PaethPredictor(Raw(x-bpp), Prior(x), Prior(x-bpp))
int offset = bytesPerPixel + 1; // Add one because x starts at one. nuint offset = bytesPerPixel + 1; // Add one because x starts at one.
nint x = 1; nuint x = 1;
for (; x < (uint)offset; x++) for (; x < offset; x++)
{ {
ref byte scan = ref Unsafe.Add(ref scanBaseRef, x); ref byte scan = ref Unsafe.Add(ref scanBaseRef, x);
byte above = Unsafe.Add(ref prevBaseRef, x); byte above = Unsafe.Add(ref prevBaseRef, x);
@ -226,7 +226,7 @@ internal static class PaethFilter
// Paeth(x) = Raw(x) - PaethPredictor(Raw(x-bpp), Prior(x), Prior(x - bpp)) // Paeth(x) = Raw(x) - PaethPredictor(Raw(x-bpp), Prior(x), Prior(x - bpp))
resultBaseRef = (byte)FilterType.Paeth; resultBaseRef = (byte)FilterType.Paeth;
nint x = 0; nuint x = 0;
for (; x < (uint)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 scan = Unsafe.Add(ref scanBaseRef, x);
@ -242,7 +242,7 @@ internal static class PaethFilter
Vector256<byte> zero = Vector256<byte>.Zero; Vector256<byte> zero = Vector256<byte>.Zero;
Vector256<int> sumAccumulator = Vector256<int>.Zero; Vector256<int> sumAccumulator = Vector256<int>.Zero;
for (nint xLeft = x - (nint)(uint)bytesPerPixel; x <= (nint)(uint)scanline.Length - Vector256<byte>.Count; xLeft += Vector256<byte>.Count) for (nuint xLeft = x - (uint)bytesPerPixel; (int)x <= scanline.Length - Vector256<byte>.Count; xLeft += (uint)Vector256<byte>.Count)
{ {
Vector256<byte> scan = Unsafe.As<byte, Vector256<byte>>(ref Unsafe.Add(ref scanBaseRef, x)); 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)); Vector256<byte> left = Unsafe.As<byte, Vector256<byte>>(ref Unsafe.Add(ref scanBaseRef, xLeft));
@ -251,7 +251,7 @@ internal static class PaethFilter
Vector256<byte> res = Avx2.Subtract(scan, PaethPredictor(left, above, upperLeft)); Vector256<byte> res = Avx2.Subtract(scan, PaethPredictor(left, above, upperLeft));
Unsafe.As<byte, Vector256<byte>>(ref Unsafe.Add(ref resultBaseRef, x + 1)) = res; // +1 to skip filter type Unsafe.As<byte, Vector256<byte>>(ref Unsafe.Add(ref resultBaseRef, x + 1)) = res; // +1 to skip filter type
x += Vector256<byte>.Count; x += (uint)Vector256<byte>.Count;
sumAccumulator = Avx2.Add(sumAccumulator, Avx2.SumAbsoluteDifferences(Avx2.Abs(res.AsSByte()), zero).AsInt32()); sumAccumulator = Avx2.Add(sumAccumulator, Avx2.SumAbsoluteDifferences(Avx2.Abs(res.AsSByte()), zero).AsInt32());
} }
@ -262,7 +262,7 @@ internal static class PaethFilter
{ {
Vector<uint> sumAccumulator = Vector<uint>.Zero; Vector<uint> sumAccumulator = Vector<uint>.Zero;
for (nint xLeft = x - (nint)(uint)bytesPerPixel; x <= (nint)(uint)scanline.Length - Vector<byte>.Count; xLeft += Vector<byte>.Count) for (nuint xLeft = x - (uint)bytesPerPixel; (int)x <= scanline.Length - Vector<byte>.Count; xLeft += (uint)Vector<byte>.Count)
{ {
Vector<byte> scan = Unsafe.As<byte, Vector<byte>>(ref Unsafe.Add(ref scanBaseRef, x)); 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)); Vector<byte> left = Unsafe.As<byte, Vector<byte>>(ref Unsafe.Add(ref scanBaseRef, xLeft));
@ -271,7 +271,7 @@ internal static class PaethFilter
Vector<byte> res = scan - PaethPredictor(left, above, upperLeft); Vector<byte> res = scan - PaethPredictor(left, above, upperLeft);
Unsafe.As<byte, Vector<byte>>(ref Unsafe.Add(ref resultBaseRef, x + 1)) = res; // +1 to skip filter type Unsafe.As<byte, Vector<byte>>(ref Unsafe.Add(ref resultBaseRef, x + 1)) = res; // +1 to skip filter type
x += Vector<byte>.Count; x += (uint)Vector<byte>.Count;
Numerics.Accumulate(ref sumAccumulator, Vector.AsVectorByte(Vector.Abs(Vector.AsVectorSByte(res)))); Numerics.Accumulate(ref sumAccumulator, Vector.AsVectorByte(Vector.Abs(Vector.AsVectorSByte(res))));
} }
@ -282,7 +282,7 @@ internal static class PaethFilter
} }
} }
for (nint xLeft = x - (nint)(uint)bytesPerPixel; x < (nint)(uint)scanline.Length; ++xLeft /* Note: ++x happens in the body to avoid one add operation */) for (nuint xLeft = x - (uint)bytesPerPixel; (int)x < scanline.Length; ++xLeft /* Note: ++x happens in the body to avoid one add operation */)
{ {
byte scan = Unsafe.Add(ref scanBaseRef, x); byte scan = Unsafe.Add(ref scanBaseRef, x);
byte left = Unsafe.Add(ref scanBaseRef, xLeft); byte left = Unsafe.Add(ref scanBaseRef, xLeft);

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

@ -36,7 +36,7 @@ internal static class SubFilter
} }
else else
{ {
DecodeScalar(scanline, (nint)(uint)bytesPerPixel); DecodeScalar(scanline, (uint)bytesPerPixel);
} }
} }
@ -47,7 +47,7 @@ internal static class SubFilter
Vector128<byte> d = Vector128<byte>.Zero; Vector128<byte> d = Vector128<byte>.Zero;
int rb = scanline.Length; int rb = scanline.Length;
nint offset = 1; nuint offset = 1;
while (rb >= 4) while (rb >= 4)
{ {
ref byte scanRef = ref Unsafe.Add(ref scanBaseRef, offset); ref byte scanRef = ref Unsafe.Add(ref scanBaseRef, offset);
@ -70,7 +70,7 @@ internal static class SubFilter
Vector64<byte> d = Vector64<byte>.Zero; Vector64<byte> d = Vector64<byte>.Zero;
int rb = scanline.Length; int rb = scanline.Length;
nint offset = 1; nuint offset = 1;
const int bytesPerBatch = 4; const int bytesPerBatch = 4;
while (rb >= bytesPerBatch) while (rb >= bytesPerBatch)
{ {
@ -87,14 +87,14 @@ internal static class SubFilter
} }
} }
private static void DecodeScalar(Span<byte> scanline, nint bytesPerPixel) private static void DecodeScalar(Span<byte> scanline, nuint bytesPerPixel)
{ {
ref byte scanBaseRef = ref MemoryMarshal.GetReference(scanline); ref byte scanBaseRef = ref MemoryMarshal.GetReference(scanline);
// Sub(x) + Raw(x-bpp) // Sub(x) + Raw(x-bpp)
nint x = bytesPerPixel + 1; nuint x = bytesPerPixel + 1;
Unsafe.Add(ref scanBaseRef, x); Unsafe.Add(ref scanBaseRef, x);
for (; x < scanline.Length; ++x) for (; x < (uint)scanline.Length; ++x)
{ {
ref byte scan = ref Unsafe.Add(ref scanBaseRef, x); ref byte scan = ref Unsafe.Add(ref scanBaseRef, x);
byte prev = Unsafe.Add(ref scanBaseRef, x - bytesPerPixel); byte prev = Unsafe.Add(ref scanBaseRef, x - bytesPerPixel);
@ -121,8 +121,8 @@ internal static class SubFilter
// Sub(x) = Raw(x) - Raw(x-bpp) // Sub(x) = Raw(x) - Raw(x-bpp)
resultBaseRef = (byte)FilterType.Sub; resultBaseRef = (byte)FilterType.Sub;
nint x = 0; nuint x = 0;
for (; x < (nint)(uint)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 scan = Unsafe.Add(ref scanBaseRef, x);
++x; ++x;
@ -136,14 +136,14 @@ internal static class SubFilter
Vector256<byte> zero = Vector256<byte>.Zero; Vector256<byte> zero = Vector256<byte>.Zero;
Vector256<int> sumAccumulator = Vector256<int>.Zero; Vector256<int> sumAccumulator = Vector256<int>.Zero;
for (nint xLeft = x - (nint)(uint)bytesPerPixel; x <= (nint)(uint)scanline.Length - Vector256<byte>.Count; xLeft += Vector256<byte>.Count) for (nuint xLeft = x - (uint)bytesPerPixel; x <= (uint)(scanline.Length - Vector256<byte>.Count); xLeft += (uint)Vector256<byte>.Count)
{ {
Vector256<byte> scan = Unsafe.As<byte, Vector256<byte>>(ref Unsafe.Add(ref scanBaseRef, x)); 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)); Vector256<byte> prev = Unsafe.As<byte, Vector256<byte>>(ref Unsafe.Add(ref scanBaseRef, xLeft));
Vector256<byte> res = Avx2.Subtract(scan, prev); Vector256<byte> res = Avx2.Subtract(scan, prev);
Unsafe.As<byte, Vector256<byte>>(ref Unsafe.Add(ref resultBaseRef, x + 1)) = res; // +1 to skip filter type Unsafe.As<byte, Vector256<byte>>(ref Unsafe.Add(ref resultBaseRef, x + 1)) = res; // +1 to skip filter type
x += Vector256<byte>.Count; x += (uint)Vector256<byte>.Count;
sumAccumulator = Avx2.Add(sumAccumulator, Avx2.SumAbsoluteDifferences(Avx2.Abs(res.AsSByte()), zero).AsInt32()); sumAccumulator = Avx2.Add(sumAccumulator, Avx2.SumAbsoluteDifferences(Avx2.Abs(res.AsSByte()), zero).AsInt32());
} }
@ -154,14 +154,14 @@ internal static class SubFilter
{ {
Vector<uint> sumAccumulator = Vector<uint>.Zero; Vector<uint> sumAccumulator = Vector<uint>.Zero;
for (nint xLeft = x - (nint)(uint)bytesPerPixel; x <= (nint)(uint)scanline.Length - Vector<byte>.Count; xLeft += Vector<byte>.Count) for (nuint xLeft = x - (uint)bytesPerPixel; x <= (uint)(scanline.Length - Vector<byte>.Count); xLeft += (uint)Vector<byte>.Count)
{ {
Vector<byte> scan = Unsafe.As<byte, Vector<byte>>(ref Unsafe.Add(ref scanBaseRef, x)); 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)); Vector<byte> prev = Unsafe.As<byte, Vector<byte>>(ref Unsafe.Add(ref scanBaseRef, xLeft));
Vector<byte> res = scan - prev; Vector<byte> res = scan - prev;
Unsafe.As<byte, Vector<byte>>(ref Unsafe.Add(ref resultBaseRef, x + 1)) = res; // +1 to skip filter type Unsafe.As<byte, Vector<byte>>(ref Unsafe.Add(ref resultBaseRef, x + 1)) = res; // +1 to skip filter type
x += Vector<byte>.Count; x += (uint)Vector<byte>.Count;
Numerics.Accumulate(ref sumAccumulator, Vector.AsVectorByte(Vector.Abs(Vector.AsVectorSByte(res)))); Numerics.Accumulate(ref sumAccumulator, Vector.AsVectorByte(Vector.Abs(Vector.AsVectorSByte(res))));
} }
@ -172,7 +172,7 @@ internal static class SubFilter
} }
} }
for (nint xLeft = x - (nint)(uint)bytesPerPixel; x < (nint)(uint)scanline.Length; ++xLeft /* Note: ++x happens in the body to avoid one add operation */) for (nuint xLeft = x - (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 scan = Unsafe.Add(ref scanBaseRef, x);
byte prev = Unsafe.Add(ref scanBaseRef, xLeft); byte prev = Unsafe.Add(ref scanBaseRef, xLeft);

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

@ -52,7 +52,7 @@ internal static class UpFilter
// Up(x) + Prior(x) // Up(x) + Prior(x)
int rb = scanline.Length; int rb = scanline.Length;
nint offset = 1; nuint offset = 1;
while (rb >= Vector256<byte>.Count) while (rb >= Vector256<byte>.Count)
{ {
ref byte scanRef = ref Unsafe.Add(ref scanBaseRef, offset); ref byte scanRef = ref Unsafe.Add(ref scanBaseRef, offset);
@ -61,12 +61,12 @@ internal static class UpFilter
Unsafe.As<byte, Vector256<byte>>(ref scanRef) = Avx2.Add(up, prior); Unsafe.As<byte, Vector256<byte>>(ref scanRef) = Avx2.Add(up, prior);
offset += Vector256<byte>.Count; offset += (uint)Vector256<byte>.Count;
rb -= Vector256<byte>.Count; rb -= Vector256<byte>.Count;
} }
// Handle left over. // Handle left over.
for (nint i = offset; i < (uint)scanline.Length; i++) for (nuint i = offset; i < (uint)scanline.Length; i++)
{ {
ref byte scan = ref Unsafe.Add(ref scanBaseRef, offset); ref byte scan = ref Unsafe.Add(ref scanBaseRef, offset);
byte above = Unsafe.Add(ref prevBaseRef, offset); byte above = Unsafe.Add(ref prevBaseRef, offset);
@ -82,7 +82,7 @@ internal static class UpFilter
// Up(x) + Prior(x) // Up(x) + Prior(x)
int rb = scanline.Length; int rb = scanline.Length;
nint offset = 1; nuint offset = 1;
while (rb >= Vector128<byte>.Count) while (rb >= Vector128<byte>.Count)
{ {
ref byte scanRef = ref Unsafe.Add(ref scanBaseRef, offset); ref byte scanRef = ref Unsafe.Add(ref scanBaseRef, offset);
@ -91,12 +91,12 @@ internal static class UpFilter
Unsafe.As<byte, Vector128<byte>>(ref scanRef) = Sse2.Add(up, prior); Unsafe.As<byte, Vector128<byte>>(ref scanRef) = Sse2.Add(up, prior);
offset += Vector128<byte>.Count; offset += (uint)Vector128<byte>.Count;
rb -= Vector128<byte>.Count; rb -= Vector128<byte>.Count;
} }
// Handle left over. // Handle left over.
for (nint i = offset; i < (uint)scanline.Length; i++) for (nuint i = offset; i < (uint)scanline.Length; i++)
{ {
ref byte scan = ref Unsafe.Add(ref scanBaseRef, offset); ref byte scan = ref Unsafe.Add(ref scanBaseRef, offset);
byte above = Unsafe.Add(ref prevBaseRef, offset); byte above = Unsafe.Add(ref prevBaseRef, offset);
@ -112,7 +112,7 @@ internal static class UpFilter
// Up(x) + Prior(x) // Up(x) + Prior(x)
int rb = scanline.Length; int rb = scanline.Length;
nint offset = 1; nuint offset = 1;
const int bytesPerBatch = 16; const int bytesPerBatch = 16;
while (rb >= bytesPerBatch) while (rb >= bytesPerBatch)
{ {
@ -127,7 +127,7 @@ internal static class UpFilter
} }
// Handle left over. // Handle left over.
for (nint i = offset; i < (uint)scanline.Length; i++) for (nuint i = offset; i < (uint)scanline.Length; i++)
{ {
ref byte scan = ref Unsafe.Add(ref scanBaseRef, offset); ref byte scan = ref Unsafe.Add(ref scanBaseRef, offset);
byte above = Unsafe.Add(ref prevBaseRef, offset); byte above = Unsafe.Add(ref prevBaseRef, offset);
@ -143,7 +143,7 @@ internal static class UpFilter
ref byte prevBaseRef = ref MemoryMarshal.GetReference(previousScanline); ref byte prevBaseRef = ref MemoryMarshal.GetReference(previousScanline);
// Up(x) + Prior(x) // Up(x) + Prior(x)
for (nint x = 1; x < (uint)scanline.Length; x++) for (nuint x = 1; x < (uint)scanline.Length; x++)
{ {
ref byte scan = ref Unsafe.Add(ref scanBaseRef, x); ref byte scan = ref Unsafe.Add(ref scanBaseRef, x);
byte above = Unsafe.Add(ref prevBaseRef, x); byte above = Unsafe.Add(ref prevBaseRef, x);
@ -172,21 +172,21 @@ internal static class UpFilter
// Up(x) = Raw(x) - Prior(x) // Up(x) = Raw(x) - Prior(x)
resultBaseRef = (byte)FilterType.Up; resultBaseRef = (byte)FilterType.Up;
nint x = 0; nuint x = 0;
if (Avx2.IsSupported) if (Avx2.IsSupported)
{ {
Vector256<byte> zero = Vector256<byte>.Zero; Vector256<byte> zero = Vector256<byte>.Zero;
Vector256<int> sumAccumulator = Vector256<int>.Zero; Vector256<int> sumAccumulator = Vector256<int>.Zero;
for (; x <= (nint)(uint)(scanline.Length - Vector256<byte>.Count);) for (; x <= (uint)(scanline.Length - Vector256<byte>.Count);)
{ {
Vector256<byte> scan = Unsafe.As<byte, Vector256<byte>>(ref Unsafe.Add(ref scanBaseRef, x)); 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)); Vector256<byte> above = Unsafe.As<byte, Vector256<byte>>(ref Unsafe.Add(ref prevBaseRef, x));
Vector256<byte> res = Avx2.Subtract(scan, above); Vector256<byte> res = Avx2.Subtract(scan, above);
Unsafe.As<byte, Vector256<byte>>(ref Unsafe.Add(ref resultBaseRef, x + 1)) = res; // +1 to skip filter type Unsafe.As<byte, Vector256<byte>>(ref Unsafe.Add(ref resultBaseRef, x + 1)) = res; // +1 to skip filter type
x += Vector256<byte>.Count; x += (uint)Vector256<byte>.Count;
sumAccumulator = Avx2.Add(sumAccumulator, Avx2.SumAbsoluteDifferences(Avx2.Abs(res.AsSByte()), zero).AsInt32()); sumAccumulator = Avx2.Add(sumAccumulator, Avx2.SumAbsoluteDifferences(Avx2.Abs(res.AsSByte()), zero).AsInt32());
} }
@ -197,14 +197,14 @@ internal static class UpFilter
{ {
Vector<uint> sumAccumulator = Vector<uint>.Zero; Vector<uint> sumAccumulator = Vector<uint>.Zero;
for (; x <= (nint)(uint)(scanline.Length - Vector<byte>.Count);) for (; x <= (uint)(scanline.Length - Vector<byte>.Count);)
{ {
Vector<byte> scan = Unsafe.As<byte, Vector<byte>>(ref Unsafe.Add(ref scanBaseRef, x)); 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)); Vector<byte> above = Unsafe.As<byte, Vector<byte>>(ref Unsafe.Add(ref prevBaseRef, x));
Vector<byte> res = scan - above; Vector<byte> res = scan - above;
Unsafe.As<byte, Vector<byte>>(ref Unsafe.Add(ref resultBaseRef, x + 1)) = res; // +1 to skip filter type Unsafe.As<byte, Vector<byte>>(ref Unsafe.Add(ref resultBaseRef, x + 1)) = res; // +1 to skip filter type
x += Vector<byte>.Count; x += (uint)Vector<byte>.Count;
Numerics.Accumulate(ref sumAccumulator, Vector.AsVectorByte(Vector.Abs(Vector.AsVectorSByte(res)))); Numerics.Accumulate(ref sumAccumulator, Vector.AsVectorByte(Vector.Abs(Vector.AsVectorSByte(res))));
} }
@ -215,7 +215,7 @@ internal static class UpFilter
} }
} }
for (; x < (nint)(uint)scanline.Length; /* Note: ++x happens in the body to avoid one add operation */) for (; x < (uint)scanline.Length; /* Note: ++x happens in the body to avoid one add operation */)
{ {
byte scan = Unsafe.Add(ref scanBaseRef, x); byte scan = Unsafe.Add(ref scanBaseRef, x);
byte above = Unsafe.Add(ref prevBaseRef, x); byte above = Unsafe.Add(ref prevBaseRef, x);

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

@ -777,8 +777,8 @@ internal sealed class PngDecoderCore : IImageDecoderInternals
this.header, this.header,
scanlineSpan, scanlineSpan,
rowSpan, rowSpan,
this.bytesPerPixel, (uint)this.bytesPerPixel,
this.bytesPerSample); (uint)this.bytesPerSample);
break; break;
@ -858,8 +858,8 @@ internal sealed class PngDecoderCore : IImageDecoderInternals
this.header, this.header,
scanlineSpan, scanlineSpan,
rowSpan, rowSpan,
pixelOffset, (uint)pixelOffset,
increment, (uint)increment,
pngMetadata.HasTransparency, pngMetadata.HasTransparency,
pngMetadata.TransparentL16.GetValueOrDefault(), pngMetadata.TransparentL16.GetValueOrDefault(),
pngMetadata.TransparentL8.GetValueOrDefault()); pngMetadata.TransparentL8.GetValueOrDefault());
@ -871,10 +871,10 @@ internal sealed class PngDecoderCore : IImageDecoderInternals
this.header, this.header,
scanlineSpan, scanlineSpan,
rowSpan, rowSpan,
pixelOffset, (uint)pixelOffset,
increment, (uint)increment,
this.bytesPerPixel, (uint)this.bytesPerPixel,
this.bytesPerSample); (uint)this.bytesPerSample);
break; break;
@ -883,8 +883,8 @@ internal sealed class PngDecoderCore : IImageDecoderInternals
this.header, this.header,
scanlineSpan, scanlineSpan,
rowSpan, rowSpan,
pixelOffset, (uint)pixelOffset,
increment, (uint)increment,
this.palette, this.palette,
this.paletteAlpha); this.paletteAlpha);
@ -895,8 +895,8 @@ internal sealed class PngDecoderCore : IImageDecoderInternals
this.header, this.header,
scanlineSpan, scanlineSpan,
rowSpan, rowSpan,
pixelOffset, (uint)pixelOffset,
increment, (uint)increment,
this.bytesPerPixel, this.bytesPerPixel,
this.bytesPerSample, this.bytesPerSample,
pngMetadata.HasTransparency, pngMetadata.HasTransparency,
@ -910,8 +910,8 @@ internal sealed class PngDecoderCore : IImageDecoderInternals
this.header, this.header,
scanlineSpan, scanlineSpan,
rowSpan, rowSpan,
pixelOffset, (uint)pixelOffset,
increment, (uint)increment,
this.bytesPerPixel, this.bytesPerPixel,
this.bytesPerSample); this.bytesPerSample);

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

@ -455,7 +455,7 @@ internal sealed class PngEncoderCore : IImageEncoderInternals, IDisposable
break; break;
case PngFilterMethod.Average: case PngFilterMethod.Average:
AverageFilter.Encode(this.currentScanline.GetSpan(), this.previousScanline.GetSpan(), filter, this.bytesPerPixel, out int _); AverageFilter.Encode(this.currentScanline.GetSpan(), this.previousScanline.GetSpan(), filter, (uint)this.bytesPerPixel, out int _);
break; break;
case PngFilterMethod.Paeth: case PngFilterMethod.Paeth:
@ -547,7 +547,7 @@ internal sealed class PngEncoderCore : IImageEncoderInternals, IDisposable
RuntimeUtility.Swap(ref filter, ref attempt); RuntimeUtility.Swap(ref filter, ref attempt);
} }
AverageFilter.Encode(current, previous, attempt, this.bytesPerPixel, out sum); AverageFilter.Encode(current, previous, attempt, (uint)this.bytesPerPixel, out sum);
if (sum < min) if (sum < min)
{ {
min = sum; min = sum;

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

@ -32,20 +32,21 @@ internal static class PngScanlineProcessor
{ {
if (header.BitDepth == 16) if (header.BitDepth == 16)
{ {
for (int x = 0, o = 0; x < header.Width; x++, o += 2) int o = 0;
for (nuint x = 0; x < (uint)header.Width; x++, o += 2)
{ {
ushort luminance = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o, 2)); ushort luminance = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o, 2));
pixel.FromL16(Unsafe.As<ushort, L16>(ref luminance)); pixel.FromL16(Unsafe.As<ushort, L16>(ref luminance));
Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; Unsafe.Add(ref rowSpanRef, x) = pixel;
} }
} }
else else
{ {
for (int x = 0; x < header.Width; x++) for (nuint x = 0; x < (uint)header.Width; x++)
{ {
byte luminance = (byte)(Unsafe.Add(ref scanlineSpanRef, (uint)x) * scaleFactor); byte luminance = (byte)(Unsafe.Add(ref scanlineSpanRef, x) * scaleFactor);
pixel.FromL8(Unsafe.As<byte, L8>(ref luminance)); pixel.FromL8(Unsafe.As<byte, L8>(ref luminance));
Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; Unsafe.Add(ref rowSpanRef, x) = pixel;
} }
} }
@ -55,28 +56,29 @@ internal static class PngScanlineProcessor
if (header.BitDepth == 16) if (header.BitDepth == 16)
{ {
La32 source = default; La32 source = default;
for (int x = 0, o = 0; x < header.Width; x++, o += 2) int o = 0;
for (nuint x = 0; x < (uint)header.Width; x++, o += 2)
{ {
ushort luminance = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o, 2)); ushort luminance = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o, 2));
source.L = luminance; source.L = luminance;
source.A = luminance.Equals(luminance16Trans.PackedValue) ? ushort.MinValue : ushort.MaxValue; source.A = luminance.Equals(luminance16Trans.PackedValue) ? ushort.MinValue : ushort.MaxValue;
pixel.FromLa32(source); pixel.FromLa32(source);
Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; Unsafe.Add(ref rowSpanRef, x) = pixel;
} }
} }
else else
{ {
La16 source = default; La16 source = default;
byte scaledLuminanceTrans = (byte)(luminanceTrans.PackedValue * scaleFactor); byte scaledLuminanceTrans = (byte)(luminanceTrans.PackedValue * scaleFactor);
for (int x = 0; x < header.Width; x++) for (nuint x = 0; x < (uint)header.Width; x++)
{ {
byte luminance = (byte)(Unsafe.Add(ref scanlineSpanRef, (uint)x) * scaleFactor); byte luminance = (byte)(Unsafe.Add(ref scanlineSpanRef, x) * scaleFactor);
source.L = luminance; source.L = luminance;
source.A = luminance.Equals(scaledLuminanceTrans) ? byte.MinValue : byte.MaxValue; source.A = luminance.Equals(scaledLuminanceTrans) ? byte.MinValue : byte.MaxValue;
pixel.FromLa16(source); pixel.FromLa16(source);
Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; Unsafe.Add(ref rowSpanRef, x) = pixel;
} }
} }
} }
@ -85,8 +87,8 @@ internal static class PngScanlineProcessor
in PngHeader header, in PngHeader header,
ReadOnlySpan<byte> scanlineSpan, ReadOnlySpan<byte> scanlineSpan,
Span<TPixel> rowSpan, Span<TPixel> rowSpan,
int pixelOffset, uint pixelOffset,
int increment, uint increment,
bool hasTrans, bool hasTrans,
L16 luminance16Trans, L16 luminance16Trans,
L8 luminanceTrans) L8 luminanceTrans)
@ -101,20 +103,21 @@ internal static class PngScanlineProcessor
{ {
if (header.BitDepth == 16) if (header.BitDepth == 16)
{ {
for (int x = pixelOffset, o = 0; x < header.Width; x += increment, o += 2) int o = 0;
for (nuint x = pixelOffset; x < (uint)header.Width; x += increment, o += 2)
{ {
ushort luminance = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o, 2)); ushort luminance = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o, 2));
pixel.FromL16(Unsafe.As<ushort, L16>(ref luminance)); pixel.FromL16(Unsafe.As<ushort, L16>(ref luminance));
Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; Unsafe.Add(ref rowSpanRef, x) = pixel;
} }
} }
else else
{ {
for (int x = pixelOffset, o = 0; x < header.Width; x += increment, o++) for (nuint x = pixelOffset, o = 0; x < (uint)header.Width; x += increment, o++)
{ {
byte luminance = (byte)(Unsafe.Add(ref scanlineSpanRef, (uint)o) * scaleFactor); byte luminance = (byte)(Unsafe.Add(ref scanlineSpanRef, o) * scaleFactor);
pixel.FromL8(Unsafe.As<byte, L8>(ref luminance)); pixel.FromL8(Unsafe.As<byte, L8>(ref luminance));
Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; Unsafe.Add(ref rowSpanRef, x) = pixel;
} }
} }
@ -124,28 +127,29 @@ internal static class PngScanlineProcessor
if (header.BitDepth == 16) if (header.BitDepth == 16)
{ {
La32 source = default; La32 source = default;
for (int x = pixelOffset, o = 0; x < header.Width; x += increment, o += 2) int o = 0;
for (nuint x = pixelOffset; x < (uint)header.Width; x += increment, o += 2)
{ {
ushort luminance = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o, 2)); ushort luminance = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o, 2));
source.L = luminance; source.L = luminance;
source.A = luminance.Equals(luminance16Trans.PackedValue) ? ushort.MinValue : ushort.MaxValue; source.A = luminance.Equals(luminance16Trans.PackedValue) ? ushort.MinValue : ushort.MaxValue;
pixel.FromLa32(source); pixel.FromLa32(source);
Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; Unsafe.Add(ref rowSpanRef, x) = pixel;
} }
} }
else else
{ {
La16 source = default; La16 source = default;
byte scaledLuminanceTrans = (byte)(luminanceTrans.PackedValue * scaleFactor); byte scaledLuminanceTrans = (byte)(luminanceTrans.PackedValue * scaleFactor);
for (int x = pixelOffset, o = 0; x < header.Width; x += increment, o++) for (nuint x = pixelOffset, o = 0; x < (uint)header.Width; x += increment, o++)
{ {
byte luminance = (byte)(Unsafe.Add(ref scanlineSpanRef, (uint)o) * scaleFactor); byte luminance = (byte)(Unsafe.Add(ref scanlineSpanRef, o) * scaleFactor);
source.L = luminance; source.L = luminance;
source.A = luminance.Equals(scaledLuminanceTrans) ? byte.MinValue : byte.MaxValue; source.A = luminance.Equals(scaledLuminanceTrans) ? byte.MinValue : byte.MaxValue;
pixel.FromLa16(source); pixel.FromLa16(source);
Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; Unsafe.Add(ref rowSpanRef, x) = pixel;
} }
} }
} }
@ -154,8 +158,8 @@ internal static class PngScanlineProcessor
in PngHeader header, in PngHeader header,
ReadOnlySpan<byte> scanlineSpan, ReadOnlySpan<byte> scanlineSpan,
Span<TPixel> rowSpan, Span<TPixel> rowSpan,
int bytesPerPixel, uint bytesPerPixel,
int bytesPerSample) uint bytesPerSample)
where TPixel : unmanaged, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
TPixel pixel = default; TPixel pixel = default;
@ -165,26 +169,27 @@ internal static class PngScanlineProcessor
if (header.BitDepth == 16) if (header.BitDepth == 16)
{ {
La32 source = default; La32 source = default;
for (int x = 0, o = 0; x < header.Width; x++, o += 4) int o = 0;
for (nuint x = 0; x < (uint)header.Width; x++, o += 4)
{ {
source.L = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o, 2)); source.L = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o, 2));
source.A = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + 2, 2)); source.A = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + 2, 2));
pixel.FromLa32(source); pixel.FromLa32(source);
Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; Unsafe.Add(ref rowSpanRef, x) = pixel;
} }
} }
else else
{ {
La16 source = default; La16 source = default;
for (int x = 0; x < header.Width; x++) for (nuint x = 0; x < (uint)header.Width; x++)
{ {
int offset = x * bytesPerPixel; nuint offset = x * bytesPerPixel;
source.L = Unsafe.Add(ref scanlineSpanRef, (uint)offset); source.L = Unsafe.Add(ref scanlineSpanRef, offset);
source.A = Unsafe.Add(ref scanlineSpanRef, (uint)(offset + bytesPerSample)); source.A = Unsafe.Add(ref scanlineSpanRef, offset + bytesPerSample);
pixel.FromLa16(source); pixel.FromLa16(source);
Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; Unsafe.Add(ref rowSpanRef, x) = pixel;
} }
} }
} }
@ -193,10 +198,10 @@ internal static class PngScanlineProcessor
in PngHeader header, in PngHeader header,
ReadOnlySpan<byte> scanlineSpan, ReadOnlySpan<byte> scanlineSpan,
Span<TPixel> rowSpan, Span<TPixel> rowSpan,
int pixelOffset, uint pixelOffset,
int increment, uint increment,
int bytesPerPixel, uint bytesPerPixel,
int bytesPerSample) uint bytesPerSample)
where TPixel : unmanaged, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
TPixel pixel = default; TPixel pixel = default;
@ -206,7 +211,8 @@ internal static class PngScanlineProcessor
if (header.BitDepth == 16) if (header.BitDepth == 16)
{ {
La32 source = default; La32 source = default;
for (int x = pixelOffset, o = 0; x < header.Width; x += increment, o += 4) int o = 0;
for (nuint x = pixelOffset; x < (uint)header.Width; x += increment, o += 4)
{ {
source.L = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o, 2)); source.L = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o, 2));
source.A = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + 2, 2)); source.A = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + 2, 2));
@ -217,15 +223,15 @@ internal static class PngScanlineProcessor
} }
else else
{ {
int offset = 0;
La16 source = default; La16 source = default;
for (int x = pixelOffset; x < header.Width; x += increment) nuint offset = 0;
for (nuint x = pixelOffset; x < (uint)header.Width; x += increment)
{ {
source.L = Unsafe.Add(ref scanlineSpanRef, (uint)offset); source.L = Unsafe.Add(ref scanlineSpanRef, offset);
source.A = Unsafe.Add(ref scanlineSpanRef, (uint)(offset + bytesPerSample)); source.A = Unsafe.Add(ref scanlineSpanRef, offset + bytesPerSample);
pixel.FromLa16(source); pixel.FromLa16(source);
Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; Unsafe.Add(ref rowSpanRef, x) = pixel;
offset += bytesPerPixel; offset += bytesPerPixel;
} }
} }
@ -257,25 +263,25 @@ internal static class PngScanlineProcessor
Rgba32 rgba = default; Rgba32 rgba = default;
ref byte paletteAlphaRef = ref MemoryMarshal.GetArrayDataReference(paletteAlpha); ref byte paletteAlphaRef = ref MemoryMarshal.GetArrayDataReference(paletteAlpha);
for (int x = 0; x < header.Width; x++) for (nuint x = 0; x < (uint)header.Width; x++)
{ {
int index = Unsafe.Add(ref scanlineSpanRef, (uint)x); uint index = Unsafe.Add(ref scanlineSpanRef, x);
rgba.Rgb = Unsafe.Add(ref palettePixelsRef, (uint)index); rgba.Rgb = Unsafe.Add(ref palettePixelsRef, index);
rgba.A = paletteAlpha.Length > index ? Unsafe.Add(ref paletteAlphaRef, (uint)index) : byte.MaxValue; rgba.A = paletteAlpha.Length > index ? Unsafe.Add(ref paletteAlphaRef, index) : byte.MaxValue;
pixel.FromRgba32(rgba); pixel.FromRgba32(rgba);
Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; Unsafe.Add(ref rowSpanRef, x) = pixel;
} }
} }
else else
{ {
for (int x = 0; x < header.Width; x++) for (nuint x = 0; x < (uint)header.Width; x++)
{ {
int index = Unsafe.Add(ref scanlineSpanRef, (uint)x); int index = Unsafe.Add(ref scanlineSpanRef, x);
Rgb24 rgb = Unsafe.Add(ref palettePixelsRef, (uint)index); Rgb24 rgb = Unsafe.Add(ref palettePixelsRef, index);
pixel.FromRgb24(rgb); pixel.FromRgb24(rgb);
Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; Unsafe.Add(ref rowSpanRef, x) = pixel;
} }
} }
} }
@ -284,8 +290,8 @@ internal static class PngScanlineProcessor
in PngHeader header, in PngHeader header,
ReadOnlySpan<byte> scanlineSpan, ReadOnlySpan<byte> scanlineSpan,
Span<TPixel> rowSpan, Span<TPixel> rowSpan,
int pixelOffset, uint pixelOffset,
int increment, uint increment,
ReadOnlySpan<byte> palette, ReadOnlySpan<byte> palette,
byte[] paletteAlpha) byte[] paletteAlpha)
where TPixel : unmanaged, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
@ -302,25 +308,25 @@ internal static class PngScanlineProcessor
// channel and we should try to read it. // channel and we should try to read it.
Rgba32 rgba = default; Rgba32 rgba = default;
ref byte paletteAlphaRef = ref MemoryMarshal.GetArrayDataReference(paletteAlpha); ref byte paletteAlphaRef = ref MemoryMarshal.GetArrayDataReference(paletteAlpha);
for (int x = pixelOffset, o = 0; x < header.Width; x += increment, o++) for (nuint x = pixelOffset, o = 0; x < (uint)header.Width; x += increment, o++)
{ {
int index = Unsafe.Add(ref scanlineSpanRef, (uint)o); uint index = Unsafe.Add(ref scanlineSpanRef, o);
rgba.A = paletteAlpha.Length > index ? Unsafe.Add(ref paletteAlphaRef, (uint)index) : byte.MaxValue; rgba.A = paletteAlpha.Length > index ? Unsafe.Add(ref paletteAlphaRef, index) : byte.MaxValue;
rgba.Rgb = Unsafe.Add(ref palettePixelsRef, (uint)index); rgba.Rgb = Unsafe.Add(ref palettePixelsRef, index);
pixel.FromRgba32(rgba); pixel.FromRgba32(rgba);
Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; Unsafe.Add(ref rowSpanRef, x) = pixel;
} }
} }
else else
{ {
for (int x = pixelOffset, o = 0; x < header.Width; x += increment, o++) for (nuint x = pixelOffset, o = 0; x < (uint)header.Width; x += increment, o++)
{ {
int index = Unsafe.Add(ref scanlineSpanRef, (uint)o); int index = Unsafe.Add(ref scanlineSpanRef, o);
Rgb24 rgb = Unsafe.Add(ref palettePixelsRef, (uint)index); Rgb24 rgb = Unsafe.Add(ref palettePixelsRef, index);
pixel.FromRgb24(rgb); pixel.FromRgb24(rgb);
Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; Unsafe.Add(ref rowSpanRef, x) = pixel;
} }
} }
} }
@ -345,14 +351,15 @@ internal static class PngScanlineProcessor
if (header.BitDepth == 16) if (header.BitDepth == 16)
{ {
Rgb48 rgb48 = default; Rgb48 rgb48 = default;
for (int x = 0, o = 0; x < header.Width; x++, o += bytesPerPixel) int o = 0;
for (nuint x = 0; x < (uint)header.Width; x++, o += bytesPerPixel)
{ {
rgb48.R = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o, bytesPerSample)); rgb48.R = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o, bytesPerSample));
rgb48.G = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + bytesPerSample, bytesPerSample)); rgb48.G = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + bytesPerSample, bytesPerSample));
rgb48.B = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + (2 * bytesPerSample), bytesPerSample)); rgb48.B = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + (2 * bytesPerSample), bytesPerSample));
pixel.FromRgb48(rgb48); pixel.FromRgb48(rgb48);
Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; Unsafe.Add(ref rowSpanRef, x) = pixel;
} }
} }
else else
@ -367,7 +374,8 @@ internal static class PngScanlineProcessor
{ {
Rgb48 rgb48 = default; Rgb48 rgb48 = default;
Rgba64 rgba64 = default; Rgba64 rgba64 = default;
for (int x = 0, o = 0; x < header.Width; x++, o += bytesPerPixel) int o = 0;
for (nuint x = 0; x < (uint)header.Width; x++, o += bytesPerPixel)
{ {
rgb48.R = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o, bytesPerSample)); rgb48.R = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o, bytesPerSample));
rgb48.G = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + bytesPerSample, bytesPerSample)); rgb48.G = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + bytesPerSample, bytesPerSample));
@ -377,7 +385,7 @@ internal static class PngScanlineProcessor
rgba64.A = rgb48.Equals(rgb48Trans) ? ushort.MinValue : ushort.MaxValue; rgba64.A = rgb48.Equals(rgb48Trans) ? ushort.MinValue : ushort.MaxValue;
pixel.FromRgba64(rgba64); pixel.FromRgba64(rgba64);
Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; Unsafe.Add(ref rowSpanRef, x) = pixel;
} }
} }
else else
@ -385,14 +393,14 @@ internal static class PngScanlineProcessor
Rgba32 rgba32 = default; Rgba32 rgba32 = default;
ReadOnlySpan<Rgb24> rgb24Span = MemoryMarshal.Cast<byte, Rgb24>(scanlineSpan); ReadOnlySpan<Rgb24> rgb24Span = MemoryMarshal.Cast<byte, Rgb24>(scanlineSpan);
ref Rgb24 rgb24SpanRef = ref MemoryMarshal.GetReference(rgb24Span); ref Rgb24 rgb24SpanRef = ref MemoryMarshal.GetReference(rgb24Span);
for (int x = 0; x < header.Width; x++) for (nuint x = 0; x < (uint)header.Width; x++)
{ {
ref readonly Rgb24 rgb24 = ref Unsafe.Add(ref rgb24SpanRef, (uint)x); ref readonly Rgb24 rgb24 = ref Unsafe.Add(ref rgb24SpanRef, x);
rgba32.Rgb = rgb24; rgba32.Rgb = rgb24;
rgba32.A = rgb24.Equals(rgb24Trans) ? byte.MinValue : byte.MaxValue; rgba32.A = rgb24.Equals(rgb24Trans) ? byte.MinValue : byte.MaxValue;
pixel.FromRgba32(rgba32); pixel.FromRgba32(rgba32);
Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; Unsafe.Add(ref rowSpanRef, x) = pixel;
} }
} }
} }
@ -401,8 +409,8 @@ internal static class PngScanlineProcessor
in PngHeader header, in PngHeader header,
ReadOnlySpan<byte> scanlineSpan, ReadOnlySpan<byte> scanlineSpan,
Span<TPixel> rowSpan, Span<TPixel> rowSpan,
int pixelOffset, uint pixelOffset,
int increment, uint increment,
int bytesPerPixel, int bytesPerPixel,
int bytesPerSample, int bytesPerSample,
bool hasTrans, bool hasTrans,
@ -420,7 +428,8 @@ internal static class PngScanlineProcessor
{ {
Rgb48 rgb48 = default; Rgb48 rgb48 = default;
Rgba64 rgba64 = default; Rgba64 rgba64 = default;
for (int x = pixelOffset, o = 0; x < header.Width; x += increment, o += bytesPerPixel) int o = 0;
for (nuint x = pixelOffset; x < (uint)header.Width; x += increment, o += bytesPerPixel)
{ {
rgb48.R = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o, bytesPerSample)); rgb48.R = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o, bytesPerSample));
rgb48.G = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + bytesPerSample, bytesPerSample)); rgb48.G = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + bytesPerSample, bytesPerSample));
@ -430,20 +439,21 @@ internal static class PngScanlineProcessor
rgba64.A = rgb48.Equals(rgb48Trans) ? ushort.MinValue : ushort.MaxValue; rgba64.A = rgb48.Equals(rgb48Trans) ? ushort.MinValue : ushort.MaxValue;
pixel.FromRgba64(rgba64); pixel.FromRgba64(rgba64);
Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; Unsafe.Add(ref rowSpanRef, x) = pixel;
} }
} }
else else
{ {
Rgb48 rgb48 = default; Rgb48 rgb48 = default;
for (int x = pixelOffset, o = 0; x < header.Width; x += increment, o += bytesPerPixel) int o = 0;
for (nuint x = pixelOffset; x < (uint)header.Width; x += increment, o += bytesPerPixel)
{ {
rgb48.R = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o, bytesPerSample)); rgb48.R = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o, bytesPerSample));
rgb48.G = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + bytesPerSample, bytesPerSample)); rgb48.G = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + bytesPerSample, bytesPerSample));
rgb48.B = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + (2 * bytesPerSample), bytesPerSample)); rgb48.B = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + (2 * bytesPerSample), bytesPerSample));
pixel.FromRgb48(rgb48); pixel.FromRgb48(rgb48);
Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; Unsafe.Add(ref rowSpanRef, x) = pixel;
} }
} }
@ -453,7 +463,8 @@ internal static class PngScanlineProcessor
if (hasTrans) if (hasTrans)
{ {
Rgba32 rgba = default; Rgba32 rgba = default;
for (int x = pixelOffset, o = 0; x < header.Width; x += increment, o += bytesPerPixel) int o = 0;
for (nuint x = pixelOffset; x < (uint)header.Width; x += increment, o += bytesPerPixel)
{ {
rgba.R = Unsafe.Add(ref scanlineSpanRef, (uint)o); rgba.R = Unsafe.Add(ref scanlineSpanRef, (uint)o);
rgba.G = Unsafe.Add(ref scanlineSpanRef, (uint)(o + bytesPerSample)); rgba.G = Unsafe.Add(ref scanlineSpanRef, (uint)(o + bytesPerSample));
@ -461,20 +472,21 @@ internal static class PngScanlineProcessor
rgba.A = rgb24Trans.Equals(rgba.Rgb) ? byte.MinValue : byte.MaxValue; rgba.A = rgb24Trans.Equals(rgba.Rgb) ? byte.MinValue : byte.MaxValue;
pixel.FromRgba32(rgba); pixel.FromRgba32(rgba);
Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; Unsafe.Add(ref rowSpanRef, x) = pixel;
} }
} }
else else
{ {
Rgb24 rgb = default; Rgb24 rgb = default;
for (int x = pixelOffset, o = 0; x < header.Width; x += increment, o += bytesPerPixel) int o = 0;
for (nuint x = pixelOffset; x < (uint)header.Width; x += increment, o += bytesPerPixel)
{ {
rgb.R = Unsafe.Add(ref scanlineSpanRef, (uint)o); rgb.R = Unsafe.Add(ref scanlineSpanRef, (uint)o);
rgb.G = Unsafe.Add(ref scanlineSpanRef, (uint)(o + bytesPerSample)); rgb.G = Unsafe.Add(ref scanlineSpanRef, (uint)(o + bytesPerSample));
rgb.B = Unsafe.Add(ref scanlineSpanRef, (uint)(o + (2 * bytesPerSample))); rgb.B = Unsafe.Add(ref scanlineSpanRef, (uint)(o + (2 * bytesPerSample)));
pixel.FromRgb24(rgb); pixel.FromRgb24(rgb);
Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; Unsafe.Add(ref rowSpanRef, x) = pixel;
} }
} }
} }
@ -494,7 +506,8 @@ internal static class PngScanlineProcessor
if (header.BitDepth == 16) if (header.BitDepth == 16)
{ {
Rgba64 rgba64 = default; Rgba64 rgba64 = default;
for (int x = 0, o = 0; x < header.Width; x++, o += bytesPerPixel) int o = 0;
for (nuint x = 0; x < (uint)header.Width; x++, o += bytesPerPixel)
{ {
rgba64.R = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o, bytesPerSample)); rgba64.R = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o, bytesPerSample));
rgba64.G = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + bytesPerSample, bytesPerSample)); rgba64.G = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + bytesPerSample, bytesPerSample));
@ -502,7 +515,7 @@ internal static class PngScanlineProcessor
rgba64.A = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + (3 * bytesPerSample), bytesPerSample)); rgba64.A = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + (3 * bytesPerSample), bytesPerSample));
pixel.FromRgba64(rgba64); pixel.FromRgba64(rgba64);
Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; Unsafe.Add(ref rowSpanRef, x) = pixel;
} }
} }
else else
@ -515,8 +528,8 @@ internal static class PngScanlineProcessor
in PngHeader header, in PngHeader header,
ReadOnlySpan<byte> scanlineSpan, ReadOnlySpan<byte> scanlineSpan,
Span<TPixel> rowSpan, Span<TPixel> rowSpan,
int pixelOffset, uint pixelOffset,
int increment, uint increment,
int bytesPerPixel, int bytesPerPixel,
int bytesPerSample) int bytesPerSample)
where TPixel : unmanaged, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
@ -528,7 +541,8 @@ internal static class PngScanlineProcessor
if (header.BitDepth == 16) if (header.BitDepth == 16)
{ {
Rgba64 rgba64 = default; Rgba64 rgba64 = default;
for (int x = pixelOffset, o = 0; x < header.Width; x += increment, o += bytesPerPixel) int o = 0;
for (nuint x = pixelOffset; x < (uint)header.Width; x += increment, o += bytesPerPixel)
{ {
rgba64.R = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o, bytesPerSample)); rgba64.R = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o, bytesPerSample));
rgba64.G = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + bytesPerSample, bytesPerSample)); rgba64.G = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + bytesPerSample, bytesPerSample));
@ -536,13 +550,14 @@ internal static class PngScanlineProcessor
rgba64.A = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + (3 * bytesPerSample), bytesPerSample)); rgba64.A = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + (3 * bytesPerSample), bytesPerSample));
pixel.FromRgba64(rgba64); pixel.FromRgba64(rgba64);
Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; Unsafe.Add(ref rowSpanRef, x) = pixel;
} }
} }
else else
{ {
Rgba32 rgba = default; Rgba32 rgba = default;
for (int x = pixelOffset, o = 0; x < header.Width; x += increment, o += bytesPerPixel) int o = 0;
for (nuint x = pixelOffset; x < (uint)header.Width; x += increment, o += bytesPerPixel)
{ {
rgba.R = Unsafe.Add(ref scanlineSpanRef, (uint)o); rgba.R = Unsafe.Add(ref scanlineSpanRef, (uint)o);
rgba.G = Unsafe.Add(ref scanlineSpanRef, (uint)(o + bytesPerSample)); rgba.G = Unsafe.Add(ref scanlineSpanRef, (uint)(o + bytesPerSample));
@ -550,7 +565,7 @@ internal static class PngScanlineProcessor
rgba.A = Unsafe.Add(ref scanlineSpanRef, (uint)(o + (3 * bytesPerSample))); rgba.A = Unsafe.Add(ref scanlineSpanRef, (uint)(o + (3 * bytesPerSample)));
pixel.FromRgba32(rgba); pixel.FromRgba32(rgba);
Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; Unsafe.Add(ref rowSpanRef, 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 bitPos = Numerics.Modulo8(bitsWritten);
nint bufferPos = bitsWritten / 8; nint bufferPos = bitsWritten / 8;
ref byte scanLineRef = ref MemoryMarshal.GetReference(scanLine); ref byte scanLineRef = ref MemoryMarshal.GetReference(scanLine);
for (nint i = 0; i < (uint)scanLine.Length; i++) for (nuint i = 0; i < (uint)scanLine.Length; i++)
{ {
if (Unsafe.Add(ref scanLineRef, i) != this.white) if (Unsafe.Add(ref scanLineRef, i) != this.white)
{ {

2
src/ImageSharp/Formats/Tiff/Compression/TiffBaseCompression.cs

@ -16,7 +16,7 @@ internal abstract class TiffBaseCompression : IDisposable
this.Width = width; this.Width = width;
this.BitsPerPixel = bitsPerPixel; this.BitsPerPixel = bitsPerPixel;
this.Predictor = predictor; this.Predictor = predictor;
this.BytesPerRow = (int)(((uint)(width * bitsPerPixel) + 7) / 8); this.BytesPerRow = ((width * bitsPerPixel) + 7) / 8;
} }
/// <summary> /// <summary>

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

@ -18,21 +18,21 @@ internal class BlackIsZero1TiffColor<TPixel> : TiffBaseColorDecoder<TPixel>
/// <inheritdoc/> /// <inheritdoc/>
public override void Decode(ReadOnlySpan<byte> data, Buffer2D<TPixel> pixels, int left, int top, int width, int height) public override void Decode(ReadOnlySpan<byte> data, Buffer2D<TPixel> pixels, int left, int top, int width, int height)
{ {
nint offset = 0; nuint offset = 0;
var colorBlack = default(TPixel); TPixel colorBlack = default;
var colorWhite = default(TPixel); TPixel colorWhite = default;
colorBlack.FromRgba32(Color.Black); colorBlack.FromRgba32(Color.Black);
colorWhite.FromRgba32(Color.White); colorWhite.FromRgba32(Color.White);
ref byte dataRef = ref MemoryMarshal.GetReference(data); ref byte dataRef = ref MemoryMarshal.GetReference(data);
for (nint y = top; y < top + height; y++) for (nuint y = (uint)top; y < (uint)(top + height); y++)
{ {
Span<TPixel> pixelRowSpan = pixels.DangerousGetRowSpan((int)y); Span<TPixel> pixelRowSpan = pixels.DangerousGetRowSpan((int)y);
ref TPixel pixelRowRef = ref MemoryMarshal.GetReference(pixelRowSpan); ref TPixel pixelRowRef = ref MemoryMarshal.GetReference(pixelRowSpan);
for (nint x = (nint)(uint)left; x < (nint)(uint)(left + width); x += 8) for (nuint x = (uint)left; x < (uint)(left + width); x += 8)
{ {
byte b = Unsafe.Add(ref dataRef, offset++); byte b = Unsafe.Add(ref dataRef, offset++);
nint maxShift = Math.Min(left + width - x, 8); nuint maxShift = Math.Min((uint)(left + width) - x, 8);
if (maxShift == 8) if (maxShift == 8)
{ {
@ -70,7 +70,7 @@ internal class BlackIsZero1TiffColor<TPixel> : TiffBaseColorDecoder<TPixel>
} }
else else
{ {
for (nint shift = 0; shift < maxShift; shift++) for (nuint shift = 0; shift < maxShift; shift++)
{ {
int bit = (b >> (7 - (int)shift)) & 1; int bit = (b >> (7 - (int)shift)) & 1;

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

@ -17,21 +17,21 @@ internal class WhiteIsZero1TiffColor<TPixel> : TiffBaseColorDecoder<TPixel>
/// <inheritdoc/> /// <inheritdoc/>
public override void Decode(ReadOnlySpan<byte> data, Buffer2D<TPixel> pixels, int left, int top, int width, int height) public override void Decode(ReadOnlySpan<byte> data, Buffer2D<TPixel> pixels, int left, int top, int width, int height)
{ {
nint offset = 0; nuint offset = 0;
var colorBlack = default(TPixel); var colorBlack = default(TPixel);
var colorWhite = default(TPixel); var colorWhite = default(TPixel);
colorBlack.FromRgba32(Color.Black); colorBlack.FromRgba32(Color.Black);
colorWhite.FromRgba32(Color.White); colorWhite.FromRgba32(Color.White);
ref byte dataRef = ref MemoryMarshal.GetReference(data); ref byte dataRef = ref MemoryMarshal.GetReference(data);
for (nint y = top; y < (nint)(uint)(top + height); y++) for (nuint y = (uint)top; y < (uint)(top + height); y++)
{ {
Span<TPixel> pixelRowSpan = pixels.DangerousGetRowSpan((int)y); Span<TPixel> pixelRowSpan = pixels.DangerousGetRowSpan((int)y);
ref TPixel pixelRowRef = ref MemoryMarshal.GetReference(pixelRowSpan); ref TPixel pixelRowRef = ref MemoryMarshal.GetReference(pixelRowSpan);
for (nint x = left; x < (nint)(uint)(left + width); x += 8) for (nuint x = (uint)left; x < (uint)(left + width); x += 8)
{ {
byte b = Unsafe.Add(ref dataRef, offset++); byte b = Unsafe.Add(ref dataRef, offset++);
nint maxShift = Math.Min(left + width - x, 8); nuint maxShift = Math.Min((uint)(left + width) - x, 8);
if (maxShift == 8) if (maxShift == 8)
{ {
@ -69,11 +69,11 @@ internal class WhiteIsZero1TiffColor<TPixel> : TiffBaseColorDecoder<TPixel>
} }
else else
{ {
for (int shift = 0; shift < maxShift; shift++) for (nuint 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 + (nint)(uint)shift); ref TPixel pixel = ref Unsafe.Add(ref pixelRowRef, x + shift);
pixel = bit == 0 ? colorWhite : colorBlack; pixel = bit == 0 ? colorWhite : colorBlack;
} }
} }

2
src/ImageSharp/Formats/Tiff/TiffDecoderCore.cs

@ -793,7 +793,7 @@ internal class TiffDecoderCore : IImageDecoderInternals
} }
} }
int bytesPerRow = (int)(((uint)(width * bitsPerPixel) + 7) / 8); int bytesPerRow = ((width * bitsPerPixel) + 7) / 8;
return bytesPerRow * height; return bytesPerRow * height;
} }

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

@ -319,7 +319,7 @@ internal class AlphaDecoder : IDisposable
return; return;
} }
nint i; nuint i;
Vector128<int> last = Vector128<int>.Zero.WithElement(0, dst[0]); Vector128<int> last = Vector128<int>.Zero.WithElement(0, dst[0]);
ref byte srcRef = ref MemoryMarshal.GetReference(input); ref byte srcRef = ref MemoryMarshal.GetReference(input);
ref byte dstRef = ref MemoryMarshal.GetReference(dst); ref byte dstRef = ref MemoryMarshal.GetReference(dst);
@ -365,20 +365,24 @@ internal class AlphaDecoder : IDisposable
} }
else if (Avx2.IsSupported) else if (Avx2.IsSupported)
{ {
nint i; ref byte inputRef = ref MemoryMarshal.GetReference(input);
ref byte prevRef = ref MemoryMarshal.GetReference(prev);
ref byte dstRef = ref MemoryMarshal.GetReference(dst);
nuint i;
int maxPos = width & ~31; int maxPos = width & ~31;
for (i = 0; i < (uint)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> a0 = Unsafe.As<byte, Vector256<int>>(ref Unsafe.Add(ref inputRef, i));
Vector256<int> b0 = Unsafe.As<byte, Vector256<int>>(ref Unsafe.Add(ref MemoryMarshal.GetReference(prev), i)); Vector256<int> b0 = Unsafe.As<byte, Vector256<int>>(ref Unsafe.Add(ref prevRef, i));
Vector256<byte> c0 = Avx2.Add(a0.AsByte(), b0.AsByte()); Vector256<byte> c0 = Avx2.Add(a0.AsByte(), b0.AsByte());
ref byte outputRef = ref Unsafe.Add(ref MemoryMarshal.GetReference(dst), i); ref byte outputRef = ref Unsafe.Add(ref dstRef, i);
Unsafe.As<byte, Vector256<byte>>(ref outputRef) = c0; Unsafe.As<byte, Vector256<byte>>(ref outputRef) = c0;
} }
for (; i < (uint)width; i++) for (; i < (uint)width; i++)
{ {
dst[(int)i] = (byte)(prev[(int)i] + input[(int)i]); Unsafe.Add(ref dstRef, i) = (byte)(Unsafe.Add(ref prevRef, i) + Unsafe.Add(ref inputRef, i));
} }
} }
else else

24
src/ImageSharp/Formats/Webp/Lossless/ColorSpaceTransformUtils.cs

@ -27,10 +27,10 @@ internal static class ColorSpaceTransformUtils
{ {
Span<uint> srcSpan = bgra[(y * stride)..]; Span<uint> srcSpan = bgra[(y * stride)..];
ref uint inputRef = ref MemoryMarshal.GetReference(srcSpan); ref uint inputRef = ref MemoryMarshal.GetReference(srcSpan);
for (nint x = 0; x <= tileWidth - span; x += span) for (nuint x = 0; x <= (uint)tileWidth - span; x += span)
{ {
nint input0Idx = x; nuint input0Idx = x;
nint input1Idx = x + (span / 2); nuint input1Idx = x + (span / 2);
Vector256<byte> input0 = Unsafe.As<uint, Vector256<uint>>(ref Unsafe.Add(ref inputRef, input0Idx)).AsByte(); Vector256<byte> input0 = Unsafe.As<uint, Vector256<uint>>(ref Unsafe.Add(ref inputRef, input0Idx)).AsByte();
Vector256<byte> input1 = Unsafe.As<uint, Vector256<uint>>(ref Unsafe.Add(ref inputRef, input1Idx)).AsByte(); Vector256<byte> input1 = Unsafe.As<uint, Vector256<uint>>(ref Unsafe.Add(ref inputRef, input1Idx)).AsByte();
Vector256<byte> r0 = Avx2.Shuffle(input0, collectColorBlueTransformsShuffleLowMask256); Vector256<byte> r0 = Avx2.Shuffle(input0, collectColorBlueTransformsShuffleLowMask256);
@ -77,10 +77,10 @@ internal static class ColorSpaceTransformUtils
{ {
Span<uint> srcSpan = bgra[(y * stride)..]; Span<uint> srcSpan = bgra[(y * stride)..];
ref uint inputRef = ref MemoryMarshal.GetReference(srcSpan); ref uint inputRef = ref MemoryMarshal.GetReference(srcSpan);
for (nint x = 0; x <= tileWidth - span; x += span) for (nuint x = 0; (int)x <= tileWidth - span; x += span)
{ {
nint input0Idx = x; nuint input0Idx = x;
nint input1Idx = x + (span / 2); nuint input1Idx = x + (span / 2);
Vector128<byte> input0 = Unsafe.As<uint, Vector128<uint>>(ref Unsafe.Add(ref inputRef, input0Idx)).AsByte(); Vector128<byte> input0 = Unsafe.As<uint, Vector128<uint>>(ref Unsafe.Add(ref inputRef, input0Idx)).AsByte();
Vector128<byte> input1 = Unsafe.As<uint, Vector128<uint>>(ref Unsafe.Add(ref inputRef, input1Idx)).AsByte(); Vector128<byte> input1 = Unsafe.As<uint, Vector128<uint>>(ref Unsafe.Add(ref inputRef, input1Idx)).AsByte();
Vector128<byte> r0 = Ssse3.Shuffle(input0, collectColorBlueTransformsShuffleLowMask); Vector128<byte> r0 = Ssse3.Shuffle(input0, collectColorBlueTransformsShuffleLowMask);
@ -146,10 +146,10 @@ internal static class ColorSpaceTransformUtils
{ {
Span<uint> srcSpan = bgra[(y * stride)..]; Span<uint> srcSpan = bgra[(y * stride)..];
ref uint inputRef = ref MemoryMarshal.GetReference(srcSpan); ref uint inputRef = ref MemoryMarshal.GetReference(srcSpan);
for (nint x = 0; x <= tileWidth - span; x += span) for (nuint x = 0; x <= (uint)tileWidth - span; x += span)
{ {
nint input0Idx = x; nuint input0Idx = x;
nint input1Idx = x + (span / 2); nuint input1Idx = x + (span / 2);
Vector256<byte> input0 = Unsafe.As<uint, Vector256<uint>>(ref Unsafe.Add(ref inputRef, input0Idx)).AsByte(); Vector256<byte> input0 = Unsafe.As<uint, Vector256<uint>>(ref Unsafe.Add(ref inputRef, input0Idx)).AsByte();
Vector256<byte> input1 = Unsafe.As<uint, Vector256<uint>>(ref Unsafe.Add(ref inputRef, input1Idx)).AsByte(); Vector256<byte> input1 = Unsafe.As<uint, Vector256<uint>>(ref Unsafe.Add(ref inputRef, input1Idx)).AsByte();
Vector256<byte> g0 = Avx2.And(input0, collectColorRedTransformsGreenMask256); // 0 0 | g 0 Vector256<byte> g0 = Avx2.And(input0, collectColorRedTransformsGreenMask256); // 0 0 | g 0
@ -189,10 +189,10 @@ internal static class ColorSpaceTransformUtils
{ {
Span<uint> srcSpan = bgra[(y * stride)..]; Span<uint> srcSpan = bgra[(y * stride)..];
ref uint inputRef = ref MemoryMarshal.GetReference(srcSpan); ref uint inputRef = ref MemoryMarshal.GetReference(srcSpan);
for (nint x = 0; x <= tileWidth - span; x += span) for (nuint x = 0; (int)x <= tileWidth - span; x += span)
{ {
nint input0Idx = x; nuint input0Idx = x;
nint input1Idx = x + (span / 2); nuint input1Idx = x + (span / 2);
Vector128<byte> input0 = Unsafe.As<uint, Vector128<uint>>(ref Unsafe.Add(ref inputRef, input0Idx)).AsByte(); Vector128<byte> input0 = Unsafe.As<uint, Vector128<uint>>(ref Unsafe.Add(ref inputRef, input0Idx)).AsByte();
Vector128<byte> input1 = Unsafe.As<uint, Vector128<uint>>(ref Unsafe.Add(ref inputRef, input1Idx)).AsByte(); Vector128<byte> input1 = Unsafe.As<uint, Vector128<uint>>(ref Unsafe.Add(ref inputRef, input1Idx)).AsByte();
Vector128<byte> g0 = Sse2.And(input0, collectColorRedTransformsGreenMask); // 0 0 | g 0 Vector128<byte> g0 = Sse2.And(input0, collectColorRedTransformsGreenMask); // 0 0 | g 0

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

@ -94,49 +94,53 @@ internal static unsafe class LosslessUtils
/// <param name="pixelData">The pixel data to apply the transformation.</param> /// <param name="pixelData">The pixel data to apply the transformation.</param>
public static void AddGreenToBlueAndRed(Span<uint> pixelData) public static void AddGreenToBlueAndRed(Span<uint> pixelData)
{ {
if (Avx2.IsSupported) if (Avx2.IsSupported && pixelData.Length >= 8)
{ {
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); 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; nuint numPixels = (uint)pixelData.Length;
nint i; nuint i = 0;
for (i = 0; i <= (nint)(uint)numPixels - 8; i += 8) do
{ {
ref uint pos = ref Unsafe.Add(ref MemoryMarshal.GetReference(pixelData), i); ref uint pos = ref Unsafe.Add(ref MemoryMarshal.GetReference(pixelData), i);
Vector256<byte> input = Unsafe.As<uint, Vector256<uint>>(ref pos).AsByte(); Vector256<byte> input = Unsafe.As<uint, Vector256<uint>>(ref pos).AsByte();
Vector256<byte> in0g0g = Avx2.Shuffle(input, addGreenToBlueAndRedMaskAvx2); Vector256<byte> in0g0g = Avx2.Shuffle(input, addGreenToBlueAndRedMaskAvx2);
Vector256<byte> output = Avx2.Add(input, in0g0g); Vector256<byte> output = Avx2.Add(input, in0g0g);
Unsafe.As<uint, Vector256<uint>>(ref pos) = output.AsUInt32(); Unsafe.As<uint, Vector256<uint>>(ref pos) = output.AsUInt32();
i += 8;
} }
while (i <= numPixels - 8);
if (i != numPixels) if (i != numPixels)
{ {
AddGreenToBlueAndRedScalar(pixelData[(int)i..]); AddGreenToBlueAndRedScalar(pixelData[(int)i..]);
} }
} }
else if (Ssse3.IsSupported) else if (Ssse3.IsSupported && pixelData.Length >= 4)
{ {
Vector128<byte> addGreenToBlueAndRedMaskSsse3 = Vector128.Create(1, 255, 1, 255, 5, 255, 5, 255, 9, 255, 9, 255, 13, 255, 13, 255); 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; nuint numPixels = (uint)pixelData.Length;
nint i; nuint i = 0;
for (i = 0; i <= (nint)(uint)numPixels - 4; i += 4) do
{ {
ref uint pos = ref Unsafe.Add(ref MemoryMarshal.GetReference(pixelData), i); ref uint pos = ref Unsafe.Add(ref MemoryMarshal.GetReference(pixelData), i);
Vector128<byte> input = Unsafe.As<uint, Vector128<uint>>(ref pos).AsByte(); Vector128<byte> input = Unsafe.As<uint, Vector128<uint>>(ref pos).AsByte();
Vector128<byte> in0g0g = Ssse3.Shuffle(input, addGreenToBlueAndRedMaskSsse3); Vector128<byte> in0g0g = Ssse3.Shuffle(input, addGreenToBlueAndRedMaskSsse3);
Vector128<byte> output = Sse2.Add(input, in0g0g); Vector128<byte> output = Sse2.Add(input, in0g0g);
Unsafe.As<uint, Vector128<uint>>(ref pos) = output.AsUInt32(); Unsafe.As<uint, Vector128<uint>>(ref pos) = output.AsUInt32();
i += 4;
} }
while (i <= numPixels - 4);
if (i != numPixels) if (i != numPixels)
{ {
AddGreenToBlueAndRedScalar(pixelData[(int)i..]); AddGreenToBlueAndRedScalar(pixelData[(int)i..]);
} }
} }
else if (Sse2.IsSupported) else if (Sse2.IsSupported && pixelData.Length >= 4)
{ {
int numPixels = pixelData.Length; nuint numPixels = (uint)pixelData.Length;
nint i; nuint i = 0;
for (i = 0; i <= (nint)(uint)numPixels - 4; i += 4) do
{ {
ref uint pos = ref Unsafe.Add(ref MemoryMarshal.GetReference(pixelData), i); ref uint pos = ref Unsafe.Add(ref MemoryMarshal.GetReference(pixelData), i);
Vector128<byte> input = Unsafe.As<uint, Vector128<uint>>(ref pos).AsByte(); Vector128<byte> input = Unsafe.As<uint, Vector128<uint>>(ref pos).AsByte();
@ -145,7 +149,9 @@ internal static unsafe class LosslessUtils
Vector128<ushort> c = Sse2.ShuffleHigh(b, SimdUtils.Shuffle.MMShuffle2200); // 0g0g Vector128<ushort> c = Sse2.ShuffleHigh(b, SimdUtils.Shuffle.MMShuffle2200); // 0g0g
Vector128<byte> output = Sse2.Add(input.AsByte(), c.AsByte()); Vector128<byte> output = Sse2.Add(input.AsByte(), c.AsByte());
Unsafe.As<uint, Vector128<uint>>(ref pos) = output.AsUInt32(); Unsafe.As<uint, Vector128<uint>>(ref pos) = output.AsUInt32();
i += 4;
} }
while (i <= numPixels - 4);
if (i != numPixels) if (i != numPixels)
{ {
@ -174,49 +180,53 @@ internal static unsafe class LosslessUtils
public static void SubtractGreenFromBlueAndRed(Span<uint> pixelData) public static void SubtractGreenFromBlueAndRed(Span<uint> pixelData)
{ {
if (Avx2.IsSupported) if (Avx2.IsSupported && pixelData.Length >= 8)
{ {
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); 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; nuint numPixels = (uint)pixelData.Length;
nint i; nuint i = 0;
for (i = 0; i <= (nint)(uint)numPixels - 8; i += 8) do
{ {
ref uint pos = ref Unsafe.Add(ref MemoryMarshal.GetReference(pixelData), i); ref uint pos = ref Unsafe.Add(ref MemoryMarshal.GetReference(pixelData), i);
Vector256<byte> input = Unsafe.As<uint, Vector256<uint>>(ref pos).AsByte(); Vector256<byte> input = Unsafe.As<uint, Vector256<uint>>(ref pos).AsByte();
Vector256<byte> in0g0g = Avx2.Shuffle(input, subtractGreenFromBlueAndRedMaskAvx2); Vector256<byte> in0g0g = Avx2.Shuffle(input, subtractGreenFromBlueAndRedMaskAvx2);
Vector256<byte> output = Avx2.Subtract(input, in0g0g); Vector256<byte> output = Avx2.Subtract(input, in0g0g);
Unsafe.As<uint, Vector256<uint>>(ref pos) = output.AsUInt32(); Unsafe.As<uint, Vector256<uint>>(ref pos) = output.AsUInt32();
i += 8;
} }
while (i <= numPixels - 8);
if (i != numPixels) if (i != numPixels)
{ {
SubtractGreenFromBlueAndRedScalar(pixelData[(int)i..]); SubtractGreenFromBlueAndRedScalar(pixelData[(int)i..]);
} }
} }
else if (Ssse3.IsSupported) else if (Ssse3.IsSupported && pixelData.Length >= 4)
{ {
Vector128<byte> subtractGreenFromBlueAndRedMaskSsse3 = Vector128.Create(1, 255, 1, 255, 5, 255, 5, 255, 9, 255, 9, 255, 13, 255, 13, 255); 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; nuint numPixels = (uint)pixelData.Length;
nint i; nuint i = 0;
for (i = 0; i <= (nint)(uint)numPixels - 4; i += 4) do
{ {
ref uint pos = ref Unsafe.Add(ref MemoryMarshal.GetReference(pixelData), i); ref uint pos = ref Unsafe.Add(ref MemoryMarshal.GetReference(pixelData), i);
Vector128<byte> input = Unsafe.As<uint, Vector128<uint>>(ref pos).AsByte(); Vector128<byte> input = Unsafe.As<uint, Vector128<uint>>(ref pos).AsByte();
Vector128<byte> in0g0g = Ssse3.Shuffle(input, subtractGreenFromBlueAndRedMaskSsse3); Vector128<byte> in0g0g = Ssse3.Shuffle(input, subtractGreenFromBlueAndRedMaskSsse3);
Vector128<byte> output = Sse2.Subtract(input, in0g0g); Vector128<byte> output = Sse2.Subtract(input, in0g0g);
Unsafe.As<uint, Vector128<uint>>(ref pos) = output.AsUInt32(); Unsafe.As<uint, Vector128<uint>>(ref pos) = output.AsUInt32();
i += 4;
} }
while (i <= numPixels - 4);
if (i != numPixels) if (i != numPixels)
{ {
SubtractGreenFromBlueAndRedScalar(pixelData[(int)i..]); SubtractGreenFromBlueAndRedScalar(pixelData[(int)i..]);
} }
} }
else if (Sse2.IsSupported) else if (Sse2.IsSupported && pixelData.Length >= 4)
{ {
int numPixels = pixelData.Length; nuint numPixels = (uint)pixelData.Length;
nint i; nuint i = 0;
for (i = 0; i <= (nint)(uint)numPixels - 4; i += 4) do
{ {
ref uint pos = ref Unsafe.Add(ref MemoryMarshal.GetReference(pixelData), i); ref uint pos = ref Unsafe.Add(ref MemoryMarshal.GetReference(pixelData), i);
Vector128<byte> input = Unsafe.As<uint, Vector128<uint>>(ref pos).AsByte(); Vector128<byte> input = Unsafe.As<uint, Vector128<uint>>(ref pos).AsByte();
@ -225,7 +235,9 @@ internal static unsafe class LosslessUtils
Vector128<ushort> c = Sse2.ShuffleHigh(b, SimdUtils.Shuffle.MMShuffle2200); // 0g0g Vector128<ushort> c = Sse2.ShuffleHigh(b, SimdUtils.Shuffle.MMShuffle2200); // 0g0g
Vector128<byte> output = Sse2.Subtract(input.AsByte(), c.AsByte()); Vector128<byte> output = Sse2.Subtract(input.AsByte(), c.AsByte());
Unsafe.As<uint, Vector128<uint>>(ref pos) = output.AsUInt32(); Unsafe.As<uint, Vector128<uint>>(ref pos) = output.AsUInt32();
i += 4;
} }
while (i <= numPixels - 4);
if (i != numPixels) if (i != numPixels)
{ {
@ -372,8 +384,8 @@ internal static unsafe class LosslessUtils
Vector256<int> multsrb = MkCst32(Cst5b(m.GreenToRed), Cst5b(m.GreenToBlue)); Vector256<int> multsrb = MkCst32(Cst5b(m.GreenToRed), Cst5b(m.GreenToBlue));
Vector256<int> multsb2 = MkCst32(Cst5b(m.RedToBlue), 0); Vector256<int> multsb2 = MkCst32(Cst5b(m.RedToBlue), 0);
nint idx; nuint idx = 0;
for (idx = 0; idx <= (nint)(uint)numPixels - 8; idx += 8) do
{ {
ref uint pos = ref Unsafe.Add(ref MemoryMarshal.GetReference(pixelData), idx); ref uint pos = ref Unsafe.Add(ref MemoryMarshal.GetReference(pixelData), idx);
Vector256<uint> input = Unsafe.As<uint, Vector256<uint>>(ref pos); Vector256<uint> input = Unsafe.As<uint, Vector256<uint>>(ref pos);
@ -388,21 +400,23 @@ internal static unsafe class LosslessUtils
Vector256<byte> i = Avx2.And(h, transformColorRedBlueMask256); Vector256<byte> i = Avx2.And(h, transformColorRedBlueMask256);
Vector256<byte> output = Avx2.Subtract(input.AsByte(), i); Vector256<byte> output = Avx2.Subtract(input.AsByte(), i);
Unsafe.As<uint, Vector256<uint>>(ref pos) = output.AsUInt32(); Unsafe.As<uint, Vector256<uint>>(ref pos) = output.AsUInt32();
idx += 8;
} }
while (idx <= (uint)numPixels - 8);
if (idx != numPixels) if (idx != (uint)numPixels)
{ {
TransformColorScalar(m, pixelData[(int)idx..], numPixels - (int)idx); TransformColorScalar(m, pixelData[(int)idx..], numPixels - (int)idx);
} }
} }
else if (Sse2.IsSupported) else if (Sse2.IsSupported && numPixels >= 4)
{ {
Vector128<byte> transformColorAlphaGreenMask = Vector128.Create(0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255); Vector128<byte> transformColorAlphaGreenMask = Vector128.Create(0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255);
Vector128<byte> transformColorRedBlueMask = Vector128.Create(255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0); Vector128<byte> transformColorRedBlueMask = Vector128.Create(255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0);
Vector128<int> multsrb = MkCst16(Cst5b(m.GreenToRed), Cst5b(m.GreenToBlue)); Vector128<int> multsrb = MkCst16(Cst5b(m.GreenToRed), Cst5b(m.GreenToBlue));
Vector128<int> multsb2 = MkCst16(Cst5b(m.RedToBlue), 0); Vector128<int> multsb2 = MkCst16(Cst5b(m.RedToBlue), 0);
nint idx; nuint idx = 0;
for (idx = 0; idx <= (nint)(uint)numPixels - 4; idx += 4) do
{ {
ref uint pos = ref Unsafe.Add(ref MemoryMarshal.GetReference(pixelData), idx); ref uint pos = ref Unsafe.Add(ref MemoryMarshal.GetReference(pixelData), idx);
Vector128<uint> input = Unsafe.As<uint, Vector128<uint>>(ref pos); Vector128<uint> input = Unsafe.As<uint, Vector128<uint>>(ref pos);
@ -417,9 +431,11 @@ internal static unsafe class LosslessUtils
Vector128<byte> i = Sse2.And(h, transformColorRedBlueMask); Vector128<byte> i = Sse2.And(h, transformColorRedBlueMask);
Vector128<byte> output = Sse2.Subtract(input.AsByte(), i); Vector128<byte> output = Sse2.Subtract(input.AsByte(), i);
Unsafe.As<uint, Vector128<uint>>(ref pos) = output.AsUInt32(); Unsafe.As<uint, Vector128<uint>>(ref pos) = output.AsUInt32();
idx += 4;
} }
while ((int)idx <= numPixels - 4);
if (idx != numPixels) if ((int)idx != numPixels)
{ {
TransformColorScalar(m, pixelData[(int)idx..], numPixels - (int)idx); TransformColorScalar(m, pixelData[(int)idx..], numPixels - (int)idx);
} }
@ -460,8 +476,8 @@ internal static unsafe class LosslessUtils
Vector256<byte> transformColorInverseAlphaGreenMask256 = Vector256.Create(0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255); Vector256<byte> transformColorInverseAlphaGreenMask256 = Vector256.Create(0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255);
Vector256<int> multsrb = MkCst32(Cst5b(m.GreenToRed), Cst5b(m.GreenToBlue)); Vector256<int> multsrb = MkCst32(Cst5b(m.GreenToRed), Cst5b(m.GreenToBlue));
Vector256<int> multsb2 = MkCst32(Cst5b(m.RedToBlue), 0); Vector256<int> multsb2 = MkCst32(Cst5b(m.RedToBlue), 0);
nint idx; nuint idx;
for (idx = 0; idx <= (nint)(uint)pixelData.Length - 8; idx += 8) for (idx = 0; idx <= (uint)pixelData.Length - 8; idx += 8)
{ {
ref uint pos = ref Unsafe.Add(ref MemoryMarshal.GetReference(pixelData), idx); ref uint pos = ref Unsafe.Add(ref MemoryMarshal.GetReference(pixelData), idx);
Vector256<uint> input = Unsafe.As<uint, Vector256<uint>>(ref pos); Vector256<uint> input = Unsafe.As<uint, Vector256<uint>>(ref pos);
@ -479,19 +495,19 @@ internal static unsafe class LosslessUtils
Unsafe.As<uint, Vector256<uint>>(ref pos) = output.AsUInt32(); Unsafe.As<uint, Vector256<uint>>(ref pos) = output.AsUInt32();
} }
if (idx != pixelData.Length) if (idx != (uint)pixelData.Length)
{ {
TransformColorInverseScalar(m, pixelData[(int)idx..]); TransformColorInverseScalar(m, pixelData[(int)idx..]);
} }
} }
else if (Sse2.IsSupported) else if (Sse2.IsSupported && pixelData.Length >= 4)
{ {
Vector128<byte> transformColorInverseAlphaGreenMask = Vector128.Create(0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255); Vector128<byte> transformColorInverseAlphaGreenMask = Vector128.Create(0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255);
Vector128<int> multsrb = MkCst16(Cst5b(m.GreenToRed), Cst5b(m.GreenToBlue)); Vector128<int> multsrb = MkCst16(Cst5b(m.GreenToRed), Cst5b(m.GreenToBlue));
Vector128<int> multsb2 = MkCst16(Cst5b(m.RedToBlue), 0); Vector128<int> multsb2 = MkCst16(Cst5b(m.RedToBlue), 0);
nint idx; nuint idx;
for (idx = 0; idx <= (nint)(uint)pixelData.Length - 4; idx += 4) for (idx = 0; idx <= (uint)pixelData.Length - 4; idx += 4)
{ {
ref uint pos = ref Unsafe.Add(ref MemoryMarshal.GetReference(pixelData), idx); ref uint pos = ref Unsafe.Add(ref MemoryMarshal.GetReference(pixelData), idx);
Vector128<uint> input = Unsafe.As<uint, Vector128<uint>>(ref pos); Vector128<uint> input = Unsafe.As<uint, Vector128<uint>>(ref pos);
@ -509,7 +525,7 @@ internal static unsafe class LosslessUtils
Unsafe.As<uint, Vector128<uint>>(ref pos) = output.AsUInt32(); Unsafe.As<uint, Vector128<uint>>(ref pos) = output.AsUInt32();
} }
if (idx != pixelData.Length) if (idx != (uint)pixelData.Length)
{ {
TransformColorInverseScalar(m, pixelData[(int)idx..]); TransformColorInverseScalar(m, pixelData[(int)idx..]);
} }
@ -740,7 +756,7 @@ internal static unsafe class LosslessUtils
Vector256<int> sumXY256 = Vector256<int>.Zero; Vector256<int> sumXY256 = Vector256<int>.Zero;
Vector256<int> sumX256 = Vector256<int>.Zero; Vector256<int> sumX256 = Vector256<int>.Zero;
ref int tmpRef = ref Unsafe.As<Vector256<int>, int>(ref tmp); ref int tmpRef = ref Unsafe.As<Vector256<int>, int>(ref tmp);
for (nint i = 0; i < 256; i += 8) for (nuint i = 0; i < 256; i += 8)
{ {
Vector256<int> xVec = Unsafe.As<int, Vector256<int>>(ref Unsafe.Add(ref xRef, i)); Vector256<int> xVec = Unsafe.As<int, Vector256<int>>(ref Unsafe.Add(ref xRef, i));
Vector256<int> yVec = Unsafe.As<int, Vector256<int>>(ref Unsafe.Add(ref yRef, i)); Vector256<int> yVec = Unsafe.As<int, Vector256<int>>(ref Unsafe.Add(ref yRef, i));

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

@ -518,9 +518,9 @@ internal sealed class Vp8LHistogram : IDeepCloneable
ref uint aRef = ref MemoryMarshal.GetReference(a); ref uint aRef = ref MemoryMarshal.GetReference(a);
ref uint bRef = ref MemoryMarshal.GetReference(b); ref uint bRef = ref MemoryMarshal.GetReference(b);
ref uint outputRef = ref MemoryMarshal.GetReference(output); ref uint outputRef = ref MemoryMarshal.GetReference(output);
nint idx; nuint idx;
for (idx = 0; idx <= (nint)(uint)count - 32; idx += 32) for (idx = 0; idx <= (uint)count - 32; idx += 32)
{ {
// Load values. // Load values.
Vector256<uint> a0 = Unsafe.As<uint, Vector256<uint>>(ref Unsafe.Add(ref aRef, idx)); Vector256<uint> a0 = Unsafe.As<uint, Vector256<uint>>(ref Unsafe.Add(ref aRef, idx));

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

@ -161,7 +161,7 @@ internal static class LossyUtils
private static int Vp8_Sse16xN_Sse2(Span<byte> a, Span<byte> b, int numPairs) private static int Vp8_Sse16xN_Sse2(Span<byte> a, Span<byte> b, int numPairs)
{ {
Vector128<int> sum = Vector128<int>.Zero; Vector128<int> sum = Vector128<int>.Zero;
nint offset = 0; nuint offset = 0;
ref byte aRef = ref MemoryMarshal.GetReference(a); ref byte aRef = ref MemoryMarshal.GetReference(a);
ref byte bRef = ref MemoryMarshal.GetReference(b); ref byte bRef = ref MemoryMarshal.GetReference(b);
for (int i = 0; i < numPairs; i++) for (int i = 0; i < numPairs; i++)
@ -186,7 +186,7 @@ internal static class LossyUtils
private static int Vp8_Sse16xN_Avx2(Span<byte> a, Span<byte> b, int numPairs) private static int Vp8_Sse16xN_Avx2(Span<byte> a, Span<byte> b, int numPairs)
{ {
Vector256<int> sum = Vector256<int>.Zero; Vector256<int> sum = Vector256<int>.Zero;
nint offset = 0; nuint offset = 0;
ref byte aRef = ref MemoryMarshal.GetReference(a); ref byte aRef = ref MemoryMarshal.GetReference(a);
ref byte bRef = ref MemoryMarshal.GetReference(b); ref byte bRef = ref MemoryMarshal.GetReference(b);
for (int i = 0; i < numPairs; i++) for (int i = 0; i < numPairs; i++)
@ -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 // 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 // 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 // q1 = f3 e3 d3 c3 b3 a3 93 83 f2 e2 d2 c2 b2 a2 92 82
Load8x4(ref r0, (nint)(uint)stride, out Vector128<byte> t1, out Vector128<byte> t2); Load8x4(ref r0, (uint)stride, out Vector128<byte> t1, out Vector128<byte> t2);
Load8x4(ref r8, (nint)(uint)stride, out p0, out q1); Load8x4(ref r8, (uint)stride, out p0, out q1);
// p1 = f0 e0 d0 c0 b0 a0 90 80 70 60 50 40 30 20 10 00 // 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 // 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. // Reads 8 rows across a vertical edge.
private static void Load8x4(ref byte bRef, nint stride, out Vector128<byte> p, out Vector128<byte> q) private static void Load8x4(ref byte bRef, nuint 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 // 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 // A1 = 73 72 71 70 33 32 31 30 53 52 51 50 13 12 11 10

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

@ -770,7 +770,7 @@ internal static unsafe class QuantEnc
{ {
uint v = src[0] * 0x01010101u; uint v = src[0] * 0x01010101u;
Span<byte> vSpan = BitConverter.GetBytes(v).AsSpan(); Span<byte> vSpan = BitConverter.GetBytes(v).AsSpan();
for (nint i = 0; i < 16; i++) for (nuint i = 0; i < 16; i++)
{ {
if (!src[..4].SequenceEqual(vSpan) || !src.Slice(4, 4).SequenceEqual(vSpan) || if (!src[..4].SequenceEqual(vSpan) || !src.Slice(4, 4).SequenceEqual(vSpan) ||
!src.Slice(8, 4).SequenceEqual(vSpan) || !src.Slice(12, 4).SequenceEqual(vSpan)) !src.Slice(8, 4).SequenceEqual(vSpan) || !src.Slice(12, 4).SequenceEqual(vSpan))
@ -789,10 +789,10 @@ internal static unsafe class QuantEnc
{ {
int score = 0; int score = 0;
ref short levelsRef = ref MemoryMarshal.GetReference(levels); ref short levelsRef = ref MemoryMarshal.GetReference(levels);
nint offset = 0; nuint offset = 0;
while (numBlocks-- > 0) while (numBlocks-- > 0)
{ {
for (nint i = 1; i < 16; i++) for (nuint i = 1; i < 16; i++)
{ {
// omit DC, we're only interested in AC // omit DC, we're only interested in AC
score += Unsafe.Add(ref levelsRef, offset) != 0 ? 1 : 0; score += Unsafe.Add(ref levelsRef, offset) != 0 ? 1 : 0;

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

@ -57,7 +57,7 @@ public partial struct Abgr32
{ {
Vector4Converters.RgbaCompatible.ToVector4(configuration, this, sourcePixels, destVectors, modifiers.Remove(PixelConversionModifiers.Scale)); Vector4Converters.RgbaCompatible.ToVector4(configuration, this, sourcePixels, destVectors, modifiers.Remove(PixelConversionModifiers.Scale));
} }
/// <inheritdoc /> /// <inheritdoc />
public override void ToRgba32( public override void ToRgba32(
Configuration configuration, Configuration configuration,
@ -71,7 +71,7 @@ public partial struct Abgr32
Span<byte> dest = MemoryMarshal.Cast<Rgba32, byte>(destinationPixels); Span<byte> dest = MemoryMarshal.Cast<Rgba32, byte>(destinationPixels);
PixelConverter.FromAbgr32.ToRgba32(source, dest); PixelConverter.FromAbgr32.ToRgba32(source, dest);
} }
/// <inheritdoc /> /// <inheritdoc />
public override void FromRgba32( public override void FromRgba32(
Configuration configuration, Configuration configuration,
@ -84,8 +84,8 @@ public partial struct Abgr32
ReadOnlySpan<byte> source = MemoryMarshal.Cast<Rgba32, byte>(sourcePixels); ReadOnlySpan<byte> source = MemoryMarshal.Cast<Rgba32, byte>(sourcePixels);
Span<byte> dest = MemoryMarshal.Cast<Abgr32, byte>(destinationPixels); Span<byte> dest = MemoryMarshal.Cast<Abgr32, byte>(destinationPixels);
PixelConverter.FromRgba32.ToAbgr32(source, dest); PixelConverter.FromRgba32.ToAbgr32(source, dest);
} }
/// <inheritdoc /> /// <inheritdoc />
public override void ToArgb32( public override void ToArgb32(
Configuration configuration, Configuration configuration,
@ -99,7 +99,7 @@ public partial struct Abgr32
Span<byte> dest = MemoryMarshal.Cast<Argb32, byte>(destinationPixels); Span<byte> dest = MemoryMarshal.Cast<Argb32, byte>(destinationPixels);
PixelConverter.FromAbgr32.ToArgb32(source, dest); PixelConverter.FromAbgr32.ToArgb32(source, dest);
} }
/// <inheritdoc /> /// <inheritdoc />
public override void FromArgb32( public override void FromArgb32(
Configuration configuration, Configuration configuration,
@ -112,8 +112,8 @@ public partial struct Abgr32
ReadOnlySpan<byte> source = MemoryMarshal.Cast<Argb32, byte>(sourcePixels); ReadOnlySpan<byte> source = MemoryMarshal.Cast<Argb32, byte>(sourcePixels);
Span<byte> dest = MemoryMarshal.Cast<Abgr32, byte>(destinationPixels); Span<byte> dest = MemoryMarshal.Cast<Abgr32, byte>(destinationPixels);
PixelConverter.FromArgb32.ToAbgr32(source, dest); PixelConverter.FromArgb32.ToAbgr32(source, dest);
} }
/// <inheritdoc /> /// <inheritdoc />
public override void ToBgra32( public override void ToBgra32(
Configuration configuration, Configuration configuration,
@ -127,7 +127,7 @@ public partial struct Abgr32
Span<byte> dest = MemoryMarshal.Cast<Bgra32, byte>(destinationPixels); Span<byte> dest = MemoryMarshal.Cast<Bgra32, byte>(destinationPixels);
PixelConverter.FromAbgr32.ToBgra32(source, dest); PixelConverter.FromAbgr32.ToBgra32(source, dest);
} }
/// <inheritdoc /> /// <inheritdoc />
public override void FromBgra32( public override void FromBgra32(
Configuration configuration, Configuration configuration,
@ -140,8 +140,8 @@ public partial struct Abgr32
ReadOnlySpan<byte> source = MemoryMarshal.Cast<Bgra32, byte>(sourcePixels); ReadOnlySpan<byte> source = MemoryMarshal.Cast<Bgra32, byte>(sourcePixels);
Span<byte> dest = MemoryMarshal.Cast<Abgr32, byte>(destinationPixels); Span<byte> dest = MemoryMarshal.Cast<Abgr32, byte>(destinationPixels);
PixelConverter.FromBgra32.ToAbgr32(source, dest); PixelConverter.FromBgra32.ToAbgr32(source, dest);
} }
/// <inheritdoc /> /// <inheritdoc />
public override void ToRgb24( public override void ToRgb24(
Configuration configuration, Configuration configuration,
@ -155,7 +155,7 @@ public partial struct Abgr32
Span<byte> dest = MemoryMarshal.Cast<Rgb24, byte>(destinationPixels); Span<byte> dest = MemoryMarshal.Cast<Rgb24, byte>(destinationPixels);
PixelConverter.FromAbgr32.ToRgb24(source, dest); PixelConverter.FromAbgr32.ToRgb24(source, dest);
} }
/// <inheritdoc /> /// <inheritdoc />
public override void FromRgb24( public override void FromRgb24(
Configuration configuration, Configuration configuration,
@ -168,8 +168,8 @@ public partial struct Abgr32
ReadOnlySpan<byte> source = MemoryMarshal.Cast<Rgb24, byte>(sourcePixels); ReadOnlySpan<byte> source = MemoryMarshal.Cast<Rgb24, byte>(sourcePixels);
Span<byte> dest = MemoryMarshal.Cast<Abgr32, byte>(destinationPixels); Span<byte> dest = MemoryMarshal.Cast<Abgr32, byte>(destinationPixels);
PixelConverter.FromRgb24.ToAbgr32(source, dest); PixelConverter.FromRgb24.ToAbgr32(source, dest);
} }
/// <inheritdoc /> /// <inheritdoc />
public override void ToBgr24( public override void ToBgr24(
Configuration configuration, Configuration configuration,
@ -183,7 +183,7 @@ public partial struct Abgr32
Span<byte> dest = MemoryMarshal.Cast<Bgr24, byte>(destinationPixels); Span<byte> dest = MemoryMarshal.Cast<Bgr24, byte>(destinationPixels);
PixelConverter.FromAbgr32.ToBgr24(source, dest); PixelConverter.FromAbgr32.ToBgr24(source, dest);
} }
/// <inheritdoc /> /// <inheritdoc />
public override void FromBgr24( public override void FromBgr24(
Configuration configuration, Configuration configuration,
@ -196,7 +196,7 @@ public partial struct Abgr32
ReadOnlySpan<byte> source = MemoryMarshal.Cast<Bgr24, byte>(sourcePixels); ReadOnlySpan<byte> source = MemoryMarshal.Cast<Bgr24, byte>(sourcePixels);
Span<byte> dest = MemoryMarshal.Cast<Abgr32, byte>(destinationPixels); Span<byte> dest = MemoryMarshal.Cast<Abgr32, byte>(destinationPixels);
PixelConverter.FromBgr24.ToAbgr32(source, dest); PixelConverter.FromBgr24.ToAbgr32(source, dest);
} }
/// <inheritdoc /> /// <inheritdoc />
public override void ToL8( public override void ToL8(
@ -210,7 +210,7 @@ public partial struct Abgr32
ref Abgr32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Abgr32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref L8 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref L8 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref Abgr32 sp = ref Unsafe.Add(ref sourceRef, i); ref Abgr32 sp = ref Unsafe.Add(ref sourceRef, i);
ref L8 dp = ref Unsafe.Add(ref destRef, 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 Abgr32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref L16 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref L16 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref Abgr32 sp = ref Unsafe.Add(ref sourceRef, i); ref Abgr32 sp = ref Unsafe.Add(ref sourceRef, i);
ref L16 dp = ref Unsafe.Add(ref destRef, 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 Abgr32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref La16 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref La16 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref Abgr32 sp = ref Unsafe.Add(ref sourceRef, i); ref Abgr32 sp = ref Unsafe.Add(ref sourceRef, i);
ref La16 dp = ref Unsafe.Add(ref destRef, 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 Abgr32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref La32 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref La32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref Abgr32 sp = ref Unsafe.Add(ref sourceRef, i); ref Abgr32 sp = ref Unsafe.Add(ref sourceRef, i);
ref La32 dp = ref Unsafe.Add(ref destRef, 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 Abgr32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgb48 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref Rgb48 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref Abgr32 sp = ref Unsafe.Add(ref sourceRef, i); ref Abgr32 sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgb48 dp = ref Unsafe.Add(ref destRef, 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 Abgr32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgba64 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref Rgba64 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref Abgr32 sp = ref Unsafe.Add(ref sourceRef, i); ref Abgr32 sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgba64 dp = ref Unsafe.Add(ref destRef, 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 Abgr32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref Abgr32 sp = ref Unsafe.Add(ref sourceRef, i); ref Abgr32 sp = ref Unsafe.Add(ref sourceRef, i);
ref Bgra5551 dp = ref Unsafe.Add(ref destRef, i); ref Bgra5551 dp = ref Unsafe.Add(ref destRef, i);

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

@ -57,7 +57,7 @@ public partial struct Argb32
{ {
Vector4Converters.RgbaCompatible.ToVector4(configuration, this, sourcePixels, destVectors, modifiers.Remove(PixelConversionModifiers.Scale)); Vector4Converters.RgbaCompatible.ToVector4(configuration, this, sourcePixels, destVectors, modifiers.Remove(PixelConversionModifiers.Scale));
} }
/// <inheritdoc /> /// <inheritdoc />
public override void ToRgba32( public override void ToRgba32(
Configuration configuration, Configuration configuration,
@ -71,7 +71,7 @@ public partial struct Argb32
Span<byte> dest = MemoryMarshal.Cast<Rgba32, byte>(destinationPixels); Span<byte> dest = MemoryMarshal.Cast<Rgba32, byte>(destinationPixels);
PixelConverter.FromArgb32.ToRgba32(source, dest); PixelConverter.FromArgb32.ToRgba32(source, dest);
} }
/// <inheritdoc /> /// <inheritdoc />
public override void FromRgba32( public override void FromRgba32(
Configuration configuration, Configuration configuration,
@ -84,8 +84,8 @@ public partial struct Argb32
ReadOnlySpan<byte> source = MemoryMarshal.Cast<Rgba32, byte>(sourcePixels); ReadOnlySpan<byte> source = MemoryMarshal.Cast<Rgba32, byte>(sourcePixels);
Span<byte> dest = MemoryMarshal.Cast<Argb32, byte>(destinationPixels); Span<byte> dest = MemoryMarshal.Cast<Argb32, byte>(destinationPixels);
PixelConverter.FromRgba32.ToArgb32(source, dest); PixelConverter.FromRgba32.ToArgb32(source, dest);
} }
/// <inheritdoc /> /// <inheritdoc />
public override void ToAbgr32( public override void ToAbgr32(
Configuration configuration, Configuration configuration,
@ -99,7 +99,7 @@ public partial struct Argb32
Span<byte> dest = MemoryMarshal.Cast<Abgr32, byte>(destinationPixels); Span<byte> dest = MemoryMarshal.Cast<Abgr32, byte>(destinationPixels);
PixelConverter.FromArgb32.ToAbgr32(source, dest); PixelConverter.FromArgb32.ToAbgr32(source, dest);
} }
/// <inheritdoc /> /// <inheritdoc />
public override void FromAbgr32( public override void FromAbgr32(
Configuration configuration, Configuration configuration,
@ -112,8 +112,8 @@ public partial struct Argb32
ReadOnlySpan<byte> source = MemoryMarshal.Cast<Abgr32, byte>(sourcePixels); ReadOnlySpan<byte> source = MemoryMarshal.Cast<Abgr32, byte>(sourcePixels);
Span<byte> dest = MemoryMarshal.Cast<Argb32, byte>(destinationPixels); Span<byte> dest = MemoryMarshal.Cast<Argb32, byte>(destinationPixels);
PixelConverter.FromAbgr32.ToArgb32(source, dest); PixelConverter.FromAbgr32.ToArgb32(source, dest);
} }
/// <inheritdoc /> /// <inheritdoc />
public override void ToBgra32( public override void ToBgra32(
Configuration configuration, Configuration configuration,
@ -127,7 +127,7 @@ public partial struct Argb32
Span<byte> dest = MemoryMarshal.Cast<Bgra32, byte>(destinationPixels); Span<byte> dest = MemoryMarshal.Cast<Bgra32, byte>(destinationPixels);
PixelConverter.FromArgb32.ToBgra32(source, dest); PixelConverter.FromArgb32.ToBgra32(source, dest);
} }
/// <inheritdoc /> /// <inheritdoc />
public override void FromBgra32( public override void FromBgra32(
Configuration configuration, Configuration configuration,
@ -140,8 +140,8 @@ public partial struct Argb32
ReadOnlySpan<byte> source = MemoryMarshal.Cast<Bgra32, byte>(sourcePixels); ReadOnlySpan<byte> source = MemoryMarshal.Cast<Bgra32, byte>(sourcePixels);
Span<byte> dest = MemoryMarshal.Cast<Argb32, byte>(destinationPixels); Span<byte> dest = MemoryMarshal.Cast<Argb32, byte>(destinationPixels);
PixelConverter.FromBgra32.ToArgb32(source, dest); PixelConverter.FromBgra32.ToArgb32(source, dest);
} }
/// <inheritdoc /> /// <inheritdoc />
public override void ToRgb24( public override void ToRgb24(
Configuration configuration, Configuration configuration,
@ -155,7 +155,7 @@ public partial struct Argb32
Span<byte> dest = MemoryMarshal.Cast<Rgb24, byte>(destinationPixels); Span<byte> dest = MemoryMarshal.Cast<Rgb24, byte>(destinationPixels);
PixelConverter.FromArgb32.ToRgb24(source, dest); PixelConverter.FromArgb32.ToRgb24(source, dest);
} }
/// <inheritdoc /> /// <inheritdoc />
public override void FromRgb24( public override void FromRgb24(
Configuration configuration, Configuration configuration,
@ -168,8 +168,8 @@ public partial struct Argb32
ReadOnlySpan<byte> source = MemoryMarshal.Cast<Rgb24, byte>(sourcePixels); ReadOnlySpan<byte> source = MemoryMarshal.Cast<Rgb24, byte>(sourcePixels);
Span<byte> dest = MemoryMarshal.Cast<Argb32, byte>(destinationPixels); Span<byte> dest = MemoryMarshal.Cast<Argb32, byte>(destinationPixels);
PixelConverter.FromRgb24.ToArgb32(source, dest); PixelConverter.FromRgb24.ToArgb32(source, dest);
} }
/// <inheritdoc /> /// <inheritdoc />
public override void ToBgr24( public override void ToBgr24(
Configuration configuration, Configuration configuration,
@ -183,7 +183,7 @@ public partial struct Argb32
Span<byte> dest = MemoryMarshal.Cast<Bgr24, byte>(destinationPixels); Span<byte> dest = MemoryMarshal.Cast<Bgr24, byte>(destinationPixels);
PixelConverter.FromArgb32.ToBgr24(source, dest); PixelConverter.FromArgb32.ToBgr24(source, dest);
} }
/// <inheritdoc /> /// <inheritdoc />
public override void FromBgr24( public override void FromBgr24(
Configuration configuration, Configuration configuration,
@ -196,7 +196,7 @@ public partial struct Argb32
ReadOnlySpan<byte> source = MemoryMarshal.Cast<Bgr24, byte>(sourcePixels); ReadOnlySpan<byte> source = MemoryMarshal.Cast<Bgr24, byte>(sourcePixels);
Span<byte> dest = MemoryMarshal.Cast<Argb32, byte>(destinationPixels); Span<byte> dest = MemoryMarshal.Cast<Argb32, byte>(destinationPixels);
PixelConverter.FromBgr24.ToArgb32(source, dest); PixelConverter.FromBgr24.ToArgb32(source, dest);
} }
/// <inheritdoc /> /// <inheritdoc />
public override void ToL8( public override void ToL8(
@ -210,7 +210,7 @@ public partial struct Argb32
ref Argb32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Argb32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref L8 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref L8 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref Argb32 sp = ref Unsafe.Add(ref sourceRef, i); ref Argb32 sp = ref Unsafe.Add(ref sourceRef, i);
ref L8 dp = ref Unsafe.Add(ref destRef, 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 Argb32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref L16 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref L16 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref Argb32 sp = ref Unsafe.Add(ref sourceRef, i); ref Argb32 sp = ref Unsafe.Add(ref sourceRef, i);
ref L16 dp = ref Unsafe.Add(ref destRef, 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 Argb32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref La16 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref La16 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref Argb32 sp = ref Unsafe.Add(ref sourceRef, i); ref Argb32 sp = ref Unsafe.Add(ref sourceRef, i);
ref La16 dp = ref Unsafe.Add(ref destRef, 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 Argb32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref La32 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref La32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref Argb32 sp = ref Unsafe.Add(ref sourceRef, i); ref Argb32 sp = ref Unsafe.Add(ref sourceRef, i);
ref La32 dp = ref Unsafe.Add(ref destRef, 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 Argb32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgb48 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref Rgb48 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref Argb32 sp = ref Unsafe.Add(ref sourceRef, i); ref Argb32 sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgb48 dp = ref Unsafe.Add(ref destRef, 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 Argb32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgba64 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref Rgba64 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref Argb32 sp = ref Unsafe.Add(ref sourceRef, i); ref Argb32 sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgba64 dp = ref Unsafe.Add(ref destRef, 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 Argb32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref Argb32 sp = ref Unsafe.Add(ref sourceRef, i); ref Argb32 sp = ref Unsafe.Add(ref sourceRef, i);
ref Bgra5551 dp = ref Unsafe.Add(ref destRef, i); ref Bgra5551 dp = ref Unsafe.Add(ref destRef, i);

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

@ -57,7 +57,7 @@ public partial struct Bgr24
{ {
Vector4Converters.RgbaCompatible.ToVector4(configuration, this, sourcePixels, destVectors, modifiers.Remove(PixelConversionModifiers.Scale | PixelConversionModifiers.Premultiply)); Vector4Converters.RgbaCompatible.ToVector4(configuration, this, sourcePixels, destVectors, modifiers.Remove(PixelConversionModifiers.Scale | PixelConversionModifiers.Premultiply));
} }
/// <inheritdoc /> /// <inheritdoc />
public override void ToRgba32( public override void ToRgba32(
Configuration configuration, Configuration configuration,
@ -71,7 +71,7 @@ public partial struct Bgr24
Span<byte> dest = MemoryMarshal.Cast<Rgba32, byte>(destinationPixels); Span<byte> dest = MemoryMarshal.Cast<Rgba32, byte>(destinationPixels);
PixelConverter.FromBgr24.ToRgba32(source, dest); PixelConverter.FromBgr24.ToRgba32(source, dest);
} }
/// <inheritdoc /> /// <inheritdoc />
public override void FromRgba32( public override void FromRgba32(
Configuration configuration, Configuration configuration,
@ -84,8 +84,8 @@ public partial struct Bgr24
ReadOnlySpan<byte> source = MemoryMarshal.Cast<Rgba32, byte>(sourcePixels); ReadOnlySpan<byte> source = MemoryMarshal.Cast<Rgba32, byte>(sourcePixels);
Span<byte> dest = MemoryMarshal.Cast<Bgr24, byte>(destinationPixels); Span<byte> dest = MemoryMarshal.Cast<Bgr24, byte>(destinationPixels);
PixelConverter.FromRgba32.ToBgr24(source, dest); PixelConverter.FromRgba32.ToBgr24(source, dest);
} }
/// <inheritdoc /> /// <inheritdoc />
public override void ToArgb32( public override void ToArgb32(
Configuration configuration, Configuration configuration,
@ -99,7 +99,7 @@ public partial struct Bgr24
Span<byte> dest = MemoryMarshal.Cast<Argb32, byte>(destinationPixels); Span<byte> dest = MemoryMarshal.Cast<Argb32, byte>(destinationPixels);
PixelConverter.FromBgr24.ToArgb32(source, dest); PixelConverter.FromBgr24.ToArgb32(source, dest);
} }
/// <inheritdoc /> /// <inheritdoc />
public override void FromArgb32( public override void FromArgb32(
Configuration configuration, Configuration configuration,
@ -112,8 +112,8 @@ public partial struct Bgr24
ReadOnlySpan<byte> source = MemoryMarshal.Cast<Argb32, byte>(sourcePixels); ReadOnlySpan<byte> source = MemoryMarshal.Cast<Argb32, byte>(sourcePixels);
Span<byte> dest = MemoryMarshal.Cast<Bgr24, byte>(destinationPixels); Span<byte> dest = MemoryMarshal.Cast<Bgr24, byte>(destinationPixels);
PixelConverter.FromArgb32.ToBgr24(source, dest); PixelConverter.FromArgb32.ToBgr24(source, dest);
} }
/// <inheritdoc /> /// <inheritdoc />
public override void ToAbgr32( public override void ToAbgr32(
Configuration configuration, Configuration configuration,
@ -127,7 +127,7 @@ public partial struct Bgr24
Span<byte> dest = MemoryMarshal.Cast<Abgr32, byte>(destinationPixels); Span<byte> dest = MemoryMarshal.Cast<Abgr32, byte>(destinationPixels);
PixelConverter.FromBgr24.ToAbgr32(source, dest); PixelConverter.FromBgr24.ToAbgr32(source, dest);
} }
/// <inheritdoc /> /// <inheritdoc />
public override void FromAbgr32( public override void FromAbgr32(
Configuration configuration, Configuration configuration,
@ -140,8 +140,8 @@ public partial struct Bgr24
ReadOnlySpan<byte> source = MemoryMarshal.Cast<Abgr32, byte>(sourcePixels); ReadOnlySpan<byte> source = MemoryMarshal.Cast<Abgr32, byte>(sourcePixels);
Span<byte> dest = MemoryMarshal.Cast<Bgr24, byte>(destinationPixels); Span<byte> dest = MemoryMarshal.Cast<Bgr24, byte>(destinationPixels);
PixelConverter.FromAbgr32.ToBgr24(source, dest); PixelConverter.FromAbgr32.ToBgr24(source, dest);
} }
/// <inheritdoc /> /// <inheritdoc />
public override void ToBgra32( public override void ToBgra32(
Configuration configuration, Configuration configuration,
@ -155,7 +155,7 @@ public partial struct Bgr24
Span<byte> dest = MemoryMarshal.Cast<Bgra32, byte>(destinationPixels); Span<byte> dest = MemoryMarshal.Cast<Bgra32, byte>(destinationPixels);
PixelConverter.FromBgr24.ToBgra32(source, dest); PixelConverter.FromBgr24.ToBgra32(source, dest);
} }
/// <inheritdoc /> /// <inheritdoc />
public override void FromBgra32( public override void FromBgra32(
Configuration configuration, Configuration configuration,
@ -168,8 +168,8 @@ public partial struct Bgr24
ReadOnlySpan<byte> source = MemoryMarshal.Cast<Bgra32, byte>(sourcePixels); ReadOnlySpan<byte> source = MemoryMarshal.Cast<Bgra32, byte>(sourcePixels);
Span<byte> dest = MemoryMarshal.Cast<Bgr24, byte>(destinationPixels); Span<byte> dest = MemoryMarshal.Cast<Bgr24, byte>(destinationPixels);
PixelConverter.FromBgra32.ToBgr24(source, dest); PixelConverter.FromBgra32.ToBgr24(source, dest);
} }
/// <inheritdoc /> /// <inheritdoc />
public override void ToRgb24( public override void ToRgb24(
Configuration configuration, Configuration configuration,
@ -183,7 +183,7 @@ public partial struct Bgr24
Span<byte> dest = MemoryMarshal.Cast<Rgb24, byte>(destinationPixels); Span<byte> dest = MemoryMarshal.Cast<Rgb24, byte>(destinationPixels);
PixelConverter.FromBgr24.ToRgb24(source, dest); PixelConverter.FromBgr24.ToRgb24(source, dest);
} }
/// <inheritdoc /> /// <inheritdoc />
public override void FromRgb24( public override void FromRgb24(
Configuration configuration, Configuration configuration,
@ -196,7 +196,7 @@ public partial struct Bgr24
ReadOnlySpan<byte> source = MemoryMarshal.Cast<Rgb24, byte>(sourcePixels); ReadOnlySpan<byte> source = MemoryMarshal.Cast<Rgb24, byte>(sourcePixels);
Span<byte> dest = MemoryMarshal.Cast<Bgr24, byte>(destinationPixels); Span<byte> dest = MemoryMarshal.Cast<Bgr24, byte>(destinationPixels);
PixelConverter.FromRgb24.ToBgr24(source, dest); PixelConverter.FromRgb24.ToBgr24(source, dest);
} }
/// <inheritdoc /> /// <inheritdoc />
public override void ToL8( public override void ToL8(
@ -210,7 +210,7 @@ public partial struct Bgr24
ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref L8 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref L8 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i);
ref L8 dp = ref Unsafe.Add(ref destRef, 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 Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref L16 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref L16 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i);
ref L16 dp = ref Unsafe.Add(ref destRef, 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 Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref La16 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref La16 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i);
ref La16 dp = ref Unsafe.Add(ref destRef, 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 Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref La32 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref La32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i);
ref La32 dp = ref Unsafe.Add(ref destRef, 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 Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgb48 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref Rgb48 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgb48 dp = ref Unsafe.Add(ref destRef, 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 Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgba64 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref Rgba64 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgba64 dp = ref Unsafe.Add(ref destRef, 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 Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i);
ref Bgra5551 dp = ref Unsafe.Add(ref destRef, i); ref Bgra5551 dp = ref Unsafe.Add(ref destRef, i);

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

@ -57,7 +57,7 @@ public partial struct Bgra32
{ {
Vector4Converters.RgbaCompatible.ToVector4(configuration, this, sourcePixels, destVectors, modifiers.Remove(PixelConversionModifiers.Scale)); Vector4Converters.RgbaCompatible.ToVector4(configuration, this, sourcePixels, destVectors, modifiers.Remove(PixelConversionModifiers.Scale));
} }
/// <inheritdoc /> /// <inheritdoc />
public override void ToRgba32( public override void ToRgba32(
Configuration configuration, Configuration configuration,
@ -71,7 +71,7 @@ public partial struct Bgra32
Span<byte> dest = MemoryMarshal.Cast<Rgba32, byte>(destinationPixels); Span<byte> dest = MemoryMarshal.Cast<Rgba32, byte>(destinationPixels);
PixelConverter.FromBgra32.ToRgba32(source, dest); PixelConverter.FromBgra32.ToRgba32(source, dest);
} }
/// <inheritdoc /> /// <inheritdoc />
public override void FromRgba32( public override void FromRgba32(
Configuration configuration, Configuration configuration,
@ -84,8 +84,8 @@ public partial struct Bgra32
ReadOnlySpan<byte> source = MemoryMarshal.Cast<Rgba32, byte>(sourcePixels); ReadOnlySpan<byte> source = MemoryMarshal.Cast<Rgba32, byte>(sourcePixels);
Span<byte> dest = MemoryMarshal.Cast<Bgra32, byte>(destinationPixels); Span<byte> dest = MemoryMarshal.Cast<Bgra32, byte>(destinationPixels);
PixelConverter.FromRgba32.ToBgra32(source, dest); PixelConverter.FromRgba32.ToBgra32(source, dest);
} }
/// <inheritdoc /> /// <inheritdoc />
public override void ToArgb32( public override void ToArgb32(
Configuration configuration, Configuration configuration,
@ -99,7 +99,7 @@ public partial struct Bgra32
Span<byte> dest = MemoryMarshal.Cast<Argb32, byte>(destinationPixels); Span<byte> dest = MemoryMarshal.Cast<Argb32, byte>(destinationPixels);
PixelConverter.FromBgra32.ToArgb32(source, dest); PixelConverter.FromBgra32.ToArgb32(source, dest);
} }
/// <inheritdoc /> /// <inheritdoc />
public override void FromArgb32( public override void FromArgb32(
Configuration configuration, Configuration configuration,
@ -112,8 +112,8 @@ public partial struct Bgra32
ReadOnlySpan<byte> source = MemoryMarshal.Cast<Argb32, byte>(sourcePixels); ReadOnlySpan<byte> source = MemoryMarshal.Cast<Argb32, byte>(sourcePixels);
Span<byte> dest = MemoryMarshal.Cast<Bgra32, byte>(destinationPixels); Span<byte> dest = MemoryMarshal.Cast<Bgra32, byte>(destinationPixels);
PixelConverter.FromArgb32.ToBgra32(source, dest); PixelConverter.FromArgb32.ToBgra32(source, dest);
} }
/// <inheritdoc /> /// <inheritdoc />
public override void ToAbgr32( public override void ToAbgr32(
Configuration configuration, Configuration configuration,
@ -127,7 +127,7 @@ public partial struct Bgra32
Span<byte> dest = MemoryMarshal.Cast<Abgr32, byte>(destinationPixels); Span<byte> dest = MemoryMarshal.Cast<Abgr32, byte>(destinationPixels);
PixelConverter.FromBgra32.ToAbgr32(source, dest); PixelConverter.FromBgra32.ToAbgr32(source, dest);
} }
/// <inheritdoc /> /// <inheritdoc />
public override void FromAbgr32( public override void FromAbgr32(
Configuration configuration, Configuration configuration,
@ -140,8 +140,8 @@ public partial struct Bgra32
ReadOnlySpan<byte> source = MemoryMarshal.Cast<Abgr32, byte>(sourcePixels); ReadOnlySpan<byte> source = MemoryMarshal.Cast<Abgr32, byte>(sourcePixels);
Span<byte> dest = MemoryMarshal.Cast<Bgra32, byte>(destinationPixels); Span<byte> dest = MemoryMarshal.Cast<Bgra32, byte>(destinationPixels);
PixelConverter.FromAbgr32.ToBgra32(source, dest); PixelConverter.FromAbgr32.ToBgra32(source, dest);
} }
/// <inheritdoc /> /// <inheritdoc />
public override void ToRgb24( public override void ToRgb24(
Configuration configuration, Configuration configuration,
@ -155,7 +155,7 @@ public partial struct Bgra32
Span<byte> dest = MemoryMarshal.Cast<Rgb24, byte>(destinationPixels); Span<byte> dest = MemoryMarshal.Cast<Rgb24, byte>(destinationPixels);
PixelConverter.FromBgra32.ToRgb24(source, dest); PixelConverter.FromBgra32.ToRgb24(source, dest);
} }
/// <inheritdoc /> /// <inheritdoc />
public override void FromRgb24( public override void FromRgb24(
Configuration configuration, Configuration configuration,
@ -168,8 +168,8 @@ public partial struct Bgra32
ReadOnlySpan<byte> source = MemoryMarshal.Cast<Rgb24, byte>(sourcePixels); ReadOnlySpan<byte> source = MemoryMarshal.Cast<Rgb24, byte>(sourcePixels);
Span<byte> dest = MemoryMarshal.Cast<Bgra32, byte>(destinationPixels); Span<byte> dest = MemoryMarshal.Cast<Bgra32, byte>(destinationPixels);
PixelConverter.FromRgb24.ToBgra32(source, dest); PixelConverter.FromRgb24.ToBgra32(source, dest);
} }
/// <inheritdoc /> /// <inheritdoc />
public override void ToBgr24( public override void ToBgr24(
Configuration configuration, Configuration configuration,
@ -183,7 +183,7 @@ public partial struct Bgra32
Span<byte> dest = MemoryMarshal.Cast<Bgr24, byte>(destinationPixels); Span<byte> dest = MemoryMarshal.Cast<Bgr24, byte>(destinationPixels);
PixelConverter.FromBgra32.ToBgr24(source, dest); PixelConverter.FromBgra32.ToBgr24(source, dest);
} }
/// <inheritdoc /> /// <inheritdoc />
public override void FromBgr24( public override void FromBgr24(
Configuration configuration, Configuration configuration,
@ -196,7 +196,7 @@ public partial struct Bgra32
ReadOnlySpan<byte> source = MemoryMarshal.Cast<Bgr24, byte>(sourcePixels); ReadOnlySpan<byte> source = MemoryMarshal.Cast<Bgr24, byte>(sourcePixels);
Span<byte> dest = MemoryMarshal.Cast<Bgra32, byte>(destinationPixels); Span<byte> dest = MemoryMarshal.Cast<Bgra32, byte>(destinationPixels);
PixelConverter.FromBgr24.ToBgra32(source, dest); PixelConverter.FromBgr24.ToBgra32(source, dest);
} }
/// <inheritdoc /> /// <inheritdoc />
public override void ToL8( public override void ToL8(
@ -210,7 +210,7 @@ public partial struct Bgra32
ref Bgra32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Bgra32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref L8 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref L8 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref Bgra32 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgra32 sp = ref Unsafe.Add(ref sourceRef, i);
ref L8 dp = ref Unsafe.Add(ref destRef, 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 Bgra32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref L16 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref L16 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref Bgra32 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgra32 sp = ref Unsafe.Add(ref sourceRef, i);
ref L16 dp = ref Unsafe.Add(ref destRef, 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 Bgra32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref La16 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref La16 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref Bgra32 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgra32 sp = ref Unsafe.Add(ref sourceRef, i);
ref La16 dp = ref Unsafe.Add(ref destRef, 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 Bgra32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref La32 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref La32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref Bgra32 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgra32 sp = ref Unsafe.Add(ref sourceRef, i);
ref La32 dp = ref Unsafe.Add(ref destRef, 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 Bgra32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgb48 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref Rgb48 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref Bgra32 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgra32 sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgb48 dp = ref Unsafe.Add(ref destRef, 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 Bgra32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgba64 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref Rgba64 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref Bgra32 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgra32 sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgba64 dp = ref Unsafe.Add(ref destRef, 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 Bgra32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref Bgra32 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgra32 sp = ref Unsafe.Add(ref sourceRef, i);
ref Bgra5551 dp = ref Unsafe.Add(ref destRef, 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 Bgra5551 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Argb32 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref Argb32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref Bgra5551 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgra5551 sp = ref Unsafe.Add(ref sourceRef, i);
ref Argb32 dp = ref Unsafe.Add(ref destRef, 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 Bgra5551 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Abgr32 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref Abgr32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref Bgra5551 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgra5551 sp = ref Unsafe.Add(ref sourceRef, i);
ref Abgr32 dp = ref Unsafe.Add(ref destRef, 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 Bgra5551 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Bgr24 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref Bgr24 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref Bgra5551 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgra5551 sp = ref Unsafe.Add(ref sourceRef, i);
ref Bgr24 dp = ref Unsafe.Add(ref destRef, 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 Bgra5551 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Bgra32 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref Bgra32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref Bgra5551 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgra5551 sp = ref Unsafe.Add(ref sourceRef, i);
ref Bgra32 dp = ref Unsafe.Add(ref destRef, 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 Bgra5551 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref L8 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref L8 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref Bgra5551 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgra5551 sp = ref Unsafe.Add(ref sourceRef, i);
ref L8 dp = ref Unsafe.Add(ref destRef, 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 Bgra5551 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref L16 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref L16 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref Bgra5551 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgra5551 sp = ref Unsafe.Add(ref sourceRef, i);
ref L16 dp = ref Unsafe.Add(ref destRef, 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 Bgra5551 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref La16 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref La16 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref Bgra5551 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgra5551 sp = ref Unsafe.Add(ref sourceRef, i);
ref La16 dp = ref Unsafe.Add(ref destRef, 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 Bgra5551 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref La32 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref La32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref Bgra5551 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgra5551 sp = ref Unsafe.Add(ref sourceRef, i);
ref La32 dp = ref Unsafe.Add(ref destRef, 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 Bgra5551 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgb24 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref Rgb24 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref Bgra5551 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgra5551 sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgb24 dp = ref Unsafe.Add(ref destRef, 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 Bgra5551 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgba32 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref Rgba32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref Bgra5551 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgra5551 sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgba32 dp = ref Unsafe.Add(ref destRef, 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 Bgra5551 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgb48 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref Rgb48 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref Bgra5551 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgra5551 sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgb48 dp = ref Unsafe.Add(ref destRef, 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 Bgra5551 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgba64 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref Rgba64 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref Bgra5551 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgra5551 sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgba64 dp = ref Unsafe.Add(ref destRef, 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 L16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Argb32 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref Argb32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref L16 sp = ref Unsafe.Add(ref sourceRef, i); ref L16 sp = ref Unsafe.Add(ref sourceRef, i);
ref Argb32 dp = ref Unsafe.Add(ref destRef, 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 L16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Abgr32 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref Abgr32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref L16 sp = ref Unsafe.Add(ref sourceRef, i); ref L16 sp = ref Unsafe.Add(ref sourceRef, i);
ref Abgr32 dp = ref Unsafe.Add(ref destRef, 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 L16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Bgr24 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref Bgr24 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref L16 sp = ref Unsafe.Add(ref sourceRef, i); ref L16 sp = ref Unsafe.Add(ref sourceRef, i);
ref Bgr24 dp = ref Unsafe.Add(ref destRef, 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 L16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Bgra32 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref Bgra32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref L16 sp = ref Unsafe.Add(ref sourceRef, i); ref L16 sp = ref Unsafe.Add(ref sourceRef, i);
ref Bgra32 dp = ref Unsafe.Add(ref destRef, 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 L16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref L8 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref L8 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref L16 sp = ref Unsafe.Add(ref sourceRef, i); ref L16 sp = ref Unsafe.Add(ref sourceRef, i);
ref L8 dp = ref Unsafe.Add(ref destRef, 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 L16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref La16 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref La16 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref L16 sp = ref Unsafe.Add(ref sourceRef, i); ref L16 sp = ref Unsafe.Add(ref sourceRef, i);
ref La16 dp = ref Unsafe.Add(ref destRef, 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 L16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref La32 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref La32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref L16 sp = ref Unsafe.Add(ref sourceRef, i); ref L16 sp = ref Unsafe.Add(ref sourceRef, i);
ref La32 dp = ref Unsafe.Add(ref destRef, 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 L16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgb24 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref Rgb24 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref L16 sp = ref Unsafe.Add(ref sourceRef, i); ref L16 sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgb24 dp = ref Unsafe.Add(ref destRef, 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 L16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgba32 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref Rgba32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref L16 sp = ref Unsafe.Add(ref sourceRef, i); ref L16 sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgba32 dp = ref Unsafe.Add(ref destRef, 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 L16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgb48 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref Rgb48 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref L16 sp = ref Unsafe.Add(ref sourceRef, i); ref L16 sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgb48 dp = ref Unsafe.Add(ref destRef, 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 L16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgba64 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref Rgba64 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref L16 sp = ref Unsafe.Add(ref sourceRef, i); ref L16 sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgba64 dp = ref Unsafe.Add(ref destRef, 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 L16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref L16 sp = ref Unsafe.Add(ref sourceRef, i); ref L16 sp = ref Unsafe.Add(ref sourceRef, i);
ref Bgra5551 dp = ref Unsafe.Add(ref destRef, 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 L8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Argb32 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref Argb32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref L8 sp = ref Unsafe.Add(ref sourceRef, i); ref L8 sp = ref Unsafe.Add(ref sourceRef, i);
ref Argb32 dp = ref Unsafe.Add(ref destRef, 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 L8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Abgr32 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref Abgr32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref L8 sp = ref Unsafe.Add(ref sourceRef, i); ref L8 sp = ref Unsafe.Add(ref sourceRef, i);
ref Abgr32 dp = ref Unsafe.Add(ref destRef, 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 L8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Bgr24 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref Bgr24 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref L8 sp = ref Unsafe.Add(ref sourceRef, i); ref L8 sp = ref Unsafe.Add(ref sourceRef, i);
ref Bgr24 dp = ref Unsafe.Add(ref destRef, 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 L8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Bgra32 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref Bgra32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref L8 sp = ref Unsafe.Add(ref sourceRef, i); ref L8 sp = ref Unsafe.Add(ref sourceRef, i);
ref Bgra32 dp = ref Unsafe.Add(ref destRef, 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 L8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref L16 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref L16 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref L8 sp = ref Unsafe.Add(ref sourceRef, i); ref L8 sp = ref Unsafe.Add(ref sourceRef, i);
ref L16 dp = ref Unsafe.Add(ref destRef, 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 L8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref La16 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref La16 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref L8 sp = ref Unsafe.Add(ref sourceRef, i); ref L8 sp = ref Unsafe.Add(ref sourceRef, i);
ref La16 dp = ref Unsafe.Add(ref destRef, 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 L8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref La32 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref La32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref L8 sp = ref Unsafe.Add(ref sourceRef, i); ref L8 sp = ref Unsafe.Add(ref sourceRef, i);
ref La32 dp = ref Unsafe.Add(ref destRef, 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 L8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgb24 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref Rgb24 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref L8 sp = ref Unsafe.Add(ref sourceRef, i); ref L8 sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgb24 dp = ref Unsafe.Add(ref destRef, 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 L8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgba32 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref Rgba32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref L8 sp = ref Unsafe.Add(ref sourceRef, i); ref L8 sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgba32 dp = ref Unsafe.Add(ref destRef, 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 L8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgb48 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref Rgb48 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref L8 sp = ref Unsafe.Add(ref sourceRef, i); ref L8 sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgb48 dp = ref Unsafe.Add(ref destRef, 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 L8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgba64 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref Rgba64 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref L8 sp = ref Unsafe.Add(ref sourceRef, i); ref L8 sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgba64 dp = ref Unsafe.Add(ref destRef, 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 L8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref L8 sp = ref Unsafe.Add(ref sourceRef, i); ref L8 sp = ref Unsafe.Add(ref sourceRef, i);
ref Bgra5551 dp = ref Unsafe.Add(ref destRef, i); ref Bgra5551 dp = ref Unsafe.Add(ref destRef, i);

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

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

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

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

@ -57,7 +57,7 @@ public partial struct Rgb24
{ {
Vector4Converters.RgbaCompatible.ToVector4(configuration, this, sourcePixels, destVectors, modifiers.Remove(PixelConversionModifiers.Scale | PixelConversionModifiers.Premultiply)); Vector4Converters.RgbaCompatible.ToVector4(configuration, this, sourcePixels, destVectors, modifiers.Remove(PixelConversionModifiers.Scale | PixelConversionModifiers.Premultiply));
} }
/// <inheritdoc /> /// <inheritdoc />
public override void ToRgba32( public override void ToRgba32(
Configuration configuration, Configuration configuration,
@ -71,7 +71,7 @@ public partial struct Rgb24
Span<byte> dest = MemoryMarshal.Cast<Rgba32, byte>(destinationPixels); Span<byte> dest = MemoryMarshal.Cast<Rgba32, byte>(destinationPixels);
PixelConverter.FromRgb24.ToRgba32(source, dest); PixelConverter.FromRgb24.ToRgba32(source, dest);
} }
/// <inheritdoc /> /// <inheritdoc />
public override void FromRgba32( public override void FromRgba32(
Configuration configuration, Configuration configuration,
@ -84,8 +84,8 @@ public partial struct Rgb24
ReadOnlySpan<byte> source = MemoryMarshal.Cast<Rgba32, byte>(sourcePixels); ReadOnlySpan<byte> source = MemoryMarshal.Cast<Rgba32, byte>(sourcePixels);
Span<byte> dest = MemoryMarshal.Cast<Rgb24, byte>(destinationPixels); Span<byte> dest = MemoryMarshal.Cast<Rgb24, byte>(destinationPixels);
PixelConverter.FromRgba32.ToRgb24(source, dest); PixelConverter.FromRgba32.ToRgb24(source, dest);
} }
/// <inheritdoc /> /// <inheritdoc />
public override void ToArgb32( public override void ToArgb32(
Configuration configuration, Configuration configuration,
@ -99,7 +99,7 @@ public partial struct Rgb24
Span<byte> dest = MemoryMarshal.Cast<Argb32, byte>(destinationPixels); Span<byte> dest = MemoryMarshal.Cast<Argb32, byte>(destinationPixels);
PixelConverter.FromRgb24.ToArgb32(source, dest); PixelConverter.FromRgb24.ToArgb32(source, dest);
} }
/// <inheritdoc /> /// <inheritdoc />
public override void FromArgb32( public override void FromArgb32(
Configuration configuration, Configuration configuration,
@ -112,8 +112,8 @@ public partial struct Rgb24
ReadOnlySpan<byte> source = MemoryMarshal.Cast<Argb32, byte>(sourcePixels); ReadOnlySpan<byte> source = MemoryMarshal.Cast<Argb32, byte>(sourcePixels);
Span<byte> dest = MemoryMarshal.Cast<Rgb24, byte>(destinationPixels); Span<byte> dest = MemoryMarshal.Cast<Rgb24, byte>(destinationPixels);
PixelConverter.FromArgb32.ToRgb24(source, dest); PixelConverter.FromArgb32.ToRgb24(source, dest);
} }
/// <inheritdoc /> /// <inheritdoc />
public override void ToAbgr32( public override void ToAbgr32(
Configuration configuration, Configuration configuration,
@ -127,7 +127,7 @@ public partial struct Rgb24
Span<byte> dest = MemoryMarshal.Cast<Abgr32, byte>(destinationPixels); Span<byte> dest = MemoryMarshal.Cast<Abgr32, byte>(destinationPixels);
PixelConverter.FromRgb24.ToAbgr32(source, dest); PixelConverter.FromRgb24.ToAbgr32(source, dest);
} }
/// <inheritdoc /> /// <inheritdoc />
public override void FromAbgr32( public override void FromAbgr32(
Configuration configuration, Configuration configuration,
@ -140,8 +140,8 @@ public partial struct Rgb24
ReadOnlySpan<byte> source = MemoryMarshal.Cast<Abgr32, byte>(sourcePixels); ReadOnlySpan<byte> source = MemoryMarshal.Cast<Abgr32, byte>(sourcePixels);
Span<byte> dest = MemoryMarshal.Cast<Rgb24, byte>(destinationPixels); Span<byte> dest = MemoryMarshal.Cast<Rgb24, byte>(destinationPixels);
PixelConverter.FromAbgr32.ToRgb24(source, dest); PixelConverter.FromAbgr32.ToRgb24(source, dest);
} }
/// <inheritdoc /> /// <inheritdoc />
public override void ToBgra32( public override void ToBgra32(
Configuration configuration, Configuration configuration,
@ -155,7 +155,7 @@ public partial struct Rgb24
Span<byte> dest = MemoryMarshal.Cast<Bgra32, byte>(destinationPixels); Span<byte> dest = MemoryMarshal.Cast<Bgra32, byte>(destinationPixels);
PixelConverter.FromRgb24.ToBgra32(source, dest); PixelConverter.FromRgb24.ToBgra32(source, dest);
} }
/// <inheritdoc /> /// <inheritdoc />
public override void FromBgra32( public override void FromBgra32(
Configuration configuration, Configuration configuration,
@ -168,8 +168,8 @@ public partial struct Rgb24
ReadOnlySpan<byte> source = MemoryMarshal.Cast<Bgra32, byte>(sourcePixels); ReadOnlySpan<byte> source = MemoryMarshal.Cast<Bgra32, byte>(sourcePixels);
Span<byte> dest = MemoryMarshal.Cast<Rgb24, byte>(destinationPixels); Span<byte> dest = MemoryMarshal.Cast<Rgb24, byte>(destinationPixels);
PixelConverter.FromBgra32.ToRgb24(source, dest); PixelConverter.FromBgra32.ToRgb24(source, dest);
} }
/// <inheritdoc /> /// <inheritdoc />
public override void ToBgr24( public override void ToBgr24(
Configuration configuration, Configuration configuration,
@ -183,7 +183,7 @@ public partial struct Rgb24
Span<byte> dest = MemoryMarshal.Cast<Bgr24, byte>(destinationPixels); Span<byte> dest = MemoryMarshal.Cast<Bgr24, byte>(destinationPixels);
PixelConverter.FromRgb24.ToBgr24(source, dest); PixelConverter.FromRgb24.ToBgr24(source, dest);
} }
/// <inheritdoc /> /// <inheritdoc />
public override void FromBgr24( public override void FromBgr24(
Configuration configuration, Configuration configuration,
@ -196,7 +196,7 @@ public partial struct Rgb24
ReadOnlySpan<byte> source = MemoryMarshal.Cast<Bgr24, byte>(sourcePixels); ReadOnlySpan<byte> source = MemoryMarshal.Cast<Bgr24, byte>(sourcePixels);
Span<byte> dest = MemoryMarshal.Cast<Rgb24, byte>(destinationPixels); Span<byte> dest = MemoryMarshal.Cast<Rgb24, byte>(destinationPixels);
PixelConverter.FromBgr24.ToRgb24(source, dest); PixelConverter.FromBgr24.ToRgb24(source, dest);
} }
/// <inheritdoc /> /// <inheritdoc />
public override void ToL8( public override void ToL8(
@ -210,7 +210,7 @@ public partial struct Rgb24
ref Rgb24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgb24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref L8 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref L8 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref Rgb24 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb24 sp = ref Unsafe.Add(ref sourceRef, i);
ref L8 dp = ref Unsafe.Add(ref destRef, 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 Rgb24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref L16 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref L16 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref Rgb24 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb24 sp = ref Unsafe.Add(ref sourceRef, i);
ref L16 dp = ref Unsafe.Add(ref destRef, 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 Rgb24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref La16 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref La16 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref Rgb24 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb24 sp = ref Unsafe.Add(ref sourceRef, i);
ref La16 dp = ref Unsafe.Add(ref destRef, 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 Rgb24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref La32 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref La32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref Rgb24 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb24 sp = ref Unsafe.Add(ref sourceRef, i);
ref La32 dp = ref Unsafe.Add(ref destRef, 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 Rgb24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgb48 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref Rgb48 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref Rgb24 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb24 sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgb48 dp = ref Unsafe.Add(ref destRef, 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 Rgb24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgba64 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref Rgba64 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref Rgb24 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb24 sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgba64 dp = ref Unsafe.Add(ref destRef, 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 Rgb24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref Rgb24 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb24 sp = ref Unsafe.Add(ref sourceRef, i);
ref Bgra5551 dp = ref Unsafe.Add(ref destRef, 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 Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Argb32 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref Argb32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i);
ref Argb32 dp = ref Unsafe.Add(ref destRef, 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 Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Abgr32 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref Abgr32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i);
ref Abgr32 dp = ref Unsafe.Add(ref destRef, 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 Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Bgr24 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref Bgr24 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i);
ref Bgr24 dp = ref Unsafe.Add(ref destRef, 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 Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Bgra32 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref Bgra32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i);
ref Bgra32 dp = ref Unsafe.Add(ref destRef, 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 Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref L8 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref L8 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i);
ref L8 dp = ref Unsafe.Add(ref destRef, 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 Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref L16 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref L16 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i);
ref L16 dp = ref Unsafe.Add(ref destRef, 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 Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref La16 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref La16 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i);
ref La16 dp = ref Unsafe.Add(ref destRef, 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 Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref La32 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref La32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i);
ref La32 dp = ref Unsafe.Add(ref destRef, 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 Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgb24 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref Rgb24 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgb24 dp = ref Unsafe.Add(ref destRef, 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 Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgba32 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref Rgba32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgba32 dp = ref Unsafe.Add(ref destRef, 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 Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgba64 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref Rgba64 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgba64 dp = ref Unsafe.Add(ref destRef, 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 Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i);
ref Bgra5551 dp = ref Unsafe.Add(ref destRef, i); ref Bgra5551 dp = ref Unsafe.Add(ref destRef, i);

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

@ -37,7 +37,7 @@ public partial struct Rgba32
sourcePixels.CopyTo(destinationPixels.Slice(0, sourcePixels.Length)); sourcePixels.CopyTo(destinationPixels.Slice(0, sourcePixels.Length));
} }
/// <inheritdoc /> /// <inheritdoc />
public override void ToArgb32( public override void ToArgb32(
Configuration configuration, Configuration configuration,
@ -51,7 +51,7 @@ public partial struct Rgba32
Span<byte> dest = MemoryMarshal.Cast<Argb32, byte>(destinationPixels); Span<byte> dest = MemoryMarshal.Cast<Argb32, byte>(destinationPixels);
PixelConverter.FromRgba32.ToArgb32(source, dest); PixelConverter.FromRgba32.ToArgb32(source, dest);
} }
/// <inheritdoc /> /// <inheritdoc />
public override void FromArgb32( public override void FromArgb32(
Configuration configuration, Configuration configuration,
@ -64,8 +64,8 @@ public partial struct Rgba32
ReadOnlySpan<byte> source = MemoryMarshal.Cast<Argb32, byte>(sourcePixels); ReadOnlySpan<byte> source = MemoryMarshal.Cast<Argb32, byte>(sourcePixels);
Span<byte> dest = MemoryMarshal.Cast<Rgba32, byte>(destinationPixels); Span<byte> dest = MemoryMarshal.Cast<Rgba32, byte>(destinationPixels);
PixelConverter.FromArgb32.ToRgba32(source, dest); PixelConverter.FromArgb32.ToRgba32(source, dest);
} }
/// <inheritdoc /> /// <inheritdoc />
public override void ToAbgr32( public override void ToAbgr32(
Configuration configuration, Configuration configuration,
@ -79,7 +79,7 @@ public partial struct Rgba32
Span<byte> dest = MemoryMarshal.Cast<Abgr32, byte>(destinationPixels); Span<byte> dest = MemoryMarshal.Cast<Abgr32, byte>(destinationPixels);
PixelConverter.FromRgba32.ToAbgr32(source, dest); PixelConverter.FromRgba32.ToAbgr32(source, dest);
} }
/// <inheritdoc /> /// <inheritdoc />
public override void FromAbgr32( public override void FromAbgr32(
Configuration configuration, Configuration configuration,
@ -92,8 +92,8 @@ public partial struct Rgba32
ReadOnlySpan<byte> source = MemoryMarshal.Cast<Abgr32, byte>(sourcePixels); ReadOnlySpan<byte> source = MemoryMarshal.Cast<Abgr32, byte>(sourcePixels);
Span<byte> dest = MemoryMarshal.Cast<Rgba32, byte>(destinationPixels); Span<byte> dest = MemoryMarshal.Cast<Rgba32, byte>(destinationPixels);
PixelConverter.FromAbgr32.ToRgba32(source, dest); PixelConverter.FromAbgr32.ToRgba32(source, dest);
} }
/// <inheritdoc /> /// <inheritdoc />
public override void ToBgra32( public override void ToBgra32(
Configuration configuration, Configuration configuration,
@ -107,7 +107,7 @@ public partial struct Rgba32
Span<byte> dest = MemoryMarshal.Cast<Bgra32, byte>(destinationPixels); Span<byte> dest = MemoryMarshal.Cast<Bgra32, byte>(destinationPixels);
PixelConverter.FromRgba32.ToBgra32(source, dest); PixelConverter.FromRgba32.ToBgra32(source, dest);
} }
/// <inheritdoc /> /// <inheritdoc />
public override void FromBgra32( public override void FromBgra32(
Configuration configuration, Configuration configuration,
@ -120,8 +120,8 @@ public partial struct Rgba32
ReadOnlySpan<byte> source = MemoryMarshal.Cast<Bgra32, byte>(sourcePixels); ReadOnlySpan<byte> source = MemoryMarshal.Cast<Bgra32, byte>(sourcePixels);
Span<byte> dest = MemoryMarshal.Cast<Rgba32, byte>(destinationPixels); Span<byte> dest = MemoryMarshal.Cast<Rgba32, byte>(destinationPixels);
PixelConverter.FromBgra32.ToRgba32(source, dest); PixelConverter.FromBgra32.ToRgba32(source, dest);
} }
/// <inheritdoc /> /// <inheritdoc />
public override void ToRgb24( public override void ToRgb24(
Configuration configuration, Configuration configuration,
@ -135,7 +135,7 @@ public partial struct Rgba32
Span<byte> dest = MemoryMarshal.Cast<Rgb24, byte>(destinationPixels); Span<byte> dest = MemoryMarshal.Cast<Rgb24, byte>(destinationPixels);
PixelConverter.FromRgba32.ToRgb24(source, dest); PixelConverter.FromRgba32.ToRgb24(source, dest);
} }
/// <inheritdoc /> /// <inheritdoc />
public override void FromRgb24( public override void FromRgb24(
Configuration configuration, Configuration configuration,
@ -148,8 +148,8 @@ public partial struct Rgba32
ReadOnlySpan<byte> source = MemoryMarshal.Cast<Rgb24, byte>(sourcePixels); ReadOnlySpan<byte> source = MemoryMarshal.Cast<Rgb24, byte>(sourcePixels);
Span<byte> dest = MemoryMarshal.Cast<Rgba32, byte>(destinationPixels); Span<byte> dest = MemoryMarshal.Cast<Rgba32, byte>(destinationPixels);
PixelConverter.FromRgb24.ToRgba32(source, dest); PixelConverter.FromRgb24.ToRgba32(source, dest);
} }
/// <inheritdoc /> /// <inheritdoc />
public override void ToBgr24( public override void ToBgr24(
Configuration configuration, Configuration configuration,
@ -163,7 +163,7 @@ public partial struct Rgba32
Span<byte> dest = MemoryMarshal.Cast<Bgr24, byte>(destinationPixels); Span<byte> dest = MemoryMarshal.Cast<Bgr24, byte>(destinationPixels);
PixelConverter.FromRgba32.ToBgr24(source, dest); PixelConverter.FromRgba32.ToBgr24(source, dest);
} }
/// <inheritdoc /> /// <inheritdoc />
public override void FromBgr24( public override void FromBgr24(
Configuration configuration, Configuration configuration,
@ -176,7 +176,7 @@ public partial struct Rgba32
ReadOnlySpan<byte> source = MemoryMarshal.Cast<Bgr24, byte>(sourcePixels); ReadOnlySpan<byte> source = MemoryMarshal.Cast<Bgr24, byte>(sourcePixels);
Span<byte> dest = MemoryMarshal.Cast<Rgba32, byte>(destinationPixels); Span<byte> dest = MemoryMarshal.Cast<Rgba32, byte>(destinationPixels);
PixelConverter.FromBgr24.ToRgba32(source, dest); PixelConverter.FromBgr24.ToRgba32(source, dest);
} }
/// <inheritdoc /> /// <inheritdoc />
public override void ToL8( public override void ToL8(
@ -190,7 +190,7 @@ public partial struct Rgba32
ref Rgba32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgba32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref L8 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref L8 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref Rgba32 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgba32 sp = ref Unsafe.Add(ref sourceRef, i);
ref L8 dp = ref Unsafe.Add(ref destRef, i); ref L8 dp = ref Unsafe.Add(ref destRef, i);
@ -211,7 +211,7 @@ public partial struct Rgba32
ref Rgba32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgba32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref L16 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref L16 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref Rgba32 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgba32 sp = ref Unsafe.Add(ref sourceRef, i);
ref L16 dp = ref Unsafe.Add(ref destRef, i); ref L16 dp = ref Unsafe.Add(ref destRef, i);
@ -232,7 +232,7 @@ public partial struct Rgba32
ref Rgba32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgba32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref La16 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref La16 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref Rgba32 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgba32 sp = ref Unsafe.Add(ref sourceRef, i);
ref La16 dp = ref Unsafe.Add(ref destRef, i); ref La16 dp = ref Unsafe.Add(ref destRef, i);
@ -253,7 +253,7 @@ public partial struct Rgba32
ref Rgba32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgba32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref La32 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref La32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref Rgba32 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgba32 sp = ref Unsafe.Add(ref sourceRef, i);
ref La32 dp = ref Unsafe.Add(ref destRef, i); ref La32 dp = ref Unsafe.Add(ref destRef, i);
@ -274,7 +274,7 @@ public partial struct Rgba32
ref Rgba32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgba32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgb48 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref Rgb48 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref Rgba32 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgba32 sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgb48 dp = ref Unsafe.Add(ref destRef, i); ref Rgb48 dp = ref Unsafe.Add(ref destRef, i);
@ -295,7 +295,7 @@ public partial struct Rgba32
ref Rgba32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgba32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgba64 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref Rgba64 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref Rgba32 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgba32 sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgba64 dp = ref Unsafe.Add(ref destRef, i); ref Rgba64 dp = ref Unsafe.Add(ref destRef, i);
@ -316,7 +316,7 @@ public partial struct Rgba32
ref Rgba32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgba32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref Rgba32 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgba32 sp = ref Unsafe.Add(ref sourceRef, i);
ref Bgra5551 dp = ref Unsafe.Add(ref destRef, i); ref Bgra5551 dp = ref Unsafe.Add(ref destRef, i);

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

@ -50,7 +50,7 @@ public partial struct Rgba64
ref Rgba64 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgba64 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Argb32 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref Argb32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref Rgba64 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgba64 sp = ref Unsafe.Add(ref sourceRef, i);
ref Argb32 dp = ref Unsafe.Add(ref destRef, i); ref Argb32 dp = ref Unsafe.Add(ref destRef, i);
@ -71,7 +71,7 @@ public partial struct Rgba64
ref Rgba64 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgba64 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Abgr32 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref Abgr32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref Rgba64 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgba64 sp = ref Unsafe.Add(ref sourceRef, i);
ref Abgr32 dp = ref Unsafe.Add(ref destRef, i); ref Abgr32 dp = ref Unsafe.Add(ref destRef, i);
@ -92,7 +92,7 @@ public partial struct Rgba64
ref Rgba64 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgba64 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Bgr24 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref Bgr24 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref Rgba64 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgba64 sp = ref Unsafe.Add(ref sourceRef, i);
ref Bgr24 dp = ref Unsafe.Add(ref destRef, i); ref Bgr24 dp = ref Unsafe.Add(ref destRef, i);
@ -113,7 +113,7 @@ public partial struct Rgba64
ref Rgba64 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgba64 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Bgra32 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref Bgra32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref Rgba64 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgba64 sp = ref Unsafe.Add(ref sourceRef, i);
ref Bgra32 dp = ref Unsafe.Add(ref destRef, i); ref Bgra32 dp = ref Unsafe.Add(ref destRef, i);
@ -134,7 +134,7 @@ public partial struct Rgba64
ref Rgba64 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgba64 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref L8 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref L8 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref Rgba64 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgba64 sp = ref Unsafe.Add(ref sourceRef, i);
ref L8 dp = ref Unsafe.Add(ref destRef, i); ref L8 dp = ref Unsafe.Add(ref destRef, i);
@ -155,7 +155,7 @@ public partial struct Rgba64
ref Rgba64 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgba64 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref L16 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref L16 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref Rgba64 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgba64 sp = ref Unsafe.Add(ref sourceRef, i);
ref L16 dp = ref Unsafe.Add(ref destRef, i); ref L16 dp = ref Unsafe.Add(ref destRef, i);
@ -176,7 +176,7 @@ public partial struct Rgba64
ref Rgba64 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgba64 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref La16 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref La16 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref Rgba64 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgba64 sp = ref Unsafe.Add(ref sourceRef, i);
ref La16 dp = ref Unsafe.Add(ref destRef, i); ref La16 dp = ref Unsafe.Add(ref destRef, i);
@ -197,7 +197,7 @@ public partial struct Rgba64
ref Rgba64 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgba64 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref La32 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref La32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref Rgba64 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgba64 sp = ref Unsafe.Add(ref sourceRef, i);
ref La32 dp = ref Unsafe.Add(ref destRef, i); ref La32 dp = ref Unsafe.Add(ref destRef, i);
@ -218,7 +218,7 @@ public partial struct Rgba64
ref Rgba64 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgba64 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgb24 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref Rgb24 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref Rgba64 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgba64 sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgb24 dp = ref Unsafe.Add(ref destRef, i); ref Rgb24 dp = ref Unsafe.Add(ref destRef, i);
@ -239,7 +239,7 @@ public partial struct Rgba64
ref Rgba64 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgba64 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgba32 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref Rgba32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref Rgba64 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgba64 sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgba32 dp = ref Unsafe.Add(ref destRef, i); ref Rgba32 dp = ref Unsafe.Add(ref destRef, i);
@ -260,7 +260,7 @@ public partial struct Rgba64
ref Rgba64 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgba64 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgb48 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref Rgb48 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref Rgba64 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgba64 sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgb48 dp = ref Unsafe.Add(ref destRef, i); ref Rgb48 dp = ref Unsafe.Add(ref destRef, i);
@ -281,7 +281,7 @@ public partial struct Rgba64
ref Rgba64 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgba64 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destinationPixels); ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref Rgba64 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgba64 sp = ref Unsafe.Add(ref sourceRef, i);
ref Bgra5551 dp = ref Unsafe.Add(ref destRef, 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 <#=fromPixelType#> sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref <#=toPixelType#> destRef = ref MemoryMarshal.GetReference(destinationPixels); ref <#=toPixelType#> destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref <#=fromPixelType#> sp = ref Unsafe.Add(ref sourceRef, i); ref <#=fromPixelType#> sp = ref Unsafe.Add(ref sourceRef, i);
ref <#=toPixelType#> dp = ref Unsafe.Add(ref destRef, 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 Vector4 sourceBaseRef = ref Unsafe.As<RgbaVector, Vector4>(ref MemoryMarshal.GetReference(sourcePixels));
ref L8 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); ref L8 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref Vector4 sp = ref Unsafe.Add(ref sourceBaseRef, i); ref Vector4 sp = ref Unsafe.Add(ref sourceBaseRef, i);
ref L8 dp = ref Unsafe.Add(ref destBaseRef, 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 Vector4 sourceBaseRef = ref Unsafe.As<RgbaVector, Vector4>(ref MemoryMarshal.GetReference(sourcePixels));
ref L16 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); ref L16 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref Vector4 sp = ref Unsafe.Add(ref sourceBaseRef, i); ref Vector4 sp = ref Unsafe.Add(ref sourceBaseRef, i);
ref L16 dp = ref Unsafe.Add(ref destBaseRef, 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 Argb32 sourceBaseRef = ref MemoryMarshal.GetReference(source);
ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)source.Length; i++) for (nuint i = 0; i < (uint)source.Length; i++)
{ {
ref Argb32 sp = ref Unsafe.Add(ref sourceBaseRef, i); ref Argb32 sp = ref Unsafe.Add(ref sourceBaseRef, i);
ref TPixel dp = ref Unsafe.Add(ref destBaseRef, 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 TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Argb32 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); ref Argb32 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref TPixel sp = ref Unsafe.Add(ref sourceBaseRef, i); ref TPixel sp = ref Unsafe.Add(ref sourceBaseRef, i);
ref Argb32 dp = ref Unsafe.Add(ref destBaseRef, 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 Abgr32 sourceBaseRef = ref MemoryMarshal.GetReference(source);
ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)source.Length; i++) for (nuint i = 0; i < (uint)source.Length; i++)
{ {
ref Abgr32 sp = ref Unsafe.Add(ref sourceBaseRef, i); ref Abgr32 sp = ref Unsafe.Add(ref sourceBaseRef, i);
ref TPixel dp = ref Unsafe.Add(ref destBaseRef, 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 TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Abgr32 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); ref Abgr32 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref TPixel sp = ref Unsafe.Add(ref sourceBaseRef, i); ref TPixel sp = ref Unsafe.Add(ref sourceBaseRef, i);
ref Abgr32 dp = ref Unsafe.Add(ref destBaseRef, 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 Bgr24 sourceBaseRef = ref MemoryMarshal.GetReference(source);
ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)source.Length; i++) for (nuint i = 0; i < (uint)source.Length; i++)
{ {
ref Bgr24 sp = ref Unsafe.Add(ref sourceBaseRef, i); ref Bgr24 sp = ref Unsafe.Add(ref sourceBaseRef, i);
ref TPixel dp = ref Unsafe.Add(ref destBaseRef, 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 TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Bgr24 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); ref Bgr24 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref TPixel sp = ref Unsafe.Add(ref sourceBaseRef, i); ref TPixel sp = ref Unsafe.Add(ref sourceBaseRef, i);
ref Bgr24 dp = ref Unsafe.Add(ref destBaseRef, 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 Bgra32 sourceBaseRef = ref MemoryMarshal.GetReference(source);
ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)source.Length; i++) for (nuint i = 0; i < (uint)source.Length; i++)
{ {
ref Bgra32 sp = ref Unsafe.Add(ref sourceBaseRef, i); ref Bgra32 sp = ref Unsafe.Add(ref sourceBaseRef, i);
ref TPixel dp = ref Unsafe.Add(ref destBaseRef, 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 TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Bgra32 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); ref Bgra32 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref TPixel sp = ref Unsafe.Add(ref sourceBaseRef, i); ref TPixel sp = ref Unsafe.Add(ref sourceBaseRef, i);
ref Bgra32 dp = ref Unsafe.Add(ref destBaseRef, 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 L8 sourceBaseRef = ref MemoryMarshal.GetReference(source);
ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)source.Length; i++) for (nuint i = 0; i < (uint)source.Length; i++)
{ {
ref L8 sp = ref Unsafe.Add(ref sourceBaseRef, i); ref L8 sp = ref Unsafe.Add(ref sourceBaseRef, i);
ref TPixel dp = ref Unsafe.Add(ref destBaseRef, 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 TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels);
ref L8 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); ref L8 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref TPixel sp = ref Unsafe.Add(ref sourceBaseRef, i); ref TPixel sp = ref Unsafe.Add(ref sourceBaseRef, i);
ref L8 dp = ref Unsafe.Add(ref destBaseRef, 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 L16 sourceBaseRef = ref MemoryMarshal.GetReference(source);
ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)source.Length; i++) for (nuint i = 0; i < (uint)source.Length; i++)
{ {
ref L16 sp = ref Unsafe.Add(ref sourceBaseRef, i); ref L16 sp = ref Unsafe.Add(ref sourceBaseRef, i);
ref TPixel dp = ref Unsafe.Add(ref destBaseRef, 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 TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels);
ref L16 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); ref L16 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref TPixel sp = ref Unsafe.Add(ref sourceBaseRef, i); ref TPixel sp = ref Unsafe.Add(ref sourceBaseRef, i);
ref L16 dp = ref Unsafe.Add(ref destBaseRef, 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 La16 sourceBaseRef = ref MemoryMarshal.GetReference(source);
ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)source.Length; i++) for (nuint i = 0; i < (uint)source.Length; i++)
{ {
ref La16 sp = ref Unsafe.Add(ref sourceBaseRef, i); ref La16 sp = ref Unsafe.Add(ref sourceBaseRef, i);
ref TPixel dp = ref Unsafe.Add(ref destBaseRef, 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 TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels);
ref La16 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); ref La16 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref TPixel sp = ref Unsafe.Add(ref sourceBaseRef, i); ref TPixel sp = ref Unsafe.Add(ref sourceBaseRef, i);
ref La16 dp = ref Unsafe.Add(ref destBaseRef, 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 La32 sourceBaseRef = ref MemoryMarshal.GetReference(source);
ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)source.Length; i++) for (nuint i = 0; i < (uint)source.Length; i++)
{ {
ref La32 sp = ref Unsafe.Add(ref sourceBaseRef, i); ref La32 sp = ref Unsafe.Add(ref sourceBaseRef, i);
ref TPixel dp = ref Unsafe.Add(ref destBaseRef, 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 TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels);
ref La32 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); ref La32 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref TPixel sp = ref Unsafe.Add(ref sourceBaseRef, i); ref TPixel sp = ref Unsafe.Add(ref sourceBaseRef, i);
ref La32 dp = ref Unsafe.Add(ref destBaseRef, 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 Rgb24 sourceBaseRef = ref MemoryMarshal.GetReference(source);
ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)source.Length; i++) for (nuint i = 0; i < (uint)source.Length; i++)
{ {
ref Rgb24 sp = ref Unsafe.Add(ref sourceBaseRef, i); ref Rgb24 sp = ref Unsafe.Add(ref sourceBaseRef, i);
ref TPixel dp = ref Unsafe.Add(ref destBaseRef, 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 TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgb24 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); ref Rgb24 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref TPixel sp = ref Unsafe.Add(ref sourceBaseRef, i); ref TPixel sp = ref Unsafe.Add(ref sourceBaseRef, i);
ref Rgb24 dp = ref Unsafe.Add(ref destBaseRef, 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 Rgba32 sourceBaseRef = ref MemoryMarshal.GetReference(source);
ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)source.Length; i++) for (nuint i = 0; i < (uint)source.Length; i++)
{ {
ref Rgba32 sp = ref Unsafe.Add(ref sourceBaseRef, i); ref Rgba32 sp = ref Unsafe.Add(ref sourceBaseRef, i);
ref TPixel dp = ref Unsafe.Add(ref destBaseRef, 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 TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgba32 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); ref Rgba32 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref TPixel sp = ref Unsafe.Add(ref sourceBaseRef, i); ref TPixel sp = ref Unsafe.Add(ref sourceBaseRef, i);
ref Rgba32 dp = ref Unsafe.Add(ref destBaseRef, 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 Rgb48 sourceBaseRef = ref MemoryMarshal.GetReference(source);
ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)source.Length; i++) for (nuint i = 0; i < (uint)source.Length; i++)
{ {
ref Rgb48 sp = ref Unsafe.Add(ref sourceBaseRef, i); ref Rgb48 sp = ref Unsafe.Add(ref sourceBaseRef, i);
ref TPixel dp = ref Unsafe.Add(ref destBaseRef, 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 TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgb48 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); ref Rgb48 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref TPixel sp = ref Unsafe.Add(ref sourceBaseRef, i); ref TPixel sp = ref Unsafe.Add(ref sourceBaseRef, i);
ref Rgb48 dp = ref Unsafe.Add(ref destBaseRef, 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 Rgba64 sourceBaseRef = ref MemoryMarshal.GetReference(source);
ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)source.Length; i++) for (nuint i = 0; i < (uint)source.Length; i++)
{ {
ref Rgba64 sp = ref Unsafe.Add(ref sourceBaseRef, i); ref Rgba64 sp = ref Unsafe.Add(ref sourceBaseRef, i);
ref TPixel dp = ref Unsafe.Add(ref destBaseRef, 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 TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgba64 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); ref Rgba64 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref TPixel sp = ref Unsafe.Add(ref sourceBaseRef, i); ref TPixel sp = ref Unsafe.Add(ref sourceBaseRef, i);
ref Rgba64 dp = ref Unsafe.Add(ref destBaseRef, 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 Bgra5551 sourceBaseRef = ref MemoryMarshal.GetReference(source);
ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)source.Length; i++) for (nuint i = 0; i < (uint)source.Length; i++)
{ {
ref Bgra5551 sp = ref Unsafe.Add(ref sourceBaseRef, i); ref Bgra5551 sp = ref Unsafe.Add(ref sourceBaseRef, i);
ref TPixel dp = ref Unsafe.Add(ref destBaseRef, 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 TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Bgra5551 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); ref Bgra5551 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref TPixel sp = ref Unsafe.Add(ref sourceBaseRef, i); ref TPixel sp = ref Unsafe.Add(ref sourceBaseRef, i);
ref Bgra5551 dp = ref Unsafe.Add(ref destBaseRef, 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 <#=pixelType#> sourceBaseRef = ref MemoryMarshal.GetReference(source);
ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)source.Length; i++) for (nuint i = 0; i < (uint)source.Length; i++)
{ {
ref <#=pixelType#> sp = ref Unsafe.Add(ref sourceBaseRef, i); ref <#=pixelType#> sp = ref Unsafe.Add(ref sourceBaseRef, i);
ref TPixel dp = ref Unsafe.Add(ref destBaseRef, i); ref TPixel dp = ref Unsafe.Add(ref destBaseRef, i);
@ -70,7 +70,7 @@
ref TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels); ref TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels);
ref <#=pixelType#> destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); ref <#=pixelType#> destBaseRef = ref MemoryMarshal.GetReference(destinationPixels);
for (nint i = 0; i < (uint)sourcePixels.Length; i++) for (nuint i = 0; i < (uint)sourcePixels.Length; i++)
{ {
ref TPixel sp = ref Unsafe.Add(ref sourceBaseRef, i); ref TPixel sp = ref Unsafe.Add(ref sourceBaseRef, i);
ref <#=pixelType#> dp = ref Unsafe.Add(ref destBaseRef, 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 byte b = ref MemoryMarshal.GetReference(blueChannel);
ref TPixel d = ref MemoryMarshal.GetReference(destination); ref TPixel d = ref MemoryMarshal.GetReference(destination);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
rgb24.R = Unsafe.Add(ref r, i); rgb24.R = Unsafe.Add(ref r, i);
rgb24.G = Unsafe.Add(ref g, 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 g = ref MemoryMarshal.GetReference(greenChannel);
ref float b = ref MemoryMarshal.GetReference(blueChannel); ref float b = ref MemoryMarshal.GetReference(blueChannel);
ref TPixel src = ref MemoryMarshal.GetReference(source); ref TPixel src = ref MemoryMarshal.GetReference(source);
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
Unsafe.Add(ref src, i).ToRgba32(ref rgba32); Unsafe.Add(ref src, i).ToRgba32(ref rgba32);
Unsafe.Add(ref r, i) = rgba32.R; Unsafe.Add(ref r, i) = rgba32.R;

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

@ -254,9 +254,9 @@ internal class AdaptiveHistogramEqualizationSlidingWindowProcessor<TPixel> : His
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
private static void AddPixelsToHistogram(ref Vector4 greyValuesBase, ref int histogramBase, int luminanceLevels, int length) private static void AddPixelsToHistogram(ref Vector4 greyValuesBase, ref int histogramBase, int luminanceLevels, int length)
{ {
for (nint idx = 0; idx < length; idx++) for (nuint idx = 0; idx < (uint)length; idx++)
{ {
int luminance = ColorNumerics.GetBT709Luminance(ref Unsafe.Add(ref greyValuesBase, (uint)idx), luminanceLevels); int luminance = ColorNumerics.GetBT709Luminance(ref Unsafe.Add(ref greyValuesBase, idx), luminanceLevels);
Unsafe.Add(ref histogramBase, (uint)luminance)++; Unsafe.Add(ref histogramBase, (uint)luminance)++;
} }
} }
@ -271,9 +271,9 @@ internal class AdaptiveHistogramEqualizationSlidingWindowProcessor<TPixel> : His
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
private static void RemovePixelsFromHistogram(ref Vector4 greyValuesBase, ref int histogramBase, int luminanceLevels, int length) private static void RemovePixelsFromHistogram(ref Vector4 greyValuesBase, ref int histogramBase, int luminanceLevels, int length)
{ {
for (int idx = 0; idx < length; idx++) for (nuint idx = 0; idx < (uint)length; idx++)
{ {
int luminance = ColorNumerics.GetBT709Luminance(ref Unsafe.Add(ref greyValuesBase, (uint)idx), luminanceLevels); int luminance = ColorNumerics.GetBT709Luminance(ref Unsafe.Add(ref greyValuesBase, idx), luminanceLevels);
Unsafe.Add(ref histogramBase, (uint)luminance)--; Unsafe.Add(ref histogramBase, (uint)luminance)--;
} }
} }

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

@ -73,7 +73,7 @@ internal abstract class HistogramEqualizationProcessor<TPixel> : ImageProcessor<
int cdfMin = 0; int cdfMin = 0;
bool cdfMinFound = false; bool cdfMinFound = false;
for (nint i = 0; i <= (uint)maxIdx; i++) for (nuint i = 0; i <= (uint)maxIdx; i++)
{ {
histSum += Unsafe.Add(ref histogramBase, i); histSum += Unsafe.Add(ref histogramBase, i);
if (!cdfMinFound && histSum != 0) if (!cdfMinFound && histSum != 0)
@ -101,7 +101,7 @@ internal abstract class HistogramEqualizationProcessor<TPixel> : ImageProcessor<
int sumOverClip = 0; int sumOverClip = 0;
ref int histogramBase = ref MemoryMarshal.GetReference(histogram); ref int histogramBase = ref MemoryMarshal.GetReference(histogram);
for (nint i = 0; i < (uint)histogram.Length; i++) for (nuint i = 0; i < (uint)histogram.Length; i++)
{ {
ref int histogramLevel = ref Unsafe.Add(ref histogramBase, i); ref int histogramLevel = ref Unsafe.Add(ref histogramBase, i);
if (histogramLevel > clipLimit) if (histogramLevel > clipLimit)
@ -115,7 +115,7 @@ internal abstract class HistogramEqualizationProcessor<TPixel> : ImageProcessor<
int addToEachBin = sumOverClip > 0 ? (int)MathF.Floor(sumOverClip / this.luminanceLevelsFloat) : 0; int addToEachBin = sumOverClip > 0 ? (int)MathF.Floor(sumOverClip / this.luminanceLevelsFloat) : 0;
if (addToEachBin > 0) if (addToEachBin > 0)
{ {
for (nint i = 0; i < (uint)histogram.Length; i++) for (nuint i = 0; i < (uint)histogram.Length; i++)
{ {
Unsafe.Add(ref histogramBase, i) += addToEachBin; Unsafe.Add(ref histogramBase, i) += addToEachBin;
} }
@ -124,8 +124,8 @@ internal abstract class HistogramEqualizationProcessor<TPixel> : ImageProcessor<
int residual = sumOverClip - (addToEachBin * this.LuminanceLevels); int residual = sumOverClip - (addToEachBin * this.LuminanceLevels);
if (residual != 0) if (residual != 0)
{ {
int residualStep = Math.Max(this.LuminanceLevels / residual, 1); uint residualStep = (uint)Math.Max(this.LuminanceLevels / residual, 1);
for (nint i = 0; i < (uint)this.LuminanceLevels && residual > 0; i += residualStep, residual--) for (nuint i = 0; i < (uint)this.LuminanceLevels && residual > 0; i += residualStep, residual--)
{ {
ref int histogramLevel = ref Unsafe.Add(ref histogramBase, i); ref int histogramLevel = ref Unsafe.Add(ref histogramBase, i);
histogramLevel++; histogramLevel++;

2
src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeKernelMap.cs

@ -100,7 +100,7 @@ internal partial class ResizeKernelMap : IDisposable
/// Returns a <see cref="ResizeKernel"/> for an index value between 0 and DestinationSize - 1. /// Returns a <see cref="ResizeKernel"/> for an index value between 0 and DestinationSize - 1.
/// </summary> /// </summary>
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
internal ref ResizeKernel GetKernel(nint destIdx) => ref this.kernels[destIdx]; internal ref ResizeKernel GetKernel(nuint destIdx) => ref this.kernels[(int)destIdx];
/// <summary> /// <summary>
/// Computes the weights to apply at each pixel when resizing. /// Computes the weights to apply at each pixel when resizing.

16
src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeWorker.cs

@ -119,7 +119,7 @@ internal sealed class ResizeWorker<TPixel> : IDisposable
for (int y = rowInterval.Min; y < rowInterval.Max; y++) for (int y = rowInterval.Min; y < rowInterval.Max; y++)
{ {
// Ensure offsets are normalized for cropping and padding. // Ensure offsets are normalized for cropping and padding.
ResizeKernel kernel = this.verticalKernelMap.GetKernel(y - this.targetOrigin.Y); ResizeKernel kernel = this.verticalKernelMap.GetKernel((uint)(y - this.targetOrigin.Y));
while (kernel.StartIndex + kernel.Length > this.currentWindow.Max) while (kernel.StartIndex + kernel.Length > this.currentWindow.Max)
{ {
@ -132,9 +132,9 @@ internal sealed class ResizeWorker<TPixel> : IDisposable
ref Vector4 fpBase = ref transposedFirstPassBufferSpan[top]; ref Vector4 fpBase = ref transposedFirstPassBufferSpan[top];
for (nint x = 0; x < (right - left); x++) for (nuint x = 0; x < (uint)(right - left); x++)
{ {
ref Vector4 firstPassColumnBase = ref Unsafe.Add(ref fpBase, x * (nint)(uint)this.workerHeight); ref Vector4 firstPassColumnBase = ref Unsafe.Add(ref fpBase, x * (uint)this.workerHeight);
// Destination color components // Destination color components
Unsafe.Add(ref tempRowBase, x) = kernel.ConvolveCore(ref firstPassColumnBase); Unsafe.Add(ref tempRowBase, x) = kernel.ConvolveCore(ref firstPassColumnBase);
@ -169,9 +169,9 @@ internal sealed class ResizeWorker<TPixel> : IDisposable
Span<Vector4> tempRowSpan = this.tempRowBuffer.GetSpan(); Span<Vector4> tempRowSpan = this.tempRowBuffer.GetSpan();
Span<Vector4> transposedFirstPassBufferSpan = this.transposedFirstPassBuffer.DangerousGetSingleSpan(); Span<Vector4> transposedFirstPassBufferSpan = this.transposedFirstPassBuffer.DangerousGetSingleSpan();
int left = this.targetWorkingRect.Left; nuint left = (uint)this.targetWorkingRect.Left;
int right = this.targetWorkingRect.Right; nuint right = (uint)this.targetWorkingRect.Right;
int targetOriginX = this.targetOrigin.X; nuint targetOriginX = (uint)this.targetOrigin.X;
for (int y = calculationInterval.Min; y < calculationInterval.Max; y++) for (int y = calculationInterval.Min; y < calculationInterval.Max; y++)
{ {
Span<TPixel> sourceRow = this.source.DangerousGetRowSpan(y); Span<TPixel> sourceRow = this.source.DangerousGetRowSpan(y);
@ -186,13 +186,13 @@ internal sealed class ResizeWorker<TPixel> : IDisposable
// Span<Vector4> firstPassSpan = transposedFirstPassBufferSpan.Slice(y - this.currentWindow.Min); // Span<Vector4> firstPassSpan = transposedFirstPassBufferSpan.Slice(y - this.currentWindow.Min);
ref Vector4 firstPassBaseRef = ref transposedFirstPassBufferSpan[y - this.currentWindow.Min]; ref Vector4 firstPassBaseRef = ref transposedFirstPassBufferSpan[y - this.currentWindow.Min];
for (nint x = left, z = 0; x < (nint)(uint)right; x++, z++) for (nuint x = left, z = 0; x < right; x++, z++)
{ {
ResizeKernel kernel = this.horizontalKernelMap.GetKernel(x - targetOriginX); ResizeKernel kernel = this.horizontalKernelMap.GetKernel(x - targetOriginX);
// optimization for: // optimization for:
// firstPassSpan[x * this.workerHeight] = kernel.Convolve(tempRowSpan); // firstPassSpan[x * this.workerHeight] = kernel.Convolve(tempRowSpan);
Unsafe.Add(ref firstPassBaseRef, z * (nint)(uint)this.workerHeight) = kernel.Convolve(tempRowSpan); Unsafe.Add(ref firstPassBaseRef, z * (uint)this.workerHeight) = kernel.Convolve(tempRowSpan);
} }
} }
} }

6
tests/ImageSharp.Benchmarks/Bulk/FromVector4.cs

@ -47,7 +47,7 @@ public abstract class FromVector4<TPixel>
{ {
ref Vector4 s = ref MemoryMarshal.GetReference(this.source.GetSpan()); ref Vector4 s = ref MemoryMarshal.GetReference(this.source.GetSpan());
ref TPixel d = ref MemoryMarshal.GetReference(this.destination.GetSpan()); ref TPixel d = ref MemoryMarshal.GetReference(this.destination.GetSpan());
for (nint i = 0; i < (uint)this.Count; i++) for (nuint i = 0; i < (uint)this.Count; i++)
{ {
Unsafe.Add(ref d, i).FromVector4(Unsafe.Add(ref s, i)); Unsafe.Add(ref d, i).FromVector4(Unsafe.Add(ref s, i));
} }
@ -103,7 +103,7 @@ public class FromVector4Rgba32 : FromVector4<Rgba32>
Span<float> src = MemoryMarshal.Cast<Vector4, float>(this.source.GetSpan()); Span<float> src = MemoryMarshal.Cast<Vector4, float>(this.source.GetSpan());
Span<byte> dest = MemoryMarshal.Cast<Rgba32, byte>(this.destination.GetSpan()); Span<byte> dest = MemoryMarshal.Cast<Rgba32, byte>(this.destination.GetSpan());
nint n = (nint)(uint)dest.Length / Vector<byte>.Count; nuint n = (uint)(dest.Length / Vector<byte>.Count);
ref Vector256<float> sourceBase = ref Vector256<float> sourceBase =
ref Unsafe.As<float, Vector256<float>>(ref MemoryMarshal.GetReference(src)); ref Unsafe.As<float, Vector256<float>>(ref MemoryMarshal.GetReference(src));
@ -114,7 +114,7 @@ public class FromVector4Rgba32 : FromVector4<Rgba32>
var maxBytes = Vector256.Create(255f); var maxBytes = Vector256.Create(255f);
for (nint i = 0; i < n; i++) for (nuint i = 0; i < n; i++)
{ {
ref Vector256<float> s = ref Unsafe.Add(ref sourceBase, i * 4); ref Vector256<float> s = ref Unsafe.Add(ref sourceBase, i * 4);

4
tests/ImageSharp.Benchmarks/Bulk/PremultiplyVector4.cs

@ -17,7 +17,7 @@ public class PremultiplyVector4
{ {
ref Vector4 baseRef = ref MemoryMarshal.GetReference<Vector4>(Vectors); ref Vector4 baseRef = ref MemoryMarshal.GetReference<Vector4>(Vectors);
for (nint i = 0; i < (uint)Vectors.Length; i++) for (nuint i = 0; i < (uint)Vectors.Length; i++)
{ {
ref Vector4 v = ref Unsafe.Add(ref baseRef, i); ref Vector4 v = ref Unsafe.Add(ref baseRef, i);
Premultiply(ref v); Premultiply(ref v);
@ -29,7 +29,7 @@ public class PremultiplyVector4
{ {
ref Vector4 baseRef = ref MemoryMarshal.GetReference<Vector4>(Vectors); ref Vector4 baseRef = ref MemoryMarshal.GetReference<Vector4>(Vectors);
for (nint i = 0; i < (uint)Vectors.Length; i++) for (nuint i = 0; i < (uint)Vectors.Length; i++)
{ {
ref Vector4 v = ref Unsafe.Add(ref baseRef, i); ref Vector4 v = ref Unsafe.Add(ref baseRef, i);
Numerics.Premultiply(ref v); Numerics.Premultiply(ref v);

12
tests/ImageSharp.Benchmarks/Bulk/ToVector4_Rgba32.cs

@ -54,13 +54,13 @@ public class ToVector4_Rgba32 : ToVector4<Rgba32>
Span<byte> sBytes = MemoryMarshal.Cast<Rgba32, byte>(this.source.GetSpan()); Span<byte> sBytes = MemoryMarshal.Cast<Rgba32, byte>(this.source.GetSpan());
Span<float> dFloats = MemoryMarshal.Cast<Vector4, float>(this.destination.GetSpan()); Span<float> dFloats = MemoryMarshal.Cast<Vector4, float>(this.destination.GetSpan());
nint n = (nint)(uint)dFloats.Length / Vector<byte>.Count; nuint n = (uint)(dFloats.Length / Vector<byte>.Count);
ref Vector<byte> sourceBase = ref Unsafe.As<byte, Vector<byte>>(ref MemoryMarshal.GetReference((ReadOnlySpan<byte>)sBytes)); ref Vector<byte> sourceBase = ref Unsafe.As<byte, Vector<byte>>(ref MemoryMarshal.GetReference((ReadOnlySpan<byte>)sBytes));
ref Vector<float> destBase = ref Unsafe.As<float, Vector<float>>(ref MemoryMarshal.GetReference(dFloats)); ref Vector<float> destBase = ref Unsafe.As<float, Vector<float>>(ref MemoryMarshal.GetReference(dFloats));
ref Vector<uint> destBaseU = ref Unsafe.As<Vector<float>, Vector<uint>>(ref destBase); ref Vector<uint> destBaseU = ref Unsafe.As<Vector<float>, Vector<uint>>(ref destBase);
for (nint i = 0; i < n; i++) for (nuint i = 0; i < n; i++)
{ {
Vector<byte> b = Unsafe.Add(ref sourceBase, i); Vector<byte> b = Unsafe.Add(ref sourceBase, i);
@ -75,10 +75,10 @@ public class ToVector4_Rgba32 : ToVector4<Rgba32>
Unsafe.Add(ref d, 3) = w3; Unsafe.Add(ref d, 3) = w3;
} }
n = (nint)(uint)dFloats.Length / Vector<float>.Count; n = (uint)(dFloats.Length / Vector<float>.Count);
var scale = new Vector<float>(1f / 255f); var scale = new Vector<float>(1f / 255f);
for (nint i = 0; i < n; i++) for (nuint i = 0; i < n; i++)
{ {
ref Vector<float> dRef = ref Unsafe.Add(ref destBase, i); ref Vector<float> dRef = ref Unsafe.Add(ref destBase, i);
@ -96,13 +96,13 @@ public class ToVector4_Rgba32 : ToVector4<Rgba32>
Span<byte> sBytes = MemoryMarshal.Cast<Rgba32, byte>(this.source.GetSpan()); Span<byte> sBytes = MemoryMarshal.Cast<Rgba32, byte>(this.source.GetSpan());
Span<float> dFloats = MemoryMarshal.Cast<Vector4, float>(this.destination.GetSpan()); Span<float> dFloats = MemoryMarshal.Cast<Vector4, float>(this.destination.GetSpan());
nint n = (nint)(uint)dFloats.Length / Vector<byte>.Count; nuint n = (uint)(dFloats.Length / Vector<byte>.Count);
ref Vector<byte> sourceBase = ref Unsafe.As<byte, Vector<byte>>(ref MemoryMarshal.GetReference((ReadOnlySpan<byte>)sBytes)); ref Vector<byte> sourceBase = ref Unsafe.As<byte, Vector<byte>>(ref MemoryMarshal.GetReference((ReadOnlySpan<byte>)sBytes));
ref Vector<float> destBase = ref Unsafe.As<float, Vector<float>>(ref MemoryMarshal.GetReference(dFloats)); ref Vector<float> destBase = ref Unsafe.As<float, Vector<float>>(ref MemoryMarshal.GetReference(dFloats));
var scale = new Vector<float>(1f / 255f); var scale = new Vector<float>(1f / 255f);
for (nint i = 0; i < n; i++) for (nuint i = 0; i < n; i++)
{ {
Vector<byte> b = Unsafe.Add(ref sourceBase, i); Vector<byte> b = Unsafe.Add(ref sourceBase, i);

4
tests/ImageSharp.Benchmarks/Bulk/UnPremultiplyVector4.cs

@ -17,7 +17,7 @@ public class UnPremultiplyVector4
{ {
ref Vector4 baseRef = ref MemoryMarshal.GetReference<Vector4>(Vectors); ref Vector4 baseRef = ref MemoryMarshal.GetReference<Vector4>(Vectors);
for (nint i = 0; i < (uint)Vectors.Length; i++) for (nuint i = 0; i < (uint)Vectors.Length; i++)
{ {
ref Vector4 v = ref Unsafe.Add(ref baseRef, i); ref Vector4 v = ref Unsafe.Add(ref baseRef, i);
@ -30,7 +30,7 @@ public class UnPremultiplyVector4
{ {
ref Vector4 baseRef = ref MemoryMarshal.GetReference<Vector4>(Vectors); ref Vector4 baseRef = ref MemoryMarshal.GetReference<Vector4>(Vectors);
for (nint i = 0; i < (uint)Vectors.Length; i++) for (nuint i = 0; i < (uint)Vectors.Length; i++)
{ {
ref Vector4 v = ref Unsafe.Add(ref baseRef, i); ref Vector4 v = ref Unsafe.Add(ref baseRef, i);
Numerics.UnPremultiply(ref v); Numerics.UnPremultiply(ref v);

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

@ -82,7 +82,7 @@ public unsafe class Block8x8F_CopyTo1x1
{ {
ref Block8x8F s = ref this.block; ref Block8x8F s = ref this.block;
ref float origin = ref Unsafe.AsRef<float>(this.bufferPtr); ref float origin = ref Unsafe.AsRef<float>(this.bufferPtr);
nint stride = (nint)(uint)Width; nuint stride = (uint)Width;
ref Vector<float> d0 = ref Unsafe.As<float, Vector<float>>(ref origin); ref Vector<float> d0 = ref Unsafe.As<float, Vector<float>>(ref origin);
ref Vector<float> d1 = ref Unsafe.As<float, Vector<float>>(ref Unsafe.Add(ref origin, stride)); ref Vector<float> d1 = ref Unsafe.As<float, Vector<float>>(ref Unsafe.Add(ref origin, stride));
@ -117,7 +117,7 @@ public unsafe class Block8x8F_CopyTo1x1
{ {
ref Block8x8F s = ref this.block; ref Block8x8F s = ref this.block;
ref float origin = ref Unsafe.AsRef<float>(this.bufferPtr); ref float origin = ref Unsafe.AsRef<float>(this.bufferPtr);
nint stride = (nint)(uint)Width; nuint stride = (uint)Width;
ref Vector<float> d0 = ref Unsafe.As<float, Vector<float>>(ref origin); ref Vector<float> d0 = ref Unsafe.As<float, Vector<float>>(ref origin);
ref Vector<float> d1 = ref Unsafe.As<float, Vector<float>>(ref Unsafe.Add(ref origin, stride)); ref Vector<float> d1 = ref Unsafe.As<float, Vector<float>>(ref Unsafe.Add(ref origin, stride));
@ -141,7 +141,7 @@ public unsafe class Block8x8F_CopyTo1x1
[Benchmark] [Benchmark]
public void UseVector8_V3() public void UseVector8_V3()
{ {
nint stride = (nint)(uint)Width * sizeof(float); nuint stride = (uint)Width * sizeof(float);
ref float d = ref this.unpinnedBuffer[0]; ref float d = ref this.unpinnedBuffer[0];
ref Vector<float> s = ref Unsafe.As<Block8x8F, Vector<float>>(ref this.block); ref Vector<float> s = ref Unsafe.As<Block8x8F, Vector<float>>(ref this.block);
@ -254,7 +254,7 @@ public unsafe class Block8x8F_CopyTo1x1
[Benchmark] [Benchmark]
public void UseVector256_Avx2_Variant3_RefCast() public void UseVector256_Avx2_Variant3_RefCast()
{ {
nint stride = (nint)(uint)Width; nuint stride = (uint)Width;
ref float d = ref this.unpinnedBuffer[0]; ref float d = ref this.unpinnedBuffer[0];
ref Vector256<float> s = ref Unsafe.As<Block8x8F, Vector256<float>>(ref this.block); ref Vector256<float> s = ref Unsafe.As<Block8x8F, Vector256<float>>(ref this.block);
@ -282,7 +282,7 @@ public unsafe class Block8x8F_CopyTo1x1
[Benchmark] [Benchmark]
public void UseVector256_Avx2_Variant3_RefCast_Mod() public void UseVector256_Avx2_Variant3_RefCast_Mod()
{ {
nint stride = (nint)(uint)Width * sizeof(float); nuint stride = (uint)Width * sizeof(float);
ref float d = ref this.unpinnedBuffer[0]; ref float d = ref this.unpinnedBuffer[0];
ref Vector256<float> s = ref Unsafe.As<Block8x8F, Vector256<float>>(ref this.block); ref Vector256<float> s = ref Unsafe.As<Block8x8F, Vector256<float>>(ref this.block);

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

@ -54,7 +54,7 @@ public unsafe class Block8x8F_Round
{ {
ref float b = ref Unsafe.As<Block8x8F, float>(ref this.block); ref float b = ref Unsafe.As<Block8x8F, float>(ref this.block);
for (nint i = 0; i < Block8x8F.Size; i++) for (nuint i = 0; i < Block8x8F.Size; i++)
{ {
ref float v = ref Unsafe.Add(ref b, i); ref float v = ref Unsafe.Add(ref b, i);
v = (float)Math.Round(v); v = (float)Math.Round(v);
@ -178,7 +178,7 @@ public unsafe class Block8x8F_Round
{ {
ref Vector128<float> p = ref Unsafe.As<Block8x8F, Vector128<float>>(ref this.block); ref Vector128<float> p = ref Unsafe.As<Block8x8F, Vector128<float>>(ref this.block);
p = Sse41.RoundToNearestInteger(p); p = Sse41.RoundToNearestInteger(p);
nint offset = sizeof(Vector128<float>); nuint offset = (uint)sizeof(Vector128<float>);
p = Sse41.RoundToNearestInteger(p); p = Sse41.RoundToNearestInteger(p);
p = ref Unsafe.AddByteOffset(ref p, offset); p = ref Unsafe.AddByteOffset(ref p, offset);
@ -218,7 +218,7 @@ public unsafe class Block8x8F_Round
{ {
ref Vector128<float> p = ref Unsafe.As<Block8x8F, Vector128<float>>(ref this.block); ref Vector128<float> p = ref Unsafe.As<Block8x8F, Vector128<float>>(ref this.block);
p = Sse41.RoundToNearestInteger(p); p = Sse41.RoundToNearestInteger(p);
nint offset = sizeof(Vector128<float>); nuint offset = (uint)sizeof(Vector128<float>);
for (int i = 0; i < 15; i++) for (int i = 0; i < 15; i++)
{ {
@ -231,7 +231,7 @@ public unsafe class Block8x8F_Round
public unsafe void Sse41_V4() public unsafe void Sse41_V4()
{ {
ref Vector128<float> p = ref Unsafe.As<Block8x8F, Vector128<float>>(ref this.block); ref Vector128<float> p = ref Unsafe.As<Block8x8F, Vector128<float>>(ref this.block);
nint offset = sizeof(Vector128<float>); nuint offset = (uint)sizeof(Vector128<float>);
ref Vector128<float> a = ref p; ref Vector128<float> a = ref p;
ref Vector128<float> b = ref Unsafe.AddByteOffset(ref a, offset); ref Vector128<float> b = ref Unsafe.AddByteOffset(ref a, offset);

10
tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertFromRgba32.cs

@ -34,7 +34,7 @@ public abstract class PixelConversion_ConvertFromRgba32
ref T destBaseRef = ref this.Dest[0]; ref T destBaseRef = ref this.Dest[0];
ref Rgba32 sourceBaseRef = ref this.Source[0]; ref Rgba32 sourceBaseRef = ref this.Source[0];
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
Unsafe.Add(ref destBaseRef, i).FromRgba32(ref Unsafe.Add(ref sourceBaseRef, i)); Unsafe.Add(ref destBaseRef, i).FromRgba32(ref Unsafe.Add(ref sourceBaseRef, i));
} }
@ -48,7 +48,7 @@ public abstract class PixelConversion_ConvertFromRgba32
ref T destBaseRef = ref this.Dest[0]; ref T destBaseRef = ref this.Dest[0];
ref Rgba32 sourceBaseRef = ref this.Source[0]; ref Rgba32 sourceBaseRef = ref this.Source[0];
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
Unsafe.Add(ref destBaseRef, i).FromRgba32(Unsafe.Add(ref sourceBaseRef, i)); Unsafe.Add(ref destBaseRef, i).FromRgba32(Unsafe.Add(ref sourceBaseRef, i));
} }
@ -62,7 +62,7 @@ public abstract class PixelConversion_ConvertFromRgba32
ref T destBaseRef = ref this.Dest[0]; ref T destBaseRef = ref this.Dest[0];
ref Rgba32 sourceBaseRef = ref this.Source[0]; ref Rgba32 sourceBaseRef = ref this.Source[0];
for (nint i = 0; i < (uint)count; i++) for (nuint i = 0; i < (uint)count; i++)
{ {
ref Rgba32 s = ref Unsafe.Add(ref sourceBaseRef, i); ref Rgba32 s = ref Unsafe.Add(ref sourceBaseRef, i);
Unsafe.Add(ref destBaseRef, i).FromBytes(s.R, s.G, s.B, s.A); Unsafe.Add(ref destBaseRef, i).FromBytes(s.R, s.G, s.B, s.A);
@ -111,7 +111,7 @@ public class PixelConversion_ConvertFromRgba32_Compatible : PixelConversion_Conv
ref Rgba32 sBase = ref this.CompatibleMemLayoutRunner.Source[0]; ref Rgba32 sBase = ref this.CompatibleMemLayoutRunner.Source[0];
ref Rgba32 dBase = ref Unsafe.As<TestRgba, Rgba32>(ref this.CompatibleMemLayoutRunner.Dest[0]); ref Rgba32 dBase = ref Unsafe.As<TestRgba, Rgba32>(ref this.CompatibleMemLayoutRunner.Dest[0]);
for (nint i = 0; i < (uint)this.Count; i++) for (nuint i = 0; i < (uint)this.Count; i++)
{ {
Unsafe.Add(ref dBase, i) = Unsafe.Add(ref sBase, i); Unsafe.Add(ref dBase, i) = Unsafe.Add(ref sBase, i);
} }
@ -151,7 +151,7 @@ public class PixelConversion_ConvertFromRgba32_Permuted_RgbaToArgb : PixelConver
ref Rgba32 sBase = ref this.PermutedRunnerRgbaToArgb.Source[0]; ref Rgba32 sBase = ref this.PermutedRunnerRgbaToArgb.Source[0];
ref TestArgb dBase = ref this.PermutedRunnerRgbaToArgb.Dest[0]; ref TestArgb dBase = ref this.PermutedRunnerRgbaToArgb.Dest[0];
for (nint i = 0; i < (uint)this.Count; i++) for (nuint i = 0; i < (uint)this.Count; i++)
{ {
Rgba32 s = Unsafe.Add(ref sBase, i); Rgba32 s = Unsafe.Add(ref sBase, i);
ref TestArgb d = ref Unsafe.Add(ref dBase, i); ref TestArgb d = ref Unsafe.Add(ref dBase, i);

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

Loading…
Cancel
Save