From f746e686df7ac0287118ac4ec143f2ac1bd9f62e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnther=20Foidl?= Date: Mon, 20 Mar 2023 20:04:02 +0100 Subject: [PATCH] PR feedback + use nuint instead of nint --- .../Conversion/ColorSpaceConverter.CieLab.cs | 26 +-- .../Conversion/ColorSpaceConverter.CieLch.cs | 26 +-- .../ColorSpaceConverter.CieLchuv.cs | 26 +-- .../Conversion/ColorSpaceConverter.CieLuv.cs | 26 +-- .../Conversion/ColorSpaceConverter.CieXyy.cs | 26 +-- .../Conversion/ColorSpaceConverter.CieXyz.cs | 26 +-- .../Conversion/ColorSpaceConverter.Cmyk.cs | 26 +-- .../Conversion/ColorSpaceConverter.Hsl.cs | 26 +-- .../Conversion/ColorSpaceConverter.Hsv.cs | 26 +-- .../ColorSpaceConverter.HunterLab.cs | 26 +-- .../ColorSpaceConverter.LinearRgb.cs | 26 +-- .../Conversion/ColorSpaceConverter.Lms.cs | 26 +-- .../Conversion/ColorSpaceConverter.Rgb.cs | 26 +-- .../Conversion/ColorSpaceConverter.YCbCr.cs | 24 +-- .../VonKriesChromaticAdaptation.cs | 2 +- src/ImageSharp/Common/Helpers/HexConverter.cs | 6 +- .../Helpers/Shuffle/IComponentShuffle.cs | 22 +-- .../Common/Helpers/Shuffle/IPad3Shuffle4.cs | 12 +- .../Common/Helpers/Shuffle/IShuffle3.cs | 10 +- .../Common/Helpers/Shuffle/IShuffle4Slice3.cs | 10 +- .../Helpers/SimdUtils.ExtendedIntrinsics.cs | 8 +- .../SimdUtils.FallbackIntrinsics128.cs | 4 +- .../Common/Helpers/SimdUtils.HwIntrinsics.cs | 48 ++--- .../Common/Helpers/SimdUtils.Pack.cs | 14 +- .../Common/Helpers/SimdUtils.Shuffle.cs | 46 ++--- .../Compression/Zlib/DeflaterHuffman.cs | 8 +- src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs | 8 +- .../Formats/ImageExtensions.Save.tt | 8 +- .../Jpeg/Components/Block8x8F.Generated.cs | 4 +- .../Jpeg/Components/Block8x8F.Generated.tt | 4 +- .../Jpeg/Components/Block8x8F.Intrinsic.cs | 6 +- .../Jpeg/Components/Block8x8F.ScaledCopy.cs | 28 +-- .../Formats/Jpeg/Components/Block8x8F.cs | 22 ++- .../JpegColorConverter.CmykAvx.cs | 8 +- .../JpegColorConverter.CmykVector.cs | 8 +- .../JpegColorConverter.GrayScaleAvx.cs | 8 +- .../JpegColorConverter.GrayScaleScalar.cs | 2 +- .../JpegColorConverter.GrayScaleVector.cs | 8 +- .../JpegColorConverter.RgbArm.cs | 4 +- .../JpegColorConverter.RgbAvx.cs | 4 +- .../JpegColorConverter.RgbVector.cs | 4 +- .../JpegColorConverter.YCbCrAvx.cs | 8 +- .../JpegColorConverter.YCbCrVector.cs | 8 +- .../JpegColorConverter.YccKAvx.cs | 8 +- .../JpegColorConverter.YccKVector.cs | 8 +- .../Decoder/ArithmeticScanDecoder.cs | 16 +- .../DownScalingComponentProcessor2.cs | 22 +-- .../DownScalingComponentProcessor4.cs | 22 +-- .../DownScalingComponentProcessor8.cs | 12 +- .../Components/Encoder/ComponentProcessor.cs | 28 +-- .../Components/Encoder/HuffmanScanEncoder.cs | 32 +-- .../Jpeg/Components/FloatingPointDCT.cs | 4 +- .../Jpeg/Components/ScaledFloatingPointDCT.cs | 2 +- .../Formats/Png/Filters/AverageFilter.cs | 26 +-- .../Formats/Png/Filters/PaethFilter.cs | 26 +-- .../Formats/Png/Filters/SubFilter.cs | 26 +-- .../Formats/Png/Filters/UpFilter.cs | 30 +-- src/ImageSharp/Formats/Png/PngDecoderCore.cs | 28 +-- src/ImageSharp/Formats/Png/PngEncoderCore.cs | 4 +- .../Formats/Png/PngScanlineProcessor.cs | 187 ++++++++++-------- .../Decompressors/T6TiffCompression.cs | 2 +- .../Tiff/Compression/TiffBaseCompression.cs | 2 +- .../BlackIsZero1TiffColor{TPixel}.cs | 14 +- .../WhiteIsZero1TiffColor{TPixel}.cs | 14 +- .../Formats/Tiff/TiffDecoderCore.cs | 2 +- src/ImageSharp/Formats/Webp/AlphaDecoder.cs | 16 +- .../Webp/Lossless/ColorSpaceTransformUtils.cs | 24 +-- .../Formats/Webp/Lossless/LosslessUtils.cs | 94 +++++---- .../Formats/Webp/Lossless/Vp8LHistogram.cs | 4 +- .../Formats/Webp/Lossy/LossyUtils.cs | 10 +- src/ImageSharp/Formats/Webp/Lossy/QuantEnc.cs | 6 +- .../Abgr32.PixelOperations.Generated.cs | 44 ++--- .../Argb32.PixelOperations.Generated.cs | 44 ++--- .../Bgr24.PixelOperations.Generated.cs | 44 ++--- .../Bgra32.PixelOperations.Generated.cs | 44 ++--- .../Bgra5551.PixelOperations.Generated.cs | 24 +-- .../L16.PixelOperations.Generated.cs | 24 +-- .../Generated/L8.PixelOperations.Generated.cs | 24 +-- .../La16.PixelOperations.Generated.cs | 24 +-- .../La32.PixelOperations.Generated.cs | 24 +-- .../Rgb24.PixelOperations.Generated.cs | 44 ++--- .../Rgb48.PixelOperations.Generated.cs | 24 +-- .../Rgba32.PixelOperations.Generated.cs | 44 ++--- .../Rgba64.PixelOperations.Generated.cs | 24 +-- .../Generated/_Common.ttinclude | 2 +- .../RgbaVector.PixelOperations.cs | 4 +- .../PixelOperations{TPixel}.Generated.cs | 52 ++--- .../PixelOperations{TPixel}.Generated.tt | 4 +- .../PixelFormats/PixelOperations{TPixel}.cs | 4 +- ...alizationSlidingWindowProcessor{TPixel}.cs | 8 +- .../HistogramEqualizationProcessor{TPixel}.cs | 10 +- .../Transforms/Resize/ResizeKernelMap.cs | 2 +- .../Transforms/Resize/ResizeWorker.cs | 16 +- .../ImageSharp.Benchmarks/Bulk/FromVector4.cs | 6 +- .../Bulk/PremultiplyVector4.cs | 4 +- .../Bulk/ToVector4_Rgba32.cs | 12 +- .../Bulk/UnPremultiplyVector4.cs | 4 +- .../BlockOperations/Block8x8F_CopyTo1x1.cs | 10 +- .../Jpeg/BlockOperations/Block8x8F_Round.cs | 8 +- .../PixelConversion_ConvertFromRgba32.cs | 10 +- .../PixelConversion_ConvertFromVector4.cs | 4 +- .../PixelConversion_ConvertToRgba32.cs | 4 +- ...vertToRgba32_AsPartOfCompositeOperation.cs | 4 +- .../PixelConversion_ConvertToVector4.cs | 4 +- ...ertToVector4_AsPartOfCompositeOperation.cs | 4 +- .../PixelConversion_PackFromRgbPlanes.cs | 10 +- .../PixelConversion_Rgba32_To_Argb32.cs | 12 +- .../PixelConversion_Rgba32_To_Bgra32.cs | 26 +-- .../General/Vectorization/UInt32ToSingle.cs | 16 +- .../General/Vectorization/VectorFetching.cs | 12 +- .../Vectorization/WidenBytesToUInt32.cs | 6 +- .../PorterDuffBulkVsSingleVector.cs | 2 +- .../Common/SimdUtilsTests.Shuffle.cs | 48 ++--- .../Formats/Png/PngEncoderFilterTests.cs | 2 +- .../Formats/Png/ReferenceImplementations.cs | 22 +-- ...ConverterTests.ReferenceImplementations.cs | 6 +- .../PixelOperations/PixelOperationsTests.cs | 2 +- .../Transforms/ResizeKernelMapTests.cs | 4 +- 118 files changed, 1090 insertions(+), 1049 deletions(-) diff --git a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLab.cs b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLab.cs index 88343cbab4..54667ca2af 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLab.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLab.cs @@ -37,7 +37,7 @@ public partial class ColorSpaceConverter ref CieLch sourceRef = ref MemoryMarshal.GetReference(source); ref CieLab destRef = ref MemoryMarshal.GetReference(destination); - for (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 CieLab dp = ref Unsafe.Add(ref destRef, i); @@ -70,7 +70,7 @@ public partial class ColorSpaceConverter ref CieLchuv sourceRef = ref MemoryMarshal.GetReference(source); ref CieLab destRef = ref MemoryMarshal.GetReference(destination); - for (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 CieLab dp = ref Unsafe.Add(ref destRef, i); @@ -103,7 +103,7 @@ public partial class ColorSpaceConverter ref CieLuv sourceRef = ref MemoryMarshal.GetReference(source); ref CieLab destRef = ref MemoryMarshal.GetReference(destination); - for (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 CieLab dp = ref Unsafe.Add(ref destRef, i); @@ -136,7 +136,7 @@ public partial class ColorSpaceConverter ref CieXyy sourceRef = ref MemoryMarshal.GetReference(source); ref CieLab destRef = ref MemoryMarshal.GetReference(destination); - for (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 CieLab dp = ref Unsafe.Add(ref destRef, i); @@ -169,7 +169,7 @@ public partial class ColorSpaceConverter ref CieXyz sourceRef = ref MemoryMarshal.GetReference(source); ref CieLab destRef = ref MemoryMarshal.GetReference(destination); - for (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 CieLab dp = ref Unsafe.Add(ref destRef, i); @@ -201,7 +201,7 @@ public partial class ColorSpaceConverter ref Cmyk sourceRef = ref MemoryMarshal.GetReference(source); ref CieLab destRef = ref MemoryMarshal.GetReference(destination); - for (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 CieLab dp = ref Unsafe.Add(ref destRef, i); @@ -234,7 +234,7 @@ public partial class ColorSpaceConverter ref Hsl sourceRef = ref MemoryMarshal.GetReference(source); ref CieLab destRef = ref MemoryMarshal.GetReference(destination); - for (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 CieLab dp = ref Unsafe.Add(ref destRef, i); @@ -266,7 +266,7 @@ public partial class ColorSpaceConverter ref Hsv sourceRef = ref MemoryMarshal.GetReference(source); ref CieLab destRef = ref MemoryMarshal.GetReference(destination); - for (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 CieLab dp = ref Unsafe.Add(ref destRef, i); @@ -299,7 +299,7 @@ public partial class ColorSpaceConverter ref HunterLab sourceRef = ref MemoryMarshal.GetReference(source); ref CieLab destRef = ref MemoryMarshal.GetReference(destination); - for (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 CieLab dp = ref Unsafe.Add(ref destRef, i); @@ -332,7 +332,7 @@ public partial class ColorSpaceConverter ref Lms sourceRef = ref MemoryMarshal.GetReference(source); ref CieLab destRef = ref MemoryMarshal.GetReference(destination); - for (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 CieLab dp = ref Unsafe.Add(ref destRef, i); @@ -365,7 +365,7 @@ public partial class ColorSpaceConverter ref LinearRgb sourceRef = ref MemoryMarshal.GetReference(source); ref CieLab destRef = ref MemoryMarshal.GetReference(destination); - for (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 CieLab dp = ref Unsafe.Add(ref destRef, i); @@ -398,7 +398,7 @@ public partial class ColorSpaceConverter ref Rgb sourceRef = ref MemoryMarshal.GetReference(source); ref CieLab destRef = ref MemoryMarshal.GetReference(destination); - for (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 CieLab dp = ref Unsafe.Add(ref destRef, i); @@ -431,7 +431,7 @@ public partial class ColorSpaceConverter ref YCbCr sourceRef = ref MemoryMarshal.GetReference(source); ref CieLab destRef = ref MemoryMarshal.GetReference(destination); - for (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 CieLab dp = ref Unsafe.Add(ref destRef, i); diff --git a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLch.cs b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLch.cs index dcd6be185c..9949b5d91b 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLch.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLch.cs @@ -36,7 +36,7 @@ public partial class ColorSpaceConverter ref CieLab sourceRef = ref MemoryMarshal.GetReference(source); ref CieLch destRef = ref MemoryMarshal.GetReference(destination); - for (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 CieLch dp = ref Unsafe.Add(ref destRef, i); @@ -69,7 +69,7 @@ public partial class ColorSpaceConverter ref CieLchuv sourceRef = ref MemoryMarshal.GetReference(source); ref CieLch destRef = ref MemoryMarshal.GetReference(destination); - for (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 CieLch dp = ref Unsafe.Add(ref destRef, i); @@ -102,7 +102,7 @@ public partial class ColorSpaceConverter ref CieLuv sourceRef = ref MemoryMarshal.GetReference(source); ref CieLch destRef = ref MemoryMarshal.GetReference(destination); - for (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 CieLch dp = ref Unsafe.Add(ref destRef, i); @@ -135,7 +135,7 @@ public partial class ColorSpaceConverter ref CieXyy sourceRef = ref MemoryMarshal.GetReference(source); ref CieLch destRef = ref MemoryMarshal.GetReference(destination); - for (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 CieLch dp = ref Unsafe.Add(ref destRef, i); @@ -168,7 +168,7 @@ public partial class ColorSpaceConverter ref CieXyz sourceRef = ref MemoryMarshal.GetReference(source); ref CieLch destRef = ref MemoryMarshal.GetReference(destination); - for (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 CieLch dp = ref Unsafe.Add(ref destRef, i); @@ -200,7 +200,7 @@ public partial class ColorSpaceConverter ref Cmyk sourceRef = ref MemoryMarshal.GetReference(source); ref CieLch destRef = ref MemoryMarshal.GetReference(destination); - for (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 CieLch dp = ref Unsafe.Add(ref destRef, i); @@ -233,7 +233,7 @@ public partial class ColorSpaceConverter ref Hsl sourceRef = ref MemoryMarshal.GetReference(source); ref CieLch destRef = ref MemoryMarshal.GetReference(destination); - for (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 CieLch dp = ref Unsafe.Add(ref destRef, i); @@ -266,7 +266,7 @@ public partial class ColorSpaceConverter ref Hsv sourceRef = ref MemoryMarshal.GetReference(source); ref CieLch destRef = ref MemoryMarshal.GetReference(destination); - for (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 CieLch dp = ref Unsafe.Add(ref destRef, i); @@ -299,7 +299,7 @@ public partial class ColorSpaceConverter ref HunterLab sourceRef = ref MemoryMarshal.GetReference(source); ref CieLch destRef = ref MemoryMarshal.GetReference(destination); - for (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 CieLch dp = ref Unsafe.Add(ref destRef, i); @@ -332,7 +332,7 @@ public partial class ColorSpaceConverter ref LinearRgb sourceRef = ref MemoryMarshal.GetReference(source); ref CieLch destRef = ref MemoryMarshal.GetReference(destination); - for (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 CieLch dp = ref Unsafe.Add(ref destRef, i); @@ -365,7 +365,7 @@ public partial class ColorSpaceConverter ref Lms sourceRef = ref MemoryMarshal.GetReference(source); ref CieLch destRef = ref MemoryMarshal.GetReference(destination); - for (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 CieLch dp = ref Unsafe.Add(ref destRef, i); @@ -398,7 +398,7 @@ public partial class ColorSpaceConverter ref Rgb sourceRef = ref MemoryMarshal.GetReference(source); ref CieLch destRef = ref MemoryMarshal.GetReference(destination); - for (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 CieLch dp = ref Unsafe.Add(ref destRef, i); @@ -431,7 +431,7 @@ public partial class ColorSpaceConverter ref YCbCr sourceRef = ref MemoryMarshal.GetReference(source); ref CieLch destRef = ref MemoryMarshal.GetReference(destination); - for (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 CieLch dp = ref Unsafe.Add(ref destRef, i); diff --git a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLchuv.cs b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLchuv.cs index eb21394a09..4b856d1189 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLchuv.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLchuv.cs @@ -36,7 +36,7 @@ public partial class ColorSpaceConverter ref CieLab sourceRef = ref MemoryMarshal.GetReference(source); ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination); - for (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 CieLchuv dp = ref Unsafe.Add(ref destRef, i); @@ -69,7 +69,7 @@ public partial class ColorSpaceConverter ref CieLch sourceRef = ref MemoryMarshal.GetReference(source); ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination); - for (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 CieLchuv dp = ref Unsafe.Add(ref destRef, i); @@ -102,7 +102,7 @@ public partial class ColorSpaceConverter ref CieLuv sourceRef = ref MemoryMarshal.GetReference(source); ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination); - for (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 CieLchuv dp = ref Unsafe.Add(ref destRef, i); @@ -135,7 +135,7 @@ public partial class ColorSpaceConverter ref CieXyy sourceRef = ref MemoryMarshal.GetReference(source); ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination); - for (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 CieLchuv dp = ref Unsafe.Add(ref destRef, i); @@ -168,7 +168,7 @@ public partial class ColorSpaceConverter ref CieXyz sourceRef = ref MemoryMarshal.GetReference(source); ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination); - for (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 CieLchuv dp = ref Unsafe.Add(ref destRef, i); @@ -201,7 +201,7 @@ public partial class ColorSpaceConverter ref Cmyk sourceRef = ref MemoryMarshal.GetReference(source); ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination); - for (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 CieLchuv dp = ref Unsafe.Add(ref destRef, i); @@ -234,7 +234,7 @@ public partial class ColorSpaceConverter ref Hsl sourceRef = ref MemoryMarshal.GetReference(source); ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination); - for (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 CieLchuv dp = ref Unsafe.Add(ref destRef, i); @@ -267,7 +267,7 @@ public partial class ColorSpaceConverter ref Hsv sourceRef = ref MemoryMarshal.GetReference(source); ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination); - for (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 CieLchuv dp = ref Unsafe.Add(ref destRef, i); @@ -300,7 +300,7 @@ public partial class ColorSpaceConverter ref HunterLab sourceRef = ref MemoryMarshal.GetReference(source); ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination); - for (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 CieLchuv dp = ref Unsafe.Add(ref destRef, i); @@ -333,7 +333,7 @@ public partial class ColorSpaceConverter ref LinearRgb sourceRef = ref MemoryMarshal.GetReference(source); ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination); - for (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 CieLchuv dp = ref Unsafe.Add(ref destRef, i); @@ -366,7 +366,7 @@ public partial class ColorSpaceConverter ref Lms sourceRef = ref MemoryMarshal.GetReference(source); ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination); - for (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 CieLchuv dp = ref Unsafe.Add(ref destRef, i); @@ -399,7 +399,7 @@ public partial class ColorSpaceConverter ref Rgb sourceRef = ref MemoryMarshal.GetReference(source); ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination); - for (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 CieLchuv dp = ref Unsafe.Add(ref destRef, i); @@ -431,7 +431,7 @@ public partial class ColorSpaceConverter ref YCbCr sourceRef = ref MemoryMarshal.GetReference(source); ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination); - for (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 CieLchuv dp = ref Unsafe.Add(ref destRef, i); diff --git a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLuv.cs b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLuv.cs index 1b6735e623..2e8029f64a 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLuv.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLuv.cs @@ -35,7 +35,7 @@ public partial class ColorSpaceConverter ref CieLab sourceRef = ref MemoryMarshal.GetReference(source); ref CieLuv destRef = ref MemoryMarshal.GetReference(destination); - for (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 CieLuv dp = ref Unsafe.Add(ref destRef, i); @@ -67,7 +67,7 @@ public partial class ColorSpaceConverter ref CieLch sourceRef = ref MemoryMarshal.GetReference(source); ref CieLuv destRef = ref MemoryMarshal.GetReference(destination); - for (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 CieLuv dp = ref Unsafe.Add(ref destRef, i); @@ -102,7 +102,7 @@ public partial class ColorSpaceConverter ref CieLchuv sourceRef = ref MemoryMarshal.GetReference(source); ref CieLuv destRef = ref MemoryMarshal.GetReference(destination); - for (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 CieLuv dp = ref Unsafe.Add(ref destRef, i); @@ -134,7 +134,7 @@ public partial class ColorSpaceConverter ref CieXyy sourceRef = ref MemoryMarshal.GetReference(source); ref CieLuv destRef = ref MemoryMarshal.GetReference(destination); - for (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 CieLuv dp = ref Unsafe.Add(ref destRef, i); @@ -169,7 +169,7 @@ public partial class ColorSpaceConverter ref CieXyz sourceRef = ref MemoryMarshal.GetReference(source); ref CieLuv destRef = ref MemoryMarshal.GetReference(destination); - for (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 CieLuv dp = ref Unsafe.Add(ref destRef, i); @@ -201,7 +201,7 @@ public partial class ColorSpaceConverter ref Cmyk sourceRef = ref MemoryMarshal.GetReference(source); ref CieLuv destRef = ref MemoryMarshal.GetReference(destination); - for (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 CieLuv dp = ref Unsafe.Add(ref destRef, i); @@ -233,7 +233,7 @@ public partial class ColorSpaceConverter ref Hsl sourceRef = ref MemoryMarshal.GetReference(source); ref CieLuv destRef = ref MemoryMarshal.GetReference(destination); - for (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 CieLuv dp = ref Unsafe.Add(ref destRef, i); @@ -265,7 +265,7 @@ public partial class ColorSpaceConverter ref Hsv sourceRef = ref MemoryMarshal.GetReference(source); ref CieLuv destRef = ref MemoryMarshal.GetReference(destination); - for (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 CieLuv dp = ref Unsafe.Add(ref destRef, i); @@ -297,7 +297,7 @@ public partial class ColorSpaceConverter ref HunterLab sourceRef = ref MemoryMarshal.GetReference(source); ref CieLuv destRef = ref MemoryMarshal.GetReference(destination); - for (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 CieLuv dp = ref Unsafe.Add(ref destRef, i); @@ -329,7 +329,7 @@ public partial class ColorSpaceConverter ref Lms sourceRef = ref MemoryMarshal.GetReference(source); ref CieLuv destRef = ref MemoryMarshal.GetReference(destination); - for (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 CieLuv dp = ref Unsafe.Add(ref destRef, i); @@ -361,7 +361,7 @@ public partial class ColorSpaceConverter ref LinearRgb sourceRef = ref MemoryMarshal.GetReference(source); ref CieLuv destRef = ref MemoryMarshal.GetReference(destination); - for (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 CieLuv dp = ref Unsafe.Add(ref destRef, i); @@ -393,7 +393,7 @@ public partial class ColorSpaceConverter ref Rgb sourceRef = ref MemoryMarshal.GetReference(source); ref CieLuv destRef = ref MemoryMarshal.GetReference(destination); - for (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 CieLuv dp = ref Unsafe.Add(ref destRef, i); @@ -425,7 +425,7 @@ public partial class ColorSpaceConverter ref YCbCr sourceRef = ref MemoryMarshal.GetReference(source); ref CieLuv destRef = ref MemoryMarshal.GetReference(destination); - for (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 CieLuv dp = ref Unsafe.Add(ref destRef, i); diff --git a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieXyy.cs b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieXyy.cs index 2b34e66f2e..13b2a225c3 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieXyy.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieXyy.cs @@ -36,7 +36,7 @@ public partial class ColorSpaceConverter ref CieLab sourceRef = ref MemoryMarshal.GetReference(source); ref CieXyy destRef = ref MemoryMarshal.GetReference(destination); - for (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 CieXyy dp = ref Unsafe.Add(ref destRef, i); @@ -69,7 +69,7 @@ public partial class ColorSpaceConverter ref CieLch sourceRef = ref MemoryMarshal.GetReference(source); ref CieXyy destRef = ref MemoryMarshal.GetReference(destination); - for (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 CieXyy dp = ref Unsafe.Add(ref destRef, i); @@ -102,7 +102,7 @@ public partial class ColorSpaceConverter ref CieLchuv sourceRef = ref MemoryMarshal.GetReference(source); ref CieXyy destRef = ref MemoryMarshal.GetReference(destination); - for (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 CieXyy dp = ref Unsafe.Add(ref destRef, i); @@ -135,7 +135,7 @@ public partial class ColorSpaceConverter ref CieLuv sourceRef = ref MemoryMarshal.GetReference(source); ref CieXyy destRef = ref MemoryMarshal.GetReference(destination); - for (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 CieXyy dp = ref Unsafe.Add(ref destRef, i); @@ -163,7 +163,7 @@ public partial class ColorSpaceConverter ref CieXyz sourceRef = ref MemoryMarshal.GetReference(source); ref CieXyy destRef = ref MemoryMarshal.GetReference(destination); - for (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 CieXyy dp = ref Unsafe.Add(ref destRef, i); @@ -196,7 +196,7 @@ public partial class ColorSpaceConverter ref Cmyk sourceRef = ref MemoryMarshal.GetReference(source); ref CieXyy destRef = ref MemoryMarshal.GetReference(destination); - for (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 CieXyy dp = ref Unsafe.Add(ref destRef, i); @@ -229,7 +229,7 @@ public partial class ColorSpaceConverter ref Hsl sourceRef = ref MemoryMarshal.GetReference(source); ref CieXyy destRef = ref MemoryMarshal.GetReference(destination); - for (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 CieXyy dp = ref Unsafe.Add(ref destRef, i); @@ -262,7 +262,7 @@ public partial class ColorSpaceConverter ref Hsv sourceRef = ref MemoryMarshal.GetReference(source); ref CieXyy destRef = ref MemoryMarshal.GetReference(destination); - for (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 CieXyy dp = ref Unsafe.Add(ref destRef, i); @@ -295,7 +295,7 @@ public partial class ColorSpaceConverter ref HunterLab sourceRef = ref MemoryMarshal.GetReference(source); ref CieXyy destRef = ref MemoryMarshal.GetReference(destination); - for (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 CieXyy dp = ref Unsafe.Add(ref destRef, i); @@ -328,7 +328,7 @@ public partial class ColorSpaceConverter ref LinearRgb sourceRef = ref MemoryMarshal.GetReference(source); ref CieXyy destRef = ref MemoryMarshal.GetReference(destination); - for (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 CieXyy dp = ref Unsafe.Add(ref destRef, i); @@ -361,7 +361,7 @@ public partial class ColorSpaceConverter ref Lms sourceRef = ref MemoryMarshal.GetReference(source); ref CieXyy destRef = ref MemoryMarshal.GetReference(destination); - for (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 CieXyy dp = ref Unsafe.Add(ref destRef, i); @@ -394,7 +394,7 @@ public partial class ColorSpaceConverter ref Rgb sourceRef = ref MemoryMarshal.GetReference(source); ref CieXyy destRef = ref MemoryMarshal.GetReference(destination); - for (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 CieXyy dp = ref Unsafe.Add(ref destRef, i); @@ -427,7 +427,7 @@ public partial class ColorSpaceConverter ref YCbCr sourceRef = ref MemoryMarshal.GetReference(source); ref CieXyy destRef = ref MemoryMarshal.GetReference(destination); - for (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 CieXyy dp = ref Unsafe.Add(ref destRef, i); diff --git a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieXyz.cs b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieXyz.cs index 1495a28b64..2212ca2e58 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieXyz.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieXyz.cs @@ -41,7 +41,7 @@ public partial class ColorSpaceConverter ref CieLab sourceRef = ref MemoryMarshal.GetReference(source); ref CieXyz destRef = ref MemoryMarshal.GetReference(destination); - for (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 CieXyz dp = ref Unsafe.Add(ref destRef, i); @@ -76,7 +76,7 @@ public partial class ColorSpaceConverter ref CieLch sourceRef = ref MemoryMarshal.GetReference(source); ref CieXyz destRef = ref MemoryMarshal.GetReference(destination); - for (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 CieXyz dp = ref Unsafe.Add(ref destRef, i); @@ -111,7 +111,7 @@ public partial class ColorSpaceConverter ref CieLchuv sourceRef = ref MemoryMarshal.GetReference(source); ref CieXyz destRef = ref MemoryMarshal.GetReference(destination); - for (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 CieXyz dp = ref Unsafe.Add(ref destRef, i); @@ -146,7 +146,7 @@ public partial class ColorSpaceConverter ref CieLuv sourceRef = ref MemoryMarshal.GetReference(source); ref CieXyz destRef = ref MemoryMarshal.GetReference(destination); - for (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 CieXyz dp = ref Unsafe.Add(ref destRef, i); @@ -177,7 +177,7 @@ public partial class ColorSpaceConverter ref CieXyy sourceRef = ref MemoryMarshal.GetReference(source); ref CieXyz destRef = ref MemoryMarshal.GetReference(destination); - for (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 CieXyz dp = ref Unsafe.Add(ref destRef, i); @@ -210,7 +210,7 @@ public partial class ColorSpaceConverter ref Cmyk sourceRef = ref MemoryMarshal.GetReference(source); ref CieXyz destRef = ref MemoryMarshal.GetReference(destination); - for (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 CieXyz dp = ref Unsafe.Add(ref destRef, i); @@ -243,7 +243,7 @@ public partial class ColorSpaceConverter ref Hsl sourceRef = ref MemoryMarshal.GetReference(source); ref CieXyz destRef = ref MemoryMarshal.GetReference(destination); - for (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 CieXyz dp = ref Unsafe.Add(ref destRef, i); @@ -277,7 +277,7 @@ public partial class ColorSpaceConverter ref Hsv sourceRef = ref MemoryMarshal.GetReference(source); ref CieXyz destRef = ref MemoryMarshal.GetReference(destination); - for (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 CieXyz dp = ref Unsafe.Add(ref destRef, i); @@ -310,7 +310,7 @@ public partial class ColorSpaceConverter ref HunterLab sourceRef = ref MemoryMarshal.GetReference(source); ref CieXyz destRef = ref MemoryMarshal.GetReference(destination); - for (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 CieXyz dp = ref Unsafe.Add(ref destRef, i); @@ -345,7 +345,7 @@ public partial class ColorSpaceConverter ref LinearRgb sourceRef = ref MemoryMarshal.GetReference(source); ref CieXyz destRef = ref MemoryMarshal.GetReference(destination); - for (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 CieXyz dp = ref Unsafe.Add(ref destRef, i); @@ -374,7 +374,7 @@ public partial class ColorSpaceConverter ref Lms sourceRef = ref MemoryMarshal.GetReference(source); ref CieXyz destRef = ref MemoryMarshal.GetReference(destination); - for (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 CieXyz dp = ref Unsafe.Add(ref destRef, i); @@ -407,7 +407,7 @@ public partial class ColorSpaceConverter ref Rgb sourceRef = ref MemoryMarshal.GetReference(source); ref CieXyz destRef = ref MemoryMarshal.GetReference(destination); - for (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 CieXyz dp = ref Unsafe.Add(ref destRef, i); @@ -440,7 +440,7 @@ public partial class ColorSpaceConverter ref YCbCr sourceRef = ref MemoryMarshal.GetReference(source); ref CieXyz destRef = ref MemoryMarshal.GetReference(destination); - for (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 CieXyz dp = ref Unsafe.Add(ref destRef, i); diff --git a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Cmyk.cs b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Cmyk.cs index 068583e82f..ea9a5d734b 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Cmyk.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Cmyk.cs @@ -36,7 +36,7 @@ public partial class ColorSpaceConverter ref CieLab sourceRef = ref MemoryMarshal.GetReference(source); ref Cmyk destRef = ref MemoryMarshal.GetReference(destination); - for (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 Cmyk dp = ref Unsafe.Add(ref destRef, i); @@ -69,7 +69,7 @@ public partial class ColorSpaceConverter ref CieLch sourceRef = ref MemoryMarshal.GetReference(source); ref Cmyk destRef = ref MemoryMarshal.GetReference(destination); - for (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 Cmyk dp = ref Unsafe.Add(ref destRef, i); @@ -102,7 +102,7 @@ public partial class ColorSpaceConverter ref CieLchuv sourceRef = ref MemoryMarshal.GetReference(source); ref Cmyk destRef = ref MemoryMarshal.GetReference(destination); - for (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 Cmyk dp = ref Unsafe.Add(ref destRef, i); @@ -135,7 +135,7 @@ public partial class ColorSpaceConverter ref CieLuv sourceRef = ref MemoryMarshal.GetReference(source); ref Cmyk destRef = ref MemoryMarshal.GetReference(destination); - for (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 Cmyk dp = ref Unsafe.Add(ref destRef, i); @@ -168,7 +168,7 @@ public partial class ColorSpaceConverter ref CieXyy sourceRef = ref MemoryMarshal.GetReference(source); ref Cmyk destRef = ref MemoryMarshal.GetReference(destination); - for (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 Cmyk dp = ref Unsafe.Add(ref destRef, i); @@ -201,7 +201,7 @@ public partial class ColorSpaceConverter ref CieXyz sourceRef = ref MemoryMarshal.GetReference(source); ref Cmyk destRef = ref MemoryMarshal.GetReference(destination); - for (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 Cmyk dp = ref Unsafe.Add(ref destRef, i); @@ -234,7 +234,7 @@ public partial class ColorSpaceConverter ref Hsl sourceRef = ref MemoryMarshal.GetReference(source); ref Cmyk destRef = ref MemoryMarshal.GetReference(destination); - for (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 Cmyk dp = ref Unsafe.Add(ref destRef, i); @@ -267,7 +267,7 @@ public partial class ColorSpaceConverter ref Hsv sourceRef = ref MemoryMarshal.GetReference(source); ref Cmyk destRef = ref MemoryMarshal.GetReference(destination); - for (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 Cmyk dp = ref Unsafe.Add(ref destRef, i); @@ -300,7 +300,7 @@ public partial class ColorSpaceConverter ref HunterLab sourceRef = ref MemoryMarshal.GetReference(source); ref Cmyk destRef = ref MemoryMarshal.GetReference(destination); - for (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 Cmyk dp = ref Unsafe.Add(ref destRef, i); @@ -333,7 +333,7 @@ public partial class ColorSpaceConverter ref LinearRgb sourceRef = ref MemoryMarshal.GetReference(source); ref Cmyk destRef = ref MemoryMarshal.GetReference(destination); - for (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 Cmyk dp = ref Unsafe.Add(ref destRef, i); @@ -366,7 +366,7 @@ public partial class ColorSpaceConverter ref Lms sourceRef = ref MemoryMarshal.GetReference(source); ref Cmyk destRef = ref MemoryMarshal.GetReference(destination); - for (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 Cmyk dp = ref Unsafe.Add(ref destRef, i); @@ -394,7 +394,7 @@ public partial class ColorSpaceConverter ref Rgb sourceRef = ref MemoryMarshal.GetReference(source); ref Cmyk destRef = ref MemoryMarshal.GetReference(destination); - for (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 Cmyk dp = ref Unsafe.Add(ref destRef, i); @@ -427,7 +427,7 @@ public partial class ColorSpaceConverter ref YCbCr sourceRef = ref MemoryMarshal.GetReference(source); ref Cmyk destRef = ref MemoryMarshal.GetReference(destination); - for (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 Cmyk dp = ref Unsafe.Add(ref destRef, i); diff --git a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Hsl.cs b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Hsl.cs index f40544b7a9..67ec162917 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Hsl.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Hsl.cs @@ -36,7 +36,7 @@ public partial class ColorSpaceConverter ref CieLab sourceRef = ref MemoryMarshal.GetReference(source); ref Hsl destRef = ref MemoryMarshal.GetReference(destination); - for (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 Hsl dp = ref Unsafe.Add(ref destRef, i); @@ -69,7 +69,7 @@ public partial class ColorSpaceConverter ref CieLch sourceRef = ref MemoryMarshal.GetReference(source); ref Hsl destRef = ref MemoryMarshal.GetReference(destination); - for (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 Hsl dp = ref Unsafe.Add(ref destRef, i); @@ -102,7 +102,7 @@ public partial class ColorSpaceConverter ref CieLchuv sourceRef = ref MemoryMarshal.GetReference(source); ref Hsl destRef = ref MemoryMarshal.GetReference(destination); - for (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 Hsl dp = ref Unsafe.Add(ref destRef, i); @@ -135,7 +135,7 @@ public partial class ColorSpaceConverter ref CieLuv sourceRef = ref MemoryMarshal.GetReference(source); ref Hsl destRef = ref MemoryMarshal.GetReference(destination); - for (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 Hsl dp = ref Unsafe.Add(ref destRef, i); @@ -168,7 +168,7 @@ public partial class ColorSpaceConverter ref CieXyy sourceRef = ref MemoryMarshal.GetReference(source); ref Hsl destRef = ref MemoryMarshal.GetReference(destination); - for (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 Hsl dp = ref Unsafe.Add(ref destRef, i); @@ -201,7 +201,7 @@ public partial class ColorSpaceConverter ref CieXyz sourceRef = ref MemoryMarshal.GetReference(source); ref Hsl destRef = ref MemoryMarshal.GetReference(destination); - for (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 Hsl dp = ref Unsafe.Add(ref destRef, i); @@ -234,7 +234,7 @@ public partial class ColorSpaceConverter ref Cmyk sourceRef = ref MemoryMarshal.GetReference(source); ref Hsl destRef = ref MemoryMarshal.GetReference(destination); - for (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 Hsl dp = ref Unsafe.Add(ref destRef, i); @@ -267,7 +267,7 @@ public partial class ColorSpaceConverter ref Hsv sourceRef = ref MemoryMarshal.GetReference(source); ref Hsl destRef = ref MemoryMarshal.GetReference(destination); - for (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 Hsl dp = ref Unsafe.Add(ref destRef, i); @@ -300,7 +300,7 @@ public partial class ColorSpaceConverter ref HunterLab sourceRef = ref MemoryMarshal.GetReference(source); ref Hsl destRef = ref MemoryMarshal.GetReference(destination); - for (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 Hsl dp = ref Unsafe.Add(ref destRef, i); @@ -333,7 +333,7 @@ public partial class ColorSpaceConverter ref LinearRgb sourceRef = ref MemoryMarshal.GetReference(source); ref Hsl destRef = ref MemoryMarshal.GetReference(destination); - for (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 Hsl dp = ref Unsafe.Add(ref destRef, i); @@ -366,7 +366,7 @@ public partial class ColorSpaceConverter ref Lms sourceRef = ref MemoryMarshal.GetReference(source); ref Hsl destRef = ref MemoryMarshal.GetReference(destination); - for (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 Hsl dp = ref Unsafe.Add(ref destRef, i); @@ -394,7 +394,7 @@ public partial class ColorSpaceConverter ref Rgb sourceRef = ref MemoryMarshal.GetReference(source); ref Hsl destRef = ref MemoryMarshal.GetReference(destination); - for (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 Hsl dp = ref Unsafe.Add(ref destRef, i); @@ -427,7 +427,7 @@ public partial class ColorSpaceConverter ref YCbCr sourceRef = ref MemoryMarshal.GetReference(source); ref Hsl destRef = ref MemoryMarshal.GetReference(destination); - for (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 Hsl dp = ref Unsafe.Add(ref destRef, i); diff --git a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Hsv.cs b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Hsv.cs index 8bd014ed96..47ee42dc5a 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Hsv.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Hsv.cs @@ -36,7 +36,7 @@ public partial class ColorSpaceConverter ref CieLab sourceRef = ref MemoryMarshal.GetReference(source); ref Hsv destRef = ref MemoryMarshal.GetReference(destination); - for (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 Hsv dp = ref Unsafe.Add(ref destRef, i); @@ -69,7 +69,7 @@ public partial class ColorSpaceConverter ref CieLch sourceRef = ref MemoryMarshal.GetReference(source); ref Hsv destRef = ref MemoryMarshal.GetReference(destination); - for (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 Hsv dp = ref Unsafe.Add(ref destRef, i); @@ -102,7 +102,7 @@ public partial class ColorSpaceConverter ref CieLchuv sourceRef = ref MemoryMarshal.GetReference(source); ref Hsv destRef = ref MemoryMarshal.GetReference(destination); - for (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 Hsv dp = ref Unsafe.Add(ref destRef, i); @@ -135,7 +135,7 @@ public partial class ColorSpaceConverter ref CieLuv sourceRef = ref MemoryMarshal.GetReference(source); ref Hsv destRef = ref MemoryMarshal.GetReference(destination); - for (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 Hsv dp = ref Unsafe.Add(ref destRef, i); @@ -168,7 +168,7 @@ public partial class ColorSpaceConverter ref CieXyy sourceRef = ref MemoryMarshal.GetReference(source); ref Hsv destRef = ref MemoryMarshal.GetReference(destination); - for (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 Hsv dp = ref Unsafe.Add(ref destRef, i); @@ -201,7 +201,7 @@ public partial class ColorSpaceConverter ref CieXyz sourceRef = ref MemoryMarshal.GetReference(source); ref Hsv destRef = ref MemoryMarshal.GetReference(destination); - for (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 Hsv dp = ref Unsafe.Add(ref destRef, i); @@ -234,7 +234,7 @@ public partial class ColorSpaceConverter ref Cmyk sourceRef = ref MemoryMarshal.GetReference(source); ref Hsv destRef = ref MemoryMarshal.GetReference(destination); - for (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 Hsv dp = ref Unsafe.Add(ref destRef, i); @@ -267,7 +267,7 @@ public partial class ColorSpaceConverter ref Hsl sourceRef = ref MemoryMarshal.GetReference(source); ref Hsv destRef = ref MemoryMarshal.GetReference(destination); - for (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 Hsv dp = ref Unsafe.Add(ref destRef, i); @@ -300,7 +300,7 @@ public partial class ColorSpaceConverter ref HunterLab sourceRef = ref MemoryMarshal.GetReference(source); ref Hsv destRef = ref MemoryMarshal.GetReference(destination); - for (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 Hsv dp = ref Unsafe.Add(ref destRef, i); @@ -333,7 +333,7 @@ public partial class ColorSpaceConverter ref LinearRgb sourceRef = ref MemoryMarshal.GetReference(source); ref Hsv destRef = ref MemoryMarshal.GetReference(destination); - for (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 Hsv dp = ref Unsafe.Add(ref destRef, i); @@ -366,7 +366,7 @@ public partial class ColorSpaceConverter ref Lms sourceRef = ref MemoryMarshal.GetReference(source); ref Hsv destRef = ref MemoryMarshal.GetReference(destination); - for (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 Hsv dp = ref Unsafe.Add(ref destRef, i); @@ -394,7 +394,7 @@ public partial class ColorSpaceConverter ref Rgb sourceRef = ref MemoryMarshal.GetReference(source); ref Hsv destRef = ref MemoryMarshal.GetReference(destination); - for (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 Hsv dp = ref Unsafe.Add(ref destRef, i); @@ -427,7 +427,7 @@ public partial class ColorSpaceConverter ref YCbCr sourceRef = ref MemoryMarshal.GetReference(source); ref Hsv destRef = ref MemoryMarshal.GetReference(destination); - for (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 Hsv dp = ref Unsafe.Add(ref destRef, i); diff --git a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.HunterLab.cs b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.HunterLab.cs index 2890594651..0604027760 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.HunterLab.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.HunterLab.cs @@ -24,7 +24,7 @@ public partial class ColorSpaceConverter ref CieLab sourceRef = ref MemoryMarshal.GetReference(source); ref HunterLab destRef = ref MemoryMarshal.GetReference(destination); - for (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 HunterLab dp = ref Unsafe.Add(ref destRef, i); @@ -45,7 +45,7 @@ public partial class ColorSpaceConverter ref CieLch sourceRef = ref MemoryMarshal.GetReference(source); ref HunterLab destRef = ref MemoryMarshal.GetReference(destination); - for (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 HunterLab dp = ref Unsafe.Add(ref destRef, i); @@ -66,7 +66,7 @@ public partial class ColorSpaceConverter ref CieLchuv sourceRef = ref MemoryMarshal.GetReference(source); ref HunterLab destRef = ref MemoryMarshal.GetReference(destination); - for (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 HunterLab dp = ref Unsafe.Add(ref destRef, i); @@ -87,7 +87,7 @@ public partial class ColorSpaceConverter ref CieLuv sourceRef = ref MemoryMarshal.GetReference(source); ref HunterLab destRef = ref MemoryMarshal.GetReference(destination); - for (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 HunterLab dp = ref Unsafe.Add(ref destRef, i); @@ -108,7 +108,7 @@ public partial class ColorSpaceConverter ref CieXyy sourceRef = ref MemoryMarshal.GetReference(source); ref HunterLab destRef = ref MemoryMarshal.GetReference(destination); - for (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 HunterLab dp = ref Unsafe.Add(ref destRef, i); @@ -129,7 +129,7 @@ public partial class ColorSpaceConverter ref CieXyz sourceRef = ref MemoryMarshal.GetReference(source); ref HunterLab destRef = ref MemoryMarshal.GetReference(destination); - for (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 HunterLab dp = ref Unsafe.Add(ref destRef, i); @@ -150,7 +150,7 @@ public partial class ColorSpaceConverter ref Cmyk sourceRef = ref MemoryMarshal.GetReference(source); ref HunterLab destRef = ref MemoryMarshal.GetReference(destination); - for (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 HunterLab dp = ref Unsafe.Add(ref destRef, i); @@ -171,7 +171,7 @@ public partial class ColorSpaceConverter ref Hsl sourceRef = ref MemoryMarshal.GetReference(source); ref HunterLab destRef = ref MemoryMarshal.GetReference(destination); - for (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 HunterLab dp = ref Unsafe.Add(ref destRef, i); @@ -192,7 +192,7 @@ public partial class ColorSpaceConverter ref Hsv sourceRef = ref MemoryMarshal.GetReference(source); ref HunterLab destRef = ref MemoryMarshal.GetReference(destination); - for (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 HunterLab dp = ref Unsafe.Add(ref destRef, i); @@ -213,7 +213,7 @@ public partial class ColorSpaceConverter ref LinearRgb sourceRef = ref MemoryMarshal.GetReference(source); ref HunterLab destRef = ref MemoryMarshal.GetReference(destination); - for (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 HunterLab dp = ref Unsafe.Add(ref destRef, i); @@ -234,7 +234,7 @@ public partial class ColorSpaceConverter ref Lms sourceRef = ref MemoryMarshal.GetReference(source); ref HunterLab destRef = ref MemoryMarshal.GetReference(destination); - for (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 HunterLab dp = ref Unsafe.Add(ref destRef, i); @@ -255,7 +255,7 @@ public partial class ColorSpaceConverter ref Rgb sourceRef = ref MemoryMarshal.GetReference(source); ref HunterLab destRef = ref MemoryMarshal.GetReference(destination); - for (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 HunterLab dp = ref Unsafe.Add(ref destRef, i); @@ -276,7 +276,7 @@ public partial class ColorSpaceConverter ref YCbCr sourceRef = ref MemoryMarshal.GetReference(source); ref HunterLab destRef = ref MemoryMarshal.GetReference(destination); - for (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 HunterLab dp = ref Unsafe.Add(ref destRef, i); diff --git a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.LinearRgb.cs b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.LinearRgb.cs index 897ec02a0f..fd385a15b0 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.LinearRgb.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.LinearRgb.cs @@ -24,7 +24,7 @@ public partial class ColorSpaceConverter ref CieLab sourceRef = ref MemoryMarshal.GetReference(source); ref LinearRgb destRef = ref MemoryMarshal.GetReference(destination); - for (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 LinearRgb dp = ref Unsafe.Add(ref destRef, i); @@ -45,7 +45,7 @@ public partial class ColorSpaceConverter ref CieLch sourceRef = ref MemoryMarshal.GetReference(source); ref LinearRgb destRef = ref MemoryMarshal.GetReference(destination); - for (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 LinearRgb dp = ref Unsafe.Add(ref destRef, i); @@ -66,7 +66,7 @@ public partial class ColorSpaceConverter ref CieLchuv sourceRef = ref MemoryMarshal.GetReference(source); ref LinearRgb destRef = ref MemoryMarshal.GetReference(destination); - for (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 LinearRgb dp = ref Unsafe.Add(ref destRef, i); @@ -87,7 +87,7 @@ public partial class ColorSpaceConverter ref CieLuv sourceRef = ref MemoryMarshal.GetReference(source); ref LinearRgb destRef = ref MemoryMarshal.GetReference(destination); - for (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 LinearRgb dp = ref Unsafe.Add(ref destRef, i); @@ -108,7 +108,7 @@ public partial class ColorSpaceConverter ref CieXyy sourceRef = ref MemoryMarshal.GetReference(source); ref LinearRgb destRef = ref MemoryMarshal.GetReference(destination); - for (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 LinearRgb dp = ref Unsafe.Add(ref destRef, i); @@ -129,7 +129,7 @@ public partial class ColorSpaceConverter ref CieXyz sourceRef = ref MemoryMarshal.GetReference(source); ref LinearRgb destRef = ref MemoryMarshal.GetReference(destination); - for (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 LinearRgb dp = ref Unsafe.Add(ref destRef, i); @@ -150,7 +150,7 @@ public partial class ColorSpaceConverter ref Cmyk sourceRef = ref MemoryMarshal.GetReference(source); ref LinearRgb destRef = ref MemoryMarshal.GetReference(destination); - for (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 LinearRgb dp = ref Unsafe.Add(ref destRef, i); @@ -171,7 +171,7 @@ public partial class ColorSpaceConverter ref Hsl sourceRef = ref MemoryMarshal.GetReference(source); ref LinearRgb destRef = ref MemoryMarshal.GetReference(destination); - for (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 LinearRgb dp = ref Unsafe.Add(ref destRef, i); @@ -192,7 +192,7 @@ public partial class ColorSpaceConverter ref Hsv sourceRef = ref MemoryMarshal.GetReference(source); ref LinearRgb destRef = ref MemoryMarshal.GetReference(destination); - for (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 LinearRgb dp = ref Unsafe.Add(ref destRef, i); @@ -213,7 +213,7 @@ public partial class ColorSpaceConverter ref HunterLab sourceRef = ref MemoryMarshal.GetReference(source); ref LinearRgb destRef = ref MemoryMarshal.GetReference(destination); - for (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 LinearRgb dp = ref Unsafe.Add(ref destRef, i); @@ -234,7 +234,7 @@ public partial class ColorSpaceConverter ref Lms sourceRef = ref MemoryMarshal.GetReference(source); ref LinearRgb destRef = ref MemoryMarshal.GetReference(destination); - for (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 LinearRgb dp = ref Unsafe.Add(ref destRef, i); @@ -255,7 +255,7 @@ public partial class ColorSpaceConverter ref Rgb sourceRef = ref MemoryMarshal.GetReference(source); ref LinearRgb destRef = ref MemoryMarshal.GetReference(destination); - for (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 LinearRgb dp = ref Unsafe.Add(ref destRef, i); @@ -276,7 +276,7 @@ public partial class ColorSpaceConverter ref YCbCr sourceRef = ref MemoryMarshal.GetReference(source); ref LinearRgb destRef = ref MemoryMarshal.GetReference(destination); - for (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 LinearRgb dp = ref Unsafe.Add(ref destRef, i); diff --git a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Lms.cs b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Lms.cs index 291f3a5fac..56f61ef80b 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Lms.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Lms.cs @@ -24,7 +24,7 @@ public partial class ColorSpaceConverter ref CieLab sourceRef = ref MemoryMarshal.GetReference(source); 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 Lms dp = ref Unsafe.Add(ref destRef, i); @@ -45,7 +45,7 @@ public partial class ColorSpaceConverter ref CieLch sourceRef = ref MemoryMarshal.GetReference(source); ref Lms destRef = ref MemoryMarshal.GetReference(destination); - for (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 Lms dp = ref Unsafe.Add(ref destRef, i); @@ -66,7 +66,7 @@ public partial class ColorSpaceConverter ref CieLchuv sourceRef = ref MemoryMarshal.GetReference(source); ref Lms destRef = ref MemoryMarshal.GetReference(destination); - for (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 Lms dp = ref Unsafe.Add(ref destRef, i); @@ -87,7 +87,7 @@ public partial class ColorSpaceConverter ref CieLuv sourceRef = ref MemoryMarshal.GetReference(source); ref Lms destRef = ref MemoryMarshal.GetReference(destination); - for (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 Lms dp = ref Unsafe.Add(ref destRef, i); @@ -108,7 +108,7 @@ public partial class ColorSpaceConverter ref CieXyy sourceRef = ref MemoryMarshal.GetReference(source); ref Lms destRef = ref MemoryMarshal.GetReference(destination); - for (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 Lms dp = ref Unsafe.Add(ref destRef, i); @@ -129,7 +129,7 @@ public partial class ColorSpaceConverter ref CieXyz sourceRef = ref MemoryMarshal.GetReference(source); ref Lms destRef = ref MemoryMarshal.GetReference(destination); - for (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 Lms dp = ref Unsafe.Add(ref destRef, i); @@ -150,7 +150,7 @@ public partial class ColorSpaceConverter ref Cmyk sourceRef = ref MemoryMarshal.GetReference(source); ref Lms destRef = ref MemoryMarshal.GetReference(destination); - for (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 Lms dp = ref Unsafe.Add(ref destRef, i); @@ -171,7 +171,7 @@ public partial class ColorSpaceConverter ref Hsl sourceRef = ref MemoryMarshal.GetReference(source); ref Lms destRef = ref MemoryMarshal.GetReference(destination); - for (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 Lms dp = ref Unsafe.Add(ref destRef, i); @@ -192,7 +192,7 @@ public partial class ColorSpaceConverter ref Hsv sourceRef = ref MemoryMarshal.GetReference(source); ref Lms destRef = ref MemoryMarshal.GetReference(destination); - for (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 Lms dp = ref Unsafe.Add(ref destRef, i); @@ -213,7 +213,7 @@ public partial class ColorSpaceConverter ref HunterLab sourceRef = ref MemoryMarshal.GetReference(source); ref Lms destRef = ref MemoryMarshal.GetReference(destination); - for (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 Lms dp = ref Unsafe.Add(ref destRef, i); @@ -234,7 +234,7 @@ public partial class ColorSpaceConverter ref LinearRgb sourceRef = ref MemoryMarshal.GetReference(source); ref Lms destRef = ref MemoryMarshal.GetReference(destination); - for (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 Lms dp = ref Unsafe.Add(ref destRef, i); @@ -255,7 +255,7 @@ public partial class ColorSpaceConverter ref Rgb sourceRef = ref MemoryMarshal.GetReference(source); ref Lms destRef = ref MemoryMarshal.GetReference(destination); - for (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 Lms dp = ref Unsafe.Add(ref destRef, i); @@ -276,7 +276,7 @@ public partial class ColorSpaceConverter ref YCbCr sourceRef = ref MemoryMarshal.GetReference(source); ref Lms destRef = ref MemoryMarshal.GetReference(destination); - for (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 Lms dp = ref Unsafe.Add(ref destRef, i); diff --git a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Rgb.cs b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Rgb.cs index 557c294992..080e1fc4bf 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Rgb.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Rgb.cs @@ -24,7 +24,7 @@ public partial class ColorSpaceConverter ref CieLab sourceRef = ref MemoryMarshal.GetReference(source); ref Rgb destRef = ref MemoryMarshal.GetReference(destination); - for (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 Rgb dp = ref Unsafe.Add(ref destRef, i); @@ -45,7 +45,7 @@ public partial class ColorSpaceConverter ref CieLch sourceRef = ref MemoryMarshal.GetReference(source); ref Rgb destRef = ref MemoryMarshal.GetReference(destination); - for (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 Rgb dp = ref Unsafe.Add(ref destRef, i); @@ -66,7 +66,7 @@ public partial class ColorSpaceConverter ref CieLchuv sourceRef = ref MemoryMarshal.GetReference(source); ref Rgb destRef = ref MemoryMarshal.GetReference(destination); - for (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 Rgb dp = ref Unsafe.Add(ref destRef, i); @@ -87,7 +87,7 @@ public partial class ColorSpaceConverter ref CieLuv sourceRef = ref MemoryMarshal.GetReference(source); ref Rgb destRef = ref MemoryMarshal.GetReference(destination); - for (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 Rgb dp = ref Unsafe.Add(ref destRef, i); @@ -108,7 +108,7 @@ public partial class ColorSpaceConverter ref CieXyy sourceRef = ref MemoryMarshal.GetReference(source); ref Rgb destRef = ref MemoryMarshal.GetReference(destination); - for (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 Rgb dp = ref Unsafe.Add(ref destRef, i); @@ -129,7 +129,7 @@ public partial class ColorSpaceConverter ref CieXyz sourceRef = ref MemoryMarshal.GetReference(source); ref Rgb destRef = ref MemoryMarshal.GetReference(destination); - for (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 Rgb dp = ref Unsafe.Add(ref destRef, i); @@ -150,7 +150,7 @@ public partial class ColorSpaceConverter ref Cmyk sourceRef = ref MemoryMarshal.GetReference(source); ref Rgb destRef = ref MemoryMarshal.GetReference(destination); - for (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 Rgb dp = ref Unsafe.Add(ref destRef, i); @@ -171,7 +171,7 @@ public partial class ColorSpaceConverter ref Hsv sourceRef = ref MemoryMarshal.GetReference(source); ref Rgb destRef = ref MemoryMarshal.GetReference(destination); - for (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 Rgb dp = ref Unsafe.Add(ref destRef, i); @@ -192,7 +192,7 @@ public partial class ColorSpaceConverter ref Hsl sourceRef = ref MemoryMarshal.GetReference(source); ref Rgb destRef = ref MemoryMarshal.GetReference(destination); - for (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 Rgb dp = ref Unsafe.Add(ref destRef, i); @@ -213,7 +213,7 @@ public partial class ColorSpaceConverter ref HunterLab sourceRef = ref MemoryMarshal.GetReference(source); ref Rgb destRef = ref MemoryMarshal.GetReference(destination); - for (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 Rgb dp = ref Unsafe.Add(ref destRef, i); @@ -234,7 +234,7 @@ public partial class ColorSpaceConverter ref LinearRgb sourceRef = ref MemoryMarshal.GetReference(source); ref Rgb destRef = ref MemoryMarshal.GetReference(destination); - for (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 Rgb dp = ref Unsafe.Add(ref destRef, i); @@ -255,7 +255,7 @@ public partial class ColorSpaceConverter ref Lms sourceRef = ref MemoryMarshal.GetReference(source); ref Rgb destRef = ref MemoryMarshal.GetReference(destination); - for (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 Rgb dp = ref Unsafe.Add(ref destRef, i); @@ -276,7 +276,7 @@ public partial class ColorSpaceConverter ref YCbCr sourceRef = ref MemoryMarshal.GetReference(source); ref Rgb destRef = ref MemoryMarshal.GetReference(destination); - for (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 Rgb dp = ref Unsafe.Add(ref destRef, i); diff --git a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.YCbCr.cs b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.YCbCr.cs index 8ea875a3d7..da8e046ff7 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.YCbCr.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.YCbCr.cs @@ -24,7 +24,7 @@ public partial class ColorSpaceConverter ref CieLab sourceRef = ref MemoryMarshal.GetReference(source); ref YCbCr destRef = ref MemoryMarshal.GetReference(destination); - for (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 YCbCr dp = ref Unsafe.Add(ref destRef, i); @@ -45,7 +45,7 @@ public partial class ColorSpaceConverter ref CieLch sourceRef = ref MemoryMarshal.GetReference(source); ref YCbCr destRef = ref MemoryMarshal.GetReference(destination); - for (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 YCbCr dp = ref Unsafe.Add(ref destRef, i); @@ -66,7 +66,7 @@ public partial class ColorSpaceConverter ref CieLuv sourceRef = ref MemoryMarshal.GetReference(source); ref YCbCr destRef = ref MemoryMarshal.GetReference(destination); - for (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 YCbCr dp = ref Unsafe.Add(ref destRef, i); @@ -87,7 +87,7 @@ public partial class ColorSpaceConverter ref CieXyy sourceRef = ref MemoryMarshal.GetReference(source); ref YCbCr destRef = ref MemoryMarshal.GetReference(destination); - for (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 YCbCr dp = ref Unsafe.Add(ref destRef, i); @@ -108,7 +108,7 @@ public partial class ColorSpaceConverter ref CieXyz sourceRef = ref MemoryMarshal.GetReference(source); ref YCbCr destRef = ref MemoryMarshal.GetReference(destination); - for (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 YCbCr dp = ref Unsafe.Add(ref destRef, i); @@ -129,7 +129,7 @@ public partial class ColorSpaceConverter ref Cmyk sourceRef = ref MemoryMarshal.GetReference(source); ref YCbCr destRef = ref MemoryMarshal.GetReference(destination); - for (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 YCbCr dp = ref Unsafe.Add(ref destRef, i); @@ -150,7 +150,7 @@ public partial class ColorSpaceConverter ref Hsl sourceRef = ref MemoryMarshal.GetReference(source); ref YCbCr destRef = ref MemoryMarshal.GetReference(destination); - for (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 YCbCr dp = ref Unsafe.Add(ref destRef, i); @@ -171,7 +171,7 @@ public partial class ColorSpaceConverter ref Hsv sourceRef = ref MemoryMarshal.GetReference(source); ref YCbCr destRef = ref MemoryMarshal.GetReference(destination); - for (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 YCbCr dp = ref Unsafe.Add(ref destRef, i); @@ -192,7 +192,7 @@ public partial class ColorSpaceConverter ref HunterLab sourceRef = ref MemoryMarshal.GetReference(source); ref YCbCr destRef = ref MemoryMarshal.GetReference(destination); - for (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 YCbCr dp = ref Unsafe.Add(ref destRef, i); @@ -213,7 +213,7 @@ public partial class ColorSpaceConverter ref LinearRgb sourceRef = ref MemoryMarshal.GetReference(source); ref YCbCr destRef = ref MemoryMarshal.GetReference(destination); - for (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 YCbCr dp = ref Unsafe.Add(ref destRef, i); @@ -234,7 +234,7 @@ public partial class ColorSpaceConverter ref Lms sourceRef = ref MemoryMarshal.GetReference(source); ref YCbCr destRef = ref MemoryMarshal.GetReference(destination); - for (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 YCbCr dp = ref Unsafe.Add(ref destRef, i); @@ -255,7 +255,7 @@ public partial class ColorSpaceConverter ref Rgb sourceRef = ref MemoryMarshal.GetReference(source); ref YCbCr destRef = ref MemoryMarshal.GetReference(destination); - for (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 YCbCr dp = ref Unsafe.Add(ref destRef, i); diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/VonKriesChromaticAdaptation.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/VonKriesChromaticAdaptation.cs index 55ed41220d..97e9cee813 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/VonKriesChromaticAdaptation.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/VonKriesChromaticAdaptation.cs @@ -81,7 +81,7 @@ public sealed class VonKriesChromaticAdaptation : IChromaticAdaptation ref CieXyz sourceRef = ref MemoryMarshal.GetReference(source); ref CieXyz destRef = ref MemoryMarshal.GetReference(destination); - for (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 dp = ref Unsafe.Add(ref destRef, i); diff --git a/src/ImageSharp/Common/Helpers/HexConverter.cs b/src/ImageSharp/Common/Helpers/HexConverter.cs index 590b9d63c7..8c473688f3 100644 --- a/src/ImageSharp/Common/Helpers/HexConverter.cs +++ b/src/ImageSharp/Common/Helpers/HexConverter.cs @@ -16,12 +16,12 @@ internal static class HexConverter /// The number of bytes written to . public static int HexStringToBytes(ReadOnlySpan chars, Span 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)); } - 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"); } @@ -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 }; - 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 diff --git a/src/ImageSharp/Common/Helpers/Shuffle/IComponentShuffle.cs b/src/ImageSharp/Common/Helpers/Shuffle/IComponentShuffle.cs index f2135b7645..a86355135e 100644 --- a/src/ImageSharp/Common/Helpers/Shuffle/IComponentShuffle.cs +++ b/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 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 + 1) = Unsafe.Add(ref sBase, (nint)(uint)p1 + i); - Unsafe.Add(ref dBase, i + 2) = Unsafe.Add(ref sBase, (nint)(uint)p2 + i); - Unsafe.Add(ref dBase, i + 3) = Unsafe.Add(ref sBase, (nint)(uint)p3 + i); + Unsafe.Add(ref dBase, i + 0) = Unsafe.Add(ref sBase, p0 + i); + Unsafe.Add(ref dBase, i + 1) = Unsafe.Add(ref sBase, p1 + i); + Unsafe.Add(ref dBase, i + 2) = Unsafe.Add(ref sBase, p2 + i); + Unsafe.Add(ref dBase, i + 3) = Unsafe.Add(ref sBase, p3 + i); } } } @@ -86,7 +86,7 @@ internal readonly struct WXYZShuffle4 : IShuffle4 ref uint dBase = ref Unsafe.As(ref MemoryMarshal.GetReference(dest)); 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); @@ -110,7 +110,7 @@ internal readonly struct WZYXShuffle4 : IShuffle4 ref uint dBase = ref Unsafe.As(ref MemoryMarshal.GetReference(dest)); 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); @@ -134,7 +134,7 @@ internal readonly struct YZWXShuffle4 : IShuffle4 ref uint dBase = ref Unsafe.As(ref MemoryMarshal.GetReference(dest)); 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); @@ -158,7 +158,7 @@ internal readonly struct ZYXWShuffle4 : IShuffle4 ref uint dBase = ref Unsafe.As(ref MemoryMarshal.GetReference(dest)); 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); @@ -189,7 +189,7 @@ internal readonly struct XWZYShuffle4 : IShuffle4 ref uint dBase = ref Unsafe.As(ref MemoryMarshal.GetReference(dest)); 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); diff --git a/src/ImageSharp/Common/Helpers/Shuffle/IPad3Shuffle4.cs b/src/ImageSharp/Common/Helpers/Shuffle/IPad3Shuffle4.cs index 3e1084d313..6cf6eef08e 100644 --- a/src/ImageSharp/Common/Helpers/Shuffle/IPad3Shuffle4.cs +++ b/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 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 temp = stackalloc byte[4]; ref byte t = ref MemoryMarshal.GetReference(temp); ref uint tu = ref Unsafe.As(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); tu = Unsafe.As(ref s) | 0xFF000000; - Unsafe.Add(ref dBase, j + 0) = Unsafe.Add(ref t, (uint)p0); - Unsafe.Add(ref dBase, j + 1) = Unsafe.Add(ref t, (uint)p1); - Unsafe.Add(ref dBase, j + 2) = Unsafe.Add(ref t, (uint)p2); - Unsafe.Add(ref dBase, j + 3) = Unsafe.Add(ref t, (uint)p3); + Unsafe.Add(ref dBase, j + 0) = Unsafe.Add(ref t, p0); + Unsafe.Add(ref dBase, j + 1) = Unsafe.Add(ref t, p1); + Unsafe.Add(ref dBase, j + 2) = Unsafe.Add(ref t, p2); + Unsafe.Add(ref dBase, j + 3) = Unsafe.Add(ref t, p3); } } } diff --git a/src/ImageSharp/Common/Helpers/Shuffle/IShuffle3.cs b/src/ImageSharp/Common/Helpers/Shuffle/IShuffle3.cs index b149bde09d..2cd586212e 100644 --- a/src/ImageSharp/Common/Helpers/Shuffle/IShuffle3.cs +++ b/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 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 + 1) = Unsafe.Add(ref sBase, (nint)(uint)p1 + i); - Unsafe.Add(ref dBase, i + 2) = Unsafe.Add(ref sBase, (nint)(uint)p2 + i); + Unsafe.Add(ref dBase, i + 0) = Unsafe.Add(ref sBase, p0 + i); + Unsafe.Add(ref dBase, i + 1) = Unsafe.Add(ref sBase, p1 + i); + Unsafe.Add(ref dBase, i + 2) = Unsafe.Add(ref sBase, p2 + i); } } } diff --git a/src/ImageSharp/Common/Helpers/Shuffle/IShuffle4Slice3.cs b/src/ImageSharp/Common/Helpers/Shuffle/IShuffle4Slice3.cs index 1f12cea257..5e82973e33 100644 --- a/src/ImageSharp/Common/Helpers/Shuffle/IShuffle4Slice3.cs +++ b/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 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 + 1) = Unsafe.Add(ref sBase, (nint)(uint)p1 + j); - Unsafe.Add(ref dBase, i + 2) = Unsafe.Add(ref sBase, (nint)(uint)p2 + j); + Unsafe.Add(ref dBase, i + 0) = Unsafe.Add(ref sBase, p0 + j); + Unsafe.Add(ref dBase, i + 1) = Unsafe.Add(ref sBase, p1 + j); + Unsafe.Add(ref dBase, i + 2) = Unsafe.Add(ref sBase, p2 + j); } } } diff --git a/src/ImageSharp/Common/Helpers/SimdUtils.ExtendedIntrinsics.cs b/src/ImageSharp/Common/Helpers/SimdUtils.ExtendedIntrinsics.cs index 9d2da7dc83..43998d0ec9 100644 --- a/src/ImageSharp/Common/Helpers/SimdUtils.ExtendedIntrinsics.cs +++ b/src/ImageSharp/Common/Helpers/SimdUtils.ExtendedIntrinsics.cs @@ -97,12 +97,12 @@ internal static partial class SimdUtils { VerifySpanInput(source, dest, Vector.Count); - nint n = (nint)(uint)dest.Length / Vector.Count; + nuint n = (uint)(dest.Length / Vector.Count); ref Vector sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); ref Vector destBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(dest)); - for (nint i = 0; i < n; i++) + for (nuint i = 0; i < n; i++) { Vector b = Unsafe.Add(ref sourceBase, i); @@ -132,13 +132,13 @@ internal static partial class SimdUtils { VerifySpanInput(source, dest, Vector.Count); - nint n = (nint)(uint)dest.Length / Vector.Count; + nuint n = (uint)(dest.Length / Vector.Count); ref Vector sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); ref Vector destBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(dest)); - for (nint i = 0; i < n; i++) + for (nuint i = 0; i < n; i++) { ref Vector s = ref Unsafe.Add(ref sourceBase, i * 4); diff --git a/src/ImageSharp/Common/Helpers/SimdUtils.FallbackIntrinsics128.cs b/src/ImageSharp/Common/Helpers/SimdUtils.FallbackIntrinsics128.cs index 6fc36cd701..d456d8e42f 100644 --- a/src/ImageSharp/Common/Helpers/SimdUtils.FallbackIntrinsics128.cs +++ b/src/ImageSharp/Common/Helpers/SimdUtils.FallbackIntrinsics128.cs @@ -83,7 +83,7 @@ internal static partial class SimdUtils const float scale = 1f / 255f; Vector4 d = default; - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref ByteVector4 s = ref Unsafe.Add(ref sBase, i); d.X = s.X; @@ -117,7 +117,7 @@ internal static partial class SimdUtils var half = new Vector4(0.5f); var maxBytes = new Vector4(255f); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { Vector4 s = Unsafe.Add(ref sBase, i); s *= maxBytes; diff --git a/src/ImageSharp/Common/Helpers/SimdUtils.HwIntrinsics.cs b/src/ImageSharp/Common/Helpers/SimdUtils.HwIntrinsics.cs index 06b61443f3..5f83ccd6be 100644 --- a/src/ImageSharp/Common/Helpers/SimdUtils.HwIntrinsics.cs +++ b/src/ImageSharp/Common/Helpers/SimdUtils.HwIntrinsics.cs @@ -221,7 +221,7 @@ internal static partial class SimdUtils ref Vector256 destBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(dest)); - nint n = (nint)(uint)dest.Length / Vector256.Count; + nint n = (nint)(uint)(dest.Length / Vector256.Count); nint m = Numerics.Modulo4(n); nint u = n - m; @@ -391,9 +391,9 @@ internal static partial class SimdUtils ref Vector128 destBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(dest)); - nint n = (nint)(uint)source.Length / Vector128.Count; + nuint n = (uint)(source.Length / Vector128.Count); - for (nint i = 0; i < n; i += 3) + for (nuint i = 0; i < n; i += 3) { ref Vector128 vs = ref Unsafe.Add(ref sourceBase, i); @@ -454,9 +454,9 @@ internal static partial class SimdUtils ref Vector128 destBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(dest)); - nint n = (nint)(uint)source.Length / Vector128.Count; + nuint n = (uint)(source.Length / Vector128.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 v0 = ref Unsafe.Add(ref sourceBase, i); Vector128 v1 = Unsafe.Add(ref v0, 1); @@ -498,9 +498,9 @@ internal static partial class SimdUtils ref Vector128 destBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(dest)); - nint n = (nint)(uint)source.Length / Vector128.Count; + nuint n = (uint)(source.Length / Vector128.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 vs = ref Unsafe.Add(ref sourceBase, i); @@ -650,16 +650,16 @@ internal static partial class SimdUtils { VerifySpanInput(source, dest, Vector256.Count); - nint n = (nint)(uint)dest.Length / Vector256.Count; + nuint n = (uint)(dest.Length / Vector256.Count); ref Vector256 destBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(dest)); 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.Count * i; + nuint si = (uint)Vector256.Count * i; Vector256 i0 = Avx2.ConvertToVector256Int32(sourceBase + si); Vector256 i1 = Avx2.ConvertToVector256Int32(sourceBase + si + Vector256.Count); Vector256 i2 = Avx2.ConvertToVector256Int32(sourceBase + si + (Vector256.Count * 2)); @@ -683,7 +683,7 @@ internal static partial class SimdUtils // Sse VerifySpanInput(source, dest, Vector128.Count); - nint n = (nint)(uint)dest.Length / Vector128.Count; + nuint n = (uint)(dest.Length / Vector128.Count); ref Vector128 destBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(dest)); @@ -691,9 +691,9 @@ internal static partial class SimdUtils var scale = Vector128.Create(1 / (float)byte.MaxValue); Vector128 zero = Vector128.Zero; - for (nint i = 0; i < n; i++) + for (nuint i = 0; i < n; i++) { - nint si = Vector128.Count * i; + nuint si = (uint)Vector128.Count * i; Vector128 i0, i1, i2, i3; if (Sse41.IsSupported) @@ -782,7 +782,7 @@ internal static partial class SimdUtils { VerifySpanInput(source, dest, Vector256.Count); - nint n = (nint)(uint)dest.Length / Vector256.Count; + nuint n = (uint)(dest.Length / Vector256.Count); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -794,7 +794,7 @@ internal static partial class SimdUtils ref byte maskBase = ref MemoryMarshal.GetReference(PermuteMaskDeinterleave8x32); Vector256 mask = Unsafe.As>(ref maskBase); - for (nint i = 0; i < n; i++) + for (nuint i = 0; i < n; i++) { ref Vector256 s = ref Unsafe.Add(ref sourceBase, i * 4); @@ -821,7 +821,7 @@ internal static partial class SimdUtils // Sse VerifySpanInput(source, dest, Vector128.Count); - nint n = (nint)(uint)dest.Length / Vector128.Count; + nuint n = (uint)(dest.Length / Vector128.Count); ref Vector128 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -831,7 +831,7 @@ internal static partial class SimdUtils var scale = Vector128.Create((float)byte.MaxValue); - for (nint i = 0; i < n; i++) + for (nuint i = 0; i < n; i++) { ref Vector128 s = ref Unsafe.Add(ref sourceBase, i * 4); @@ -864,7 +864,7 @@ internal static partial class SimdUtils ref Vector256 bBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(blueChannel)); ref byte dBase = ref Unsafe.As(ref MemoryMarshal.GetReference(destination)); - nint count = (nint)(uint)redChannel.Length / Vector256.Count; + nuint count = (uint)(redChannel.Length / Vector256.Count); ref byte control1Bytes = ref MemoryMarshal.GetReference(PermuteMaskEvenOdd8x32); Vector256 control1 = Unsafe.As>(ref control1Bytes); @@ -875,7 +875,7 @@ internal static partial class SimdUtils Vector256 shuffleAlpha = Unsafe.As>(ref MemoryMarshal.GetReference(ShuffleMaskShiftAlpha)); - for (nint i = 0; i < count; i++) + for (nuint i = 0; i < count; i++) { Vector256 r0 = Unsafe.Add(ref rBase, i); Vector256 g0 = Unsafe.Add(ref gBase, i); @@ -936,12 +936,12 @@ internal static partial class SimdUtils ref Vector256 bBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(blueChannel)); ref Vector256 dBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - nint count = (nint)(uint)redChannel.Length / Vector256.Count; + nuint count = (uint)(redChannel.Length / Vector256.Count); ref byte control1Bytes = ref MemoryMarshal.GetReference(PermuteMaskEvenOdd8x32); Vector256 control1 = Unsafe.As>(ref control1Bytes); var a = Vector256.Create((byte)255); - for (nint i = 0; i < count; i++) + for (nuint i = 0; i < count; i++) { Vector256 r0 = Unsafe.Add(ref rBase, i); Vector256 g0 = Unsafe.Add(ref gBase, i); @@ -994,8 +994,8 @@ internal static partial class SimdUtils Vector256 r, g, b; const int bytesPerRgbStride = 24; - int count = (int)((uint)source.Length / 8); - for (nint i = 0; i < (uint)count; i++) + nuint count = (uint)source.Length / 8; + for (nuint i = 0; i < count; i++) { 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; } - int sliceCount = count * 8; + int sliceCount = (int)(count * 8); redChannel = redChannel.Slice(sliceCount); greenChannel = greenChannel.Slice(sliceCount); blueChannel = blueChannel.Slice(sliceCount); diff --git a/src/ImageSharp/Common/Helpers/SimdUtils.Pack.cs b/src/ImageSharp/Common/Helpers/SimdUtils.Pack.cs index ff8323df03..f471d0231b 100644 --- a/src/ImageSharp/Common/Helpers/SimdUtils.Pack.cs +++ b/src/ImageSharp/Common/Helpers/SimdUtils.Pack.cs @@ -86,8 +86,8 @@ internal static partial class SimdUtils ref ByteTuple4 b = ref Unsafe.As(ref MemoryMarshal.GetReference(blueChannel)); ref Rgb24 rgb = ref MemoryMarshal.GetReference(destination); - uint count = (uint)redChannel.Length / 4; - for (nint i = 0; i < count; i++) + nuint count = (uint)redChannel.Length / 4; + for (nuint i = 0; i < count; i++) { ref Rgb24 d0 = ref Unsafe.Add(ref rgb, i * 4); ref Rgb24 d1 = ref Unsafe.Add(ref d0, 1); @@ -133,9 +133,9 @@ internal static partial class SimdUtils ref ByteTuple4 b = ref Unsafe.As(ref MemoryMarshal.GetReference(blueChannel)); 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)); - 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 d1 = ref Unsafe.Add(ref d0, 1); @@ -181,7 +181,7 @@ internal static partial class SimdUtils ref byte b = ref MemoryMarshal.GetReference(blueChannel); 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); d.R = Unsafe.Add(ref r, i); @@ -201,7 +201,7 @@ internal static partial class SimdUtils ref byte b = ref MemoryMarshal.GetReference(blueChannel); ref Rgba32 rgba = ref MemoryMarshal.GetReference(destination); - for (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); d.R = Unsafe.Add(ref r, i); @@ -226,7 +226,7 @@ internal static partial class SimdUtils ref float b = ref MemoryMarshal.GetReference(blueChannel); ref Rgb24 rgb = ref MemoryMarshal.GetReference(source); - for (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); Unsafe.Add(ref r, i) = src.R; diff --git a/src/ImageSharp/Common/Helpers/SimdUtils.Shuffle.cs b/src/ImageSharp/Common/Helpers/SimdUtils.Shuffle.cs index 532f9d4fab..c1437c05e6 100644 --- a/src/ImageSharp/Common/Helpers/SimdUtils.Shuffle.cs +++ b/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 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 + 1) = Unsafe.Add(ref sBase, (nint)(uint)p1 + i); - Unsafe.Add(ref dBase, i + 2) = Unsafe.Add(ref sBase, (nint)(uint)p2 + i); - Unsafe.Add(ref dBase, i + 3) = Unsafe.Add(ref sBase, (nint)(uint)p3 + i); + Unsafe.Add(ref dBase, i + 0) = Unsafe.Add(ref sBase, p0 + i); + Unsafe.Add(ref dBase, i + 1) = Unsafe.Add(ref sBase, p1 + i); + Unsafe.Add(ref dBase, i + 2) = Unsafe.Add(ref sBase, p2 + i); + Unsafe.Add(ref dBase, i + 3) = Unsafe.Add(ref sBase, p3 + i); } } @@ -492,34 +492,34 @@ internal static partial class SimdUtils { InverseMMShuffle( control, - out int p3, - out int p2, - out int p1, - out int p0); + out uint p3, + out uint p2, + out uint p1, + out uint p0); 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, (uint)(i + 1)) = (byte)(p1 + i); - Unsafe.Add(ref spanBase, (uint)(i + 2)) = (byte)(p2 + i); - Unsafe.Add(ref spanBase, (uint)(i + 3)) = (byte)(p3 + i); + Unsafe.Add(ref spanBase, i + 0) = (byte)(p0 + i); + Unsafe.Add(ref spanBase, i + 1) = (byte)(p1 + i); + Unsafe.Add(ref spanBase, i + 2) = (byte)(p2 + i); + Unsafe.Add(ref spanBase, i + 3) = (byte)(p3 + i); } } [MethodImpl(InliningOptions.ShortMethod)] public static void InverseMMShuffle( byte control, - out int p3, - out int p2, - out int p1, - out int p0) + out uint p3, + out uint p2, + out uint p1, + out uint p0) { - p3 = (control >> 6) & 0x3; - p2 = (control >> 4) & 0x3; - p1 = (control >> 2) & 0x3; - p0 = (control >> 0) & 0x3; + p3 = (uint)((control >> 6) & 0x3); + p2 = (uint)((control >> 4) & 0x3); + p1 = (uint)((control >> 2) & 0x3); + p0 = (uint)((control >> 0) & 0x3); } } } diff --git a/src/ImageSharp/Compression/Zlib/DeflaterHuffman.cs b/src/ImageSharp/Compression/Zlib/DeflaterHuffman.cs index ebc43f8822..e4dc1945a8 100644 --- a/src/ImageSharp/Compression/Zlib/DeflaterHuffman.cs +++ b/src/ImageSharp/Compression/Zlib/DeflaterHuffman.cs @@ -286,13 +286,13 @@ internal sealed unsafe class DeflaterHuffman : IDisposable int static_len = this.extraBits; ref byte staticLLengthRef = ref MemoryMarshal.GetReference(StaticLLength); - for (nint i = 0; i < LiteralNumber; i++) + for (nuint i = 0; i < LiteralNumber; i++) { static_len += this.literalTree.Frequencies[i] * Unsafe.Add(ref staticLLengthRef, i); } 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); } @@ -625,10 +625,10 @@ internal sealed unsafe class DeflaterHuffman : IDisposable ref int valuesRef = ref MemoryMarshal.GetReference(valuesMemoryOwner.Memory.Span); 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); - nint i2 = 2 * i; + nuint i2 = 2 * i; Unsafe.Add(ref childrenRef, i2) = node; Unsafe.Add(ref childrenRef, i2 + 1) = -1; Unsafe.Add(ref valuesRef, i) = this.Frequencies[node] << 8; diff --git a/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs b/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs index a2c7058233..60f18c8023 100644 --- a/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs +++ b/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs @@ -123,8 +123,8 @@ internal sealed class BmpEncoderCore : IImageEncoderInternals BmpMetadata bmpMetadata = metadata.GetBmpMetadata(); this.bitsPerPixel ??= bmpMetadata.BitsPerPixel; - short bpp = (short)this.bitsPerPixel; - int bytesPerLine = (int)(4 * ((((uint)image.Width * (ushort)bpp) + 31) / 32)); + ushort bpp = (ushort)this.bitsPerPixel; + int bytesPerLine = (int)(4 * ((((uint)image.Width * bpp) + 31) / 32)); this.padding = bytesPerLine - (int)(image.Width * (bpp / 8F)); int colorPaletteSize = this.bitsPerPixel switch @@ -176,7 +176,7 @@ internal sealed class BmpEncoderCore : IImageEncoderInternals /// The metadata. /// The icc profile data. /// The bitmap information header. - 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 vResolution = 0; @@ -212,7 +212,7 @@ internal sealed class BmpEncoderCore : IImageEncoderInternals width: width, height: height, planes: 1, - bitsPerPixel: bpp, + bitsPerPixel: (short)bpp, imageSize: height * bytesPerLine, xPelsPerMeter: hResolution, yPelsPerMeter: vResolution, diff --git a/src/ImageSharp/Formats/ImageExtensions.Save.tt b/src/ImageSharp/Formats/ImageExtensions.Save.tt index 7498aa7c3b..64f3bde9cc 100644 --- a/src/ImageSharp/Formats/ImageExtensions.Save.tt +++ b/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) => source.Save( path, - encoder ?? source.GetConfiguration().ImageFormatsManager.FindEncoder(<#= fmt #>Format.Instance)); + encoder ?? source.GetConfiguration().ImageFormatsManager.GetEncoder(<#= fmt #>Format.Instance)); /// /// 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) => source.SaveAsync( path, - encoder ?? source.GetConfiguration().ImageFormatsManager.FindEncoder(<#= fmt #>Format.Instance), + encoder ?? source.GetConfiguration().ImageFormatsManager.GetEncoder(<#= fmt #>Format.Instance), cancellationToken); /// @@ -124,7 +124,7 @@ public static partial class ImageExtensions public static void SaveAs<#= fmt #>(this Image source, Stream stream, <#= fmt #>Encoder encoder) => source.Save( stream, - encoder ?? source.GetConfiguration().ImageFormatsManager.FindEncoder(<#= fmt #>Format.Instance)); + encoder ?? source.GetConfiguration().ImageFormatsManager.GetEncoder(<#= fmt #>Format.Instance)); /// /// 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) => source.SaveAsync( stream, - encoder ?? source.GetConfiguration().ImageFormatsManager.FindEncoder(<#= fmt #>Format.Instance), + encoder ?? source.GetConfiguration().ImageFormatsManager.GetEncoder(<#= fmt #>Format.Instance), cancellationToken); <# diff --git a/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.Generated.cs b/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.Generated.cs index e5d252f432..93bb7be36e 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.Generated.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.Generated.cs @@ -16,7 +16,7 @@ internal partial struct Block8x8F { var CMin4 = new Vector4(0F); 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.V0R = Numerics.Clamp(this.V0R + COff4, CMin4, CMax4); @@ -42,7 +42,7 @@ internal partial struct Block8x8F [MethodImpl(InliningOptions.ShortMethod)] public void NormalizeColorsAndRoundInPlaceVector8(float maximum) { - var off = new Vector(MathF.Ceiling(maximum * 0.5F)); // /2 + var off = new Vector(MathF.Ceiling(maximum * 0.5F)); var max = new Vector(maximum); ref Vector row0 = ref Unsafe.As>(ref this.V0L); diff --git a/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.Generated.tt b/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.Generated.tt index 7350edd38b..19b795c23a 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.Generated.tt +++ b/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.Generated.tt @@ -29,7 +29,7 @@ internal partial struct Block8x8F { var CMin4 = new Vector4(0F); 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)] public void NormalizeColorsAndRoundInPlaceVector8(float maximum) { - var off = new Vector(MathF.Ceiling(maximum * 0.5F)); // /2 + var off = new Vector(MathF.Ceiling(maximum * 0.5F)); var max = new Vector(maximum); <# diff --git a/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.Intrinsic.cs b/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.Intrinsic.cs index 7611d403ac..63be76f00f 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.Intrinsic.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.Intrinsic.cs @@ -41,9 +41,9 @@ internal partial struct Block8x8F ref Vector256 bBase = ref b.V0; ref Vector256 destRef = ref dest.V01; - var multiplyIntoInt16ShuffleMask = Vector256.Create(0, 1, 4, 5, 2, 3, 6, 7); + Vector256 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 row0 = Avx.ConvertToVector256Int32(Avx.Multiply(Unsafe.Add(ref aBase, i + 0), Unsafe.Add(ref bBase, i + 0))); Vector256 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 destBase = ref Unsafe.As>(ref dest); - for (nint i = 0; i < 16; i += 2) + for (nuint i = 0; i < 16; i += 2) { Vector128 left = Sse2.ConvertToVector128Int32(Sse.Multiply(Unsafe.Add(ref aBase, i + 0), Unsafe.Add(ref bBase, i + 0))); Vector128 right = Sse2.ConvertToVector128Int32(Sse.Multiply(Unsafe.Add(ref aBase, i + 1), Unsafe.Add(ref bBase, i + 1))); diff --git a/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.ScaledCopy.cs b/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.ScaledCopy.cs index e68ede9fbb..652c064ad5 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.ScaledCopy.cs +++ b/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! - 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) { ref Vector2 destBase = ref Unsafe.As(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, 1, destStride); @@ -48,12 +48,12 @@ internal partial struct Block8x8F WidenCopyRowImpl2x2(ref this.V0L, ref destBase, 7, destStride); [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 sRight = ref Unsafe.Add(ref sLeft, 1); - nint offset = 2 * row * destStride; + nuint offset = 2 * row * destStride; ref Vector4 dTopLeft = ref Unsafe.As(ref Unsafe.Add(ref destBase, offset)); ref Vector4 dBottomLeft = ref Unsafe.As(ref Unsafe.Add(ref destBase, offset + destStride)); @@ -86,23 +86,23 @@ internal partial struct Block8x8F } [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; - int y8 = y * 8; + nuint yy = y * verticalScale; + 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]; - nint baseIdx = (nint)(uint)((yy * areaStride) + xx); + float value = this[(int)(y8 + x)]; + 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; Unsafe.Add(ref areaOrigin, baseIdx + j) = value; diff --git a/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.cs b/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.cs index a0a8cd28e2..21971a8c7d 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.cs @@ -71,28 +71,34 @@ internal partial struct Block8x8F : IEquatable /// The index /// The float value at the specified index public float this[int idx] + { + get => this[(uint)idx]; + set => this[(uint)idx] = value; + } + + internal float this[nuint idx] { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { - DebugGuard.MustBeBetweenOrEqualTo(idx, 0, Size - 1, nameof(idx)); + DebugGuard.MustBeBetweenOrEqualTo((int)idx, 0, Size - 1, nameof(idx)); ref float selfRef = ref Unsafe.As(ref this); - return Unsafe.Add(ref selfRef, (nint)(uint)idx); + return Unsafe.Add(ref selfRef, idx); } [MethodImpl(MethodImplOptions.AggressiveInlining)] set { - DebugGuard.MustBeBetweenOrEqualTo(idx, 0, Size - 1, nameof(idx)); + DebugGuard.MustBeBetweenOrEqualTo((int)idx, 0, Size - 1, nameof(idx)); ref float selfRef = ref Unsafe.As(ref this); - Unsafe.Add(ref selfRef, (nint)(uint)idx) = value; + Unsafe.Add(ref selfRef, idx) = value; } } public float this[int x, int y] { - get => this[(y * 8) + x]; - set => this[(y * 8) + x] = value; + get => this[((uint)y * 8) + (uint)x]; + set => this[((uint)y * 8) + (uint)x] = value; } public static Block8x8F Load(Span data) @@ -425,7 +431,7 @@ internal partial struct Block8x8F : IEquatable Vector256 targetVector = Vector256.Create(value); ref Vector256 blockStride = ref this.V0; - for (nint i = 0; i < RowCount; i++) + for (nuint i = 0; i < RowCount; i++) { Vector256 areEqual = Avx2.CompareEqual(Avx.ConvertToVector256Int32WithTruncation(Unsafe.Add(ref this.V0, i)), targetVector); if (Avx2.MoveMask(areEqual.AsByte()) != equalityMask) @@ -439,7 +445,7 @@ internal partial struct Block8x8F : IEquatable ref float scalars = ref Unsafe.As(ref this); - for (nint i = 0; i < Size; i++) + for (nuint i = 0; i < Size; i++) { if ((int)Unsafe.Add(ref scalars, i) != value) { diff --git a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.CmykAvx.cs b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.CmykAvx.cs index 3144afa76b..07ba3648c4 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.CmykAvx.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.CmykAvx.cs @@ -32,8 +32,8 @@ internal abstract partial class JpegColorConverterBase // Used for the color conversion var scale = Vector256.Create(1 / (this.MaximumValue * this.MaximumValue)); - nint n = (nint)(uint)values.Component0.Length / Vector256.Count; - for (nint i = 0; i < n; i++) + nuint n = (uint)(values.Component0.Length / Vector256.Count); + for (nuint i = 0; i < n; i++) { ref Vector256 c = ref Unsafe.Add(ref c0Base, i); ref Vector256 m = ref Unsafe.Add(ref c1Base, i); @@ -71,8 +71,8 @@ internal abstract partial class JpegColorConverterBase var scale = Vector256.Create(maxValue); - nint n = (nint)(uint)values.Component0.Length / Vector256.Count; - for (nint i = 0; i < n; i++) + nuint n = (uint)(values.Component0.Length / Vector256.Count); + for (nuint i = 0; i < n; i++) { Vector256 ctmp = Avx.Subtract(scale, Unsafe.Add(ref srcR, i)); Vector256 mtmp = Avx.Subtract(scale, Unsafe.Add(ref srcG, i)); diff --git a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.CmykVector.cs b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.CmykVector.cs index 03d9a1532a..2e2ff08bf9 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.CmykVector.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.CmykVector.cs @@ -30,8 +30,8 @@ internal abstract partial class JpegColorConverterBase var scale = new Vector(1 / (this.MaximumValue * this.MaximumValue)); - nint n = (nint)(uint)values.Component0.Length / Vector.Count; - for (nint i = 0; i < n; i++) + nuint n = (uint)(values.Component0.Length / Vector.Count); + for (nuint i = 0; i < n; i++) { ref Vector c = ref Unsafe.Add(ref cBase, i); ref Vector m = ref Unsafe.Add(ref mBase, i); @@ -78,8 +78,8 @@ internal abstract partial class JpegColorConverterBase // Used for the color conversion var scale = new Vector(maxValue); - nint n = (nint)(uint)values.Component0.Length / Vector.Count; - for (nint i = 0; i < n; i++) + nuint n = (uint)(values.Component0.Length / Vector.Count); + for (nuint i = 0; i < n; i++) { Vector ctmp = scale - Unsafe.Add(ref srcR, i); Vector mtmp = scale - Unsafe.Add(ref srcG, i); diff --git a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.GrayScaleAvx.cs b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.GrayScaleAvx.cs index 4bb9869728..80ae6621c4 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.GrayScaleAvx.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.GrayScaleAvx.cs @@ -27,8 +27,8 @@ internal abstract partial class JpegColorConverterBase // Used for the color conversion var scale = Vector256.Create(1 / this.MaximumValue); - nint n = (nint)(uint)values.Component0.Length / Vector256.Count; - for (nint i = 0; i < n; i++) + nuint n = (uint)(values.Component0.Length / Vector256.Count); + for (nuint i = 0; i < n; i++) { ref Vector256 c0 = ref Unsafe.Add(ref c0Base, i); c0 = Avx.Multiply(c0, scale); @@ -53,8 +53,8 @@ internal abstract partial class JpegColorConverterBase var f0587 = Vector256.Create(0.587f); var f0114 = Vector256.Create(0.114f); - nint n = (nint)(uint)values.Component0.Length / Vector256.Count; - for (nint i = 0; i < n; i++) + nuint n = (uint)(values.Component0.Length / Vector256.Count); + for (nuint i = 0; i < n; i++) { ref Vector256 r = ref Unsafe.Add(ref srcRed, i); ref Vector256 g = ref Unsafe.Add(ref srcGreen, i); diff --git a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.GrayScaleScalar.cs b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.GrayScaleScalar.cs index df511594af..4d3b5c60bd 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.GrayScaleScalar.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.GrayScaleScalar.cs @@ -28,7 +28,7 @@ internal abstract partial class JpegColorConverterBase ref float valuesRef = ref MemoryMarshal.GetReference(values); float scale = 1 / maxValue; - for (nint i = 0; i < (uint)values.Length; i++) + for (nuint i = 0; i < (uint)values.Length; i++) { Unsafe.Add(ref valuesRef, i) *= scale; } diff --git a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.GrayScaleVector.cs b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.GrayScaleVector.cs index d8ba115d24..018e0ca442 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.GrayScaleVector.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.GrayScaleVector.cs @@ -24,8 +24,8 @@ internal abstract partial class JpegColorConverterBase var scale = new Vector(1 / this.MaximumValue); - nint n = (nint)(uint)values.Component0.Length / Vector.Count; - for (nint i = 0; i < n; i++) + nuint n = (uint)(values.Component0.Length / Vector.Count); + for (nuint i = 0; i < n; i++) { ref Vector c0 = ref Unsafe.Add(ref cBase, i); c0 *= scale; @@ -53,8 +53,8 @@ internal abstract partial class JpegColorConverterBase var gMult = new Vector(0.587f); var bMult = new Vector(0.114f); - nint n = (nint)(uint)values.Component0.Length / Vector.Count; - for (nint i = 0; i < n; i++) + nuint n = (uint)(values.Component0.Length / Vector.Count); + for (nuint i = 0; i < n; i++) { Vector r = Unsafe.Add(ref srcR, i); Vector g = Unsafe.Add(ref srcR, i); diff --git a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.RgbArm.cs b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.RgbArm.cs index 4a2112592f..72d8340a0f 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.RgbArm.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.RgbArm.cs @@ -30,8 +30,8 @@ internal abstract partial class JpegColorConverterBase // Used for the color conversion var scale = Vector128.Create(1 / this.MaximumValue); - nint n = (nint)(uint)values.Component0.Length / Vector128.Count; - for (nint i = 0; i < n; i++) + nuint n = (uint)(values.Component0.Length / Vector128.Count); + for (nuint i = 0; i < n; i++) { ref Vector128 r = ref Unsafe.Add(ref rBase, i); ref Vector128 g = ref Unsafe.Add(ref gBase, i); diff --git a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.RgbAvx.cs b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.RgbAvx.cs index 76b2e9936c..8c095309c7 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.RgbAvx.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.RgbAvx.cs @@ -29,8 +29,8 @@ internal abstract partial class JpegColorConverterBase // Used for the color conversion var scale = Vector256.Create(1 / this.MaximumValue); - nint n = (nint)(uint)values.Component0.Length / Vector256.Count; - for (nint i = 0; i < n; i++) + nuint n = (uint)(values.Component0.Length / Vector256.Count); + for (nuint i = 0; i < n; i++) { ref Vector256 r = ref Unsafe.Add(ref rBase, i); ref Vector256 g = ref Unsafe.Add(ref gBase, i); diff --git a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.RgbVector.cs b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.RgbVector.cs index 5d85bb0482..cbba796440 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.RgbVector.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.RgbVector.cs @@ -28,8 +28,8 @@ internal abstract partial class JpegColorConverterBase var scale = new Vector(1 / this.MaximumValue); - nint n = (nint)(uint)values.Component0.Length / Vector.Count; - for (nint i = 0; i < n; i++) + nuint n = (uint)(values.Component0.Length / Vector.Count); + for (nuint i = 0; i < n; i++) { ref Vector r = ref Unsafe.Add(ref rBase, i); ref Vector g = ref Unsafe.Add(ref gBase, i); diff --git a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YCbCrAvx.cs b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YCbCrAvx.cs index 59f24493a1..e828ba1179 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YCbCrAvx.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YCbCrAvx.cs @@ -38,8 +38,8 @@ internal abstract partial class JpegColorConverterBase var bCbMult = Vector256.Create(YCbCrScalar.BCbMult); // Walking 8 elements at one step: - nint n = (nint)(uint)values.Component0.Length / Vector256.Count; - for (nint i = 0; i < n; i++) + nuint n = (uint)(values.Component0.Length / Vector256.Count); + for (nuint i = 0; i < n; i++) { // y = yVals[i]; // cb = cbVals[i] - 128F; @@ -98,8 +98,8 @@ internal abstract partial class JpegColorConverterBase var fn0081312F = Vector256.Create(-0.081312F); var f05 = Vector256.Create(0.5f); - nint n = (nint)(uint)values.Component0.Length / Vector256.Count; - for (nint i = 0; i < n; i++) + nuint n = (uint)(values.Component0.Length / Vector256.Count); + for (nuint i = 0; i < n; i++) { Vector256 r = Unsafe.Add(ref srcR, i); Vector256 g = Unsafe.Add(ref srcG, i); diff --git a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YCbCrVector.cs b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YCbCrVector.cs index 0f7a364868..e3b4be235f 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YCbCrVector.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YCbCrVector.cs @@ -35,8 +35,8 @@ internal abstract partial class JpegColorConverterBase var gCrMult = new Vector(-YCbCrScalar.GCrMult); var bCbMult = new Vector(YCbCrScalar.BCbMult); - nint n = (nint)(uint)values.Component0.Length / Vector.Count; - for (nint i = 0; i < n; i++) + nuint n = (uint)(values.Component0.Length / Vector.Count); + for (nuint i = 0; i < n; i++) { // y = yVals[i]; // cb = cbVals[i] - 128F; @@ -103,8 +103,8 @@ internal abstract partial class JpegColorConverterBase var gCrMult = new Vector(0.418688f); var bCrMult = new Vector(0.081312f); - nint n = (nint)(uint)values.Component0.Length / Vector.Count; - for (nint i = 0; i < n; i++) + nuint n = (uint)(values.Component0.Length / Vector.Count); + for (nuint i = 0; i < n; i++) { Vector r = Unsafe.Add(ref srcR, i); Vector g = Unsafe.Add(ref srcG, i); diff --git a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YccKAvx.cs b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YccKAvx.cs index 0cfb3201b4..8ab2dd3d67 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YccKAvx.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YccKAvx.cs @@ -40,8 +40,8 @@ internal abstract partial class JpegColorConverterBase var bCbMult = Vector256.Create(YCbCrScalar.BCbMult); // Walking 8 elements at one step: - nint n = (nint)(uint)values.Component0.Length / Vector256.Count; - for (nint i = 0; i < n; i++) + nuint n = (uint)(values.Component0.Length / Vector256.Count); + for (nuint i = 0; i < n; i++) { // y = yVals[i]; // cb = cbVals[i] - 128F; @@ -109,8 +109,8 @@ internal abstract partial class JpegColorConverterBase var fn0081312F = Vector256.Create(-0.081312F); var f05 = Vector256.Create(0.5f); - nint n = (nint)(uint)values.Component0.Length / Vector256.Count; - for (nint i = 0; i < n; i++) + nuint n = (uint)(values.Component0.Length / Vector256.Count); + for (nuint i = 0; i < n; i++) { Vector256 r = Avx.Subtract(maxSampleValue, Unsafe.Add(ref srcR, i)); Vector256 g = Avx.Subtract(maxSampleValue, Unsafe.Add(ref srcG, i)); diff --git a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YccKVector.cs b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YccKVector.cs index feefe3021d..711b0fe3bb 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YccKVector.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YccKVector.cs @@ -36,8 +36,8 @@ internal abstract partial class JpegColorConverterBase var gCrMult = new Vector(-YCbCrScalar.GCrMult); var bCbMult = new Vector(YCbCrScalar.BCbMult); - nint n = (nint)(uint)values.Component0.Length / Vector.Count; - for (nint i = 0; i < n; i++) + nuint n = (uint)(values.Component0.Length / Vector.Count); + for (nuint i = 0; i < n; i++) { // y = yVals[i]; // cb = cbVals[i] - 128F; @@ -107,8 +107,8 @@ internal abstract partial class JpegColorConverterBase var gCrMult = new Vector(0.418688f); var bCrMult = new Vector(0.081312f); - nint n = (nint)(uint)values.Component0.Length / Vector.Count; - for (nint i = 0; i < n; i++) + nuint n = (uint)(values.Component0.Length / Vector.Count); + for (nuint i = 0; i < n; i++) { Vector r = maxSampleValue - Unsafe.Add(ref srcR, i); Vector g = maxSampleValue - Unsafe.Add(ref srcG, i); diff --git a/src/ImageSharp/Formats/Jpeg/Components/Decoder/ArithmeticScanDecoder.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/ArithmeticScanDecoder.cs index fcefe542d4..5ecf779615 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Decoder/ArithmeticScanDecoder.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Decoder/ArithmeticScanDecoder.cs @@ -470,7 +470,7 @@ internal class ArithmeticScanDecoder : IJpegScanDecoder this.DecodeBlockBaseline( component, - ref Unsafe.Add(ref blockRef, (nint)(uint)blockCol), + ref Unsafe.Add(ref blockRef, (uint)blockCol), ref acDecodingTable, ref dcDecodingTable); } @@ -521,7 +521,7 @@ internal class ArithmeticScanDecoder : IJpegScanDecoder this.DecodeBlockBaseline( component, - ref Unsafe.Add(ref blockRef, (nint)(uint)k), + ref Unsafe.Add(ref blockRef, (uint)k), ref acDecodingTable, ref dcDecodingTable); @@ -560,7 +560,7 @@ internal class ArithmeticScanDecoder : IJpegScanDecoder this.DecodeBlockBaseline( component, - ref Unsafe.Add(ref blockRef, (nint)(uint)i), + ref Unsafe.Add(ref blockRef, (uint)i), ref acDecodingTable, ref dcDecodingTable); @@ -611,7 +611,7 @@ internal class ArithmeticScanDecoder : IJpegScanDecoder this.DecodeBlockProgressiveDc( component, - ref Unsafe.Add(ref blockRef, (nint)(uint)blockCol), + ref Unsafe.Add(ref blockRef, (uint)blockCol), ref dcDecodingTable); } } @@ -653,7 +653,7 @@ internal class ArithmeticScanDecoder : IJpegScanDecoder this.DecodeBlockProgressiveDc( component, - ref Unsafe.Add(ref blockRef, (nint)(uint)i), + ref Unsafe.Add(ref blockRef, (uint)i), ref dcDecodingTable); this.HandleRestart(); @@ -680,7 +680,7 @@ internal class ArithmeticScanDecoder : IJpegScanDecoder this.DecodeBlockProgressiveAc( component, - ref Unsafe.Add(ref blockRef, (nint)(uint)i), + ref Unsafe.Add(ref blockRef, (uint)i), ref acDecodingTable); this.HandleRestart(); @@ -717,7 +717,7 @@ internal class ArithmeticScanDecoder : IJpegScanDecoder // Figure F.21: Decoding nonzero value v. // Figure F.22: Decoding the sign of v. 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. 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.22: Decoding the sign of v 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. int m = this.DecodeBinaryDecision(ref reader, ref st); diff --git a/src/ImageSharp/Formats/Jpeg/Components/Decoder/ComponentProcessors/DownScalingComponentProcessor2.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/ComponentProcessors/DownScalingComponentProcessor2.cs index 8b4256e3b9..0ec7500e0d 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Decoder/ComponentProcessors/DownScalingComponentProcessor2.cs +++ b/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) { // 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)] - 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; - int y8 = y * 8; + nuint yy = y * verticalScale; + 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]; - 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; - Unsafe.Add(ref areaOrigin, (nint)(uint)(baseIdx + j)) = value; + Unsafe.Add(ref areaOrigin, baseIdx + j) = value; } } } diff --git a/src/ImageSharp/Formats/Jpeg/Components/Decoder/ComponentProcessors/DownScalingComponentProcessor4.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/ComponentProcessors/DownScalingComponentProcessor4.cs index 170cdbb3c8..99daaa49e7 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Decoder/ComponentProcessors/DownScalingComponentProcessor4.cs +++ b/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) { // 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)] - 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; - int y8 = y * 8; + nuint yy = y * verticalScale; + 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]; - 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; - Unsafe.Add(ref areaOrigin, (nint)(uint)(baseIdx + j)) = value; + Unsafe.Add(ref areaOrigin, baseIdx + j) = value; } } } diff --git a/src/ImageSharp/Formats/Jpeg/Components/Decoder/ComponentProcessors/DownScalingComponentProcessor8.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/ComponentProcessors/DownScalingComponentProcessor8.cs index 81104d2f3d..cf321d7cd9 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Decoder/ComponentProcessors/DownScalingComponentProcessor8.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Decoder/ComponentProcessors/DownScalingComponentProcessor8.cs @@ -67,20 +67,20 @@ internal sealed class DownScalingComponentProcessor8 : ComponentProcessor { destRef = value; Unsafe.Add(ref destRef, 1) = value; - Unsafe.Add(ref destRef, 0 + (nint)(uint)destStrideWidth) = value; - Unsafe.Add(ref destRef, 1 + (nint)(uint)destStrideWidth) = value; + Unsafe.Add(ref destRef, 0 + (uint)destStrideWidth) = value; + Unsafe.Add(ref destRef, 1 + (uint)destStrideWidth) = value; return; } // 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); } } } diff --git a/src/ImageSharp/Formats/Jpeg/Components/Encoder/ComponentProcessor.cs b/src/ImageSharp/Formats/Jpeg/Components/Encoder/ComponentProcessor.cs index 3c89ab1fb6..9b08175051 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Encoder/ComponentProcessor.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Encoder/ComponentProcessor.cs @@ -122,8 +122,8 @@ internal class ComponentProcessor : IDisposable ref Vector256 sourceVectorRef = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); // Spans are guaranteed to be multiple of 8 so no extra 'remainder' steps are needed - nint count = (nint)(uint)source.Length / Vector256.Count; - for (nint i = 0; i < count; i++) + nuint count = (uint)(source.Length / Vector256.Count); + for (nuint i = 0; i < count; 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 targetVectorRef = ref Unsafe.As>(ref MemoryMarshal.GetReference(target)); ref Vector sourceVectorRef = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); - nint count = (nint)(uint)source.Length / Vector.Count; - for (nint i = 0; i < count; i++) + nuint count = (uint)(source.Length / Vector.Count); + for (nuint i = 0; i < count; i++) { Unsafe.Add(ref targetVectorRef, i) += Unsafe.Add(ref sourceVectorRef, i); } ref float targetRef = ref MemoryMarshal.GetReference(target); ref float sourceRef = ref MemoryMarshal.GetReference(source); - for (nint i = count * Vector.Count; i < (uint)source.Length; i++) + for (nuint i = count * (uint)Vector.Count; i < (uint)source.Length; i++) { Unsafe.Add(ref targetRef, i) += Unsafe.Add(ref sourceRef, i); } @@ -166,16 +166,16 @@ internal class ComponentProcessor : IDisposable source = source.Slice(touchedCount); target = target.Slice(touchedCount / factor); - nint length = (nint)(uint)touchedCount / Vector256.Count; + nuint length = (uint)(touchedCount / Vector256.Count); for (int i = 0; i < haddIterationsCount; i++) { length /= 2; - for (nint j = 0; j < length; j++) + for (nuint j = 0; j < length; j++) { - nint indexLeft = j * 2; - nint indexRight = indexLeft + 1; + nuint indexLeft = j * 2; + nuint indexRight = indexLeft + 1; Vector256 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(); } @@ -200,9 +200,9 @@ internal class ComponentProcessor : IDisposable ref Vector256 targetVectorRef = ref Unsafe.As>(ref MemoryMarshal.GetReference(target)); // Spans are guaranteed to be multiple of 8 so no extra 'remainder' steps are needed - nint count = (nint)(uint)target.Length / Vector256.Count; + nuint count = (uint)(target.Length / Vector256.Count); 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); } @@ -211,15 +211,15 @@ internal class ComponentProcessor : IDisposable { ref Vector targetVectorRef = ref Unsafe.As>(ref MemoryMarshal.GetReference(target)); - nint count = (nint)(uint)target.Length / Vector.Count; + nuint count = (uint)(target.Length / Vector.Count); var multiplierVector = new Vector(multiplier); - for (nint i = 0; i < count; i++) + for (nuint i = 0; i < count; i++) { Unsafe.Add(ref targetVectorRef, i) *= multiplierVector; } ref float targetRef = ref MemoryMarshal.GetReference(target); - for (nint i = count * Vector.Count; i < (uint)target.Length; i++) + for (nuint i = count * (uint)Vector.Count; i < (uint)target.Length; i++) { Unsafe.Add(ref targetRef, i) *= multiplier; } diff --git a/src/ImageSharp/Formats/Jpeg/Components/Encoder/HuffmanScanEncoder.cs b/src/ImageSharp/Formats/Jpeg/Components/Encoder/HuffmanScanEncoder.cs index 1453b0a568..d74494f9e5 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Encoder/HuffmanScanEncoder.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Encoder/HuffmanScanEncoder.cs @@ -180,7 +180,7 @@ internal class HuffmanScanEncoder Span blockSpan = component.SpectralBlocks.DangerousGetRowSpan(y: 0); 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( component, @@ -219,7 +219,7 @@ internal class HuffmanScanEncoder Span blockSpan = component.SpectralBlocks.DangerousGetRowSpan(y: i); 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( component, @@ -246,9 +246,9 @@ internal class HuffmanScanEncoder private void EncodeScanBaselineInterleaved(JpegFrame frame, SpectralConverter converter, CancellationToken cancellationToken) where TPixel : unmanaged, IPixel { - nint mcu = 0; - nint mcusPerColumn = frame.McusPerColumn; - nint mcusPerLine = frame.McusPerLine; + int mcu = 0; + int mcusPerColumn = frame.McusPerColumn; + int mcusPerLine = frame.McusPerLine; for (int j = 0; j < mcusPerColumn; j++) { @@ -258,21 +258,21 @@ internal class HuffmanScanEncoder converter.ConvertStrideBaseline(); // 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 - nint mcuCol = mcu % mcusPerLine; - for (nint k = 0; k < frame.Components.Length; k++) + int mcuCol = mcu % mcusPerLine; + for (int k = 0; k < frame.Components.Length; k++) { Component component = frame.Components[k]; ref HuffmanLut dcHuffmanTable = ref this.dcHuffmanTables[component.DcTableId]; ref HuffmanLut acHuffmanTable = ref this.acHuffmanTables[component.AcTableId]; - nint h = component.HorizontalSamplingFactor; + int h = component.HorizontalSamplingFactor; 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 // by the basic H and V specified for the component @@ -281,9 +281,9 @@ internal class HuffmanScanEncoder Span blockSpan = component.SpectralBlocks.DangerousGetRowSpan(y); 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( component, @@ -315,8 +315,8 @@ internal class HuffmanScanEncoder private void EncodeThreeComponentBaselineInterleavedScanNoSubsampling(JpegFrame frame, SpectralConverter converter, CancellationToken cancellationToken) where TPixel : unmanaged, IPixel { - nint mcusPerColumn = frame.McusPerColumn; - nint mcusPerLine = frame.McusPerLine; + nuint mcusPerColumn = (uint)frame.McusPerColumn; + nuint mcusPerLine = (uint)frame.McusPerLine; Component c2 = frame.Components[2]; 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 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(); @@ -341,7 +341,7 @@ internal class HuffmanScanEncoder converter.ConvertStrideBaseline(); // Encode spectral to binary - for (nint i = 0; i < mcusPerLine; i++) + for (nuint i = 0; i < mcusPerLine; i++) { this.WriteBlock( c0, diff --git a/src/ImageSharp/Formats/Jpeg/Components/FloatingPointDCT.cs b/src/ImageSharp/Formats/Jpeg/Components/FloatingPointDCT.cs index 15348d4474..0aca33b4c9 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/FloatingPointDCT.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/FloatingPointDCT.cs @@ -69,7 +69,7 @@ internal static partial class FloatingPointDCT { ref float tableRef = ref Unsafe.As(ref quantTable); ref float multipliersRef = ref MemoryMarshal.GetReference(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); elemRef = 0.125f * elemRef * Unsafe.Add(ref multipliersRef, i); @@ -88,7 +88,7 @@ internal static partial class FloatingPointDCT { ref float tableRef = ref Unsafe.As(ref quantTable); ref float multipliersRef = ref MemoryMarshal.GetReference(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); elemRef = 0.125f / (elemRef * Unsafe.Add(ref multipliersRef, i)); diff --git a/src/ImageSharp/Formats/Jpeg/Components/ScaledFloatingPointDCT.cs b/src/ImageSharp/Formats/Jpeg/Components/ScaledFloatingPointDCT.cs index 4f67b7dfe9..1a2767308f 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/ScaledFloatingPointDCT.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/ScaledFloatingPointDCT.cs @@ -40,7 +40,7 @@ internal static class ScaledFloatingPointDCT public static void AdjustToIDCT(ref Block8x8F quantTable) { ref float tableRef = ref Unsafe.As(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); elemRef = 0.125f * elemRef; diff --git a/src/ImageSharp/Formats/Png/Filters/AverageFilter.cs b/src/ImageSharp/Formats/Png/Filters/AverageFilter.cs index 0e601f5262..2750aa6808 100644 --- a/src/ImageSharp/Formats/Png/Filters/AverageFilter.cs +++ b/src/ImageSharp/Formats/Png/Filters/AverageFilter.cs @@ -42,7 +42,7 @@ internal static class AverageFilter } else { - DecodeScalar(scanline, previousScanline, (nint)(uint)bytesPerPixel); + DecodeScalar(scanline, previousScanline, (uint)bytesPerPixel); } } @@ -56,7 +56,7 @@ internal static class AverageFilter Vector128 ones = Vector128.Create((byte)1); int rb = scanline.Length; - nint offset = 1; + nuint offset = 1; while (rb >= 4) { ref byte scanRef = ref Unsafe.Add(ref scanBaseRef, offset); @@ -88,7 +88,7 @@ internal static class AverageFilter Vector64 d = Vector64.Zero; int rb = scanline.Length; - nint offset = 1; + nuint offset = 1; const int bytesPerBatch = 4; while (rb >= bytesPerBatch) { @@ -108,12 +108,12 @@ internal static class AverageFilter } [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static void DecodeScalar(Span scanline, Span previousScanline, nint bytesPerPixel) + private static void DecodeScalar(Span scanline, Span previousScanline, uint bytesPerPixel) { ref byte scanBaseRef = ref MemoryMarshal.GetReference(scanline); ref byte prevBaseRef = ref MemoryMarshal.GetReference(previousScanline); - nint x = 1; + nuint x = 1; for (; x <= bytesPerPixel /* Note the <= because x starts at 1 */; ++x) { ref byte scan = ref Unsafe.Add(ref scanBaseRef, x); @@ -139,7 +139,7 @@ internal static class AverageFilter /// The bytes per pixel. /// The sum of the total variance of the filtered row. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void Encode(ReadOnlySpan scanline, ReadOnlySpan previousScanline, Span result, int bytesPerPixel, out int sum) + public static void Encode(ReadOnlySpan scanline, ReadOnlySpan previousScanline, Span result, uint bytesPerPixel, out int sum) { DebugGuard.MustBeSameSized(scanline, previousScanline, nameof(scanline)); 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) resultBaseRef = (byte)FilterType.Average; - nint x = 0; - for (; x < (uint)bytesPerPixel; /* Note: ++x happens in the body to avoid one add operation */) + nuint x = 0; + for (; x < bytesPerPixel; /* Note: ++x happens in the body to avoid one add operation */) { byte scan = Unsafe.Add(ref scanBaseRef, x); byte above = Unsafe.Add(ref prevBaseRef, x); @@ -169,7 +169,7 @@ internal static class AverageFilter Vector256 sumAccumulator = Vector256.Zero; Vector256 allBitsSet = Avx2.CompareEqual(sumAccumulator, sumAccumulator).AsByte(); - for (nint xLeft = x - (nint)(uint)bytesPerPixel; x <= (uint)scanline.Length - Vector256.Count; xLeft += Vector256.Count) + for (nuint xLeft = x - bytesPerPixel; x <= (uint)(scanline.Length - Vector256.Count); xLeft += (uint)Vector256.Count) { Vector256 scan = Unsafe.As>(ref Unsafe.Add(ref scanBaseRef, x)); Vector256 left = Unsafe.As>(ref Unsafe.Add(ref scanBaseRef, xLeft)); @@ -179,7 +179,7 @@ internal static class AverageFilter Vector256 res = Avx2.Subtract(scan, avg); Unsafe.As>(ref Unsafe.Add(ref resultBaseRef, x + 1)) = res; // +1 to skip filter type - x += Vector256.Count; + x += (uint)Vector256.Count; sumAccumulator = Avx2.Add(sumAccumulator, Avx2.SumAbsoluteDifferences(Avx2.Abs(res.AsSByte()), zero).AsInt32()); } @@ -192,7 +192,7 @@ internal static class AverageFilter Vector128 sumAccumulator = Vector128.Zero; Vector128 allBitsSet = Sse2.CompareEqual(sumAccumulator, sumAccumulator).AsByte(); - for (nint xLeft = x - (nint)(uint)bytesPerPixel; x <= (uint)scanline.Length - Vector128.Count; xLeft += Vector128.Count) + for (nuint xLeft = x - bytesPerPixel; x <= (uint)(scanline.Length - Vector128.Count); xLeft += (uint)Vector128.Count) { Vector128 scan = Unsafe.As>(ref Unsafe.Add(ref scanBaseRef, x)); Vector128 left = Unsafe.As>(ref Unsafe.Add(ref scanBaseRef, xLeft)); @@ -202,7 +202,7 @@ internal static class AverageFilter Vector128 res = Sse2.Subtract(scan, avg); Unsafe.As>(ref Unsafe.Add(ref resultBaseRef, x + 1)) = res; // +1 to skip filter type - x += Vector128.Count; + x += (uint)Vector128.Count; Vector128 absRes; if (Ssse3.IsSupported) @@ -221,7 +221,7 @@ internal static class AverageFilter 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 left = Unsafe.Add(ref scanBaseRef, xLeft); diff --git a/src/ImageSharp/Formats/Png/Filters/PaethFilter.cs b/src/ImageSharp/Formats/Png/Filters/PaethFilter.cs index 540ec63231..f2226974c9 100644 --- a/src/ImageSharp/Formats/Png/Filters/PaethFilter.cs +++ b/src/ImageSharp/Formats/Png/Filters/PaethFilter.cs @@ -45,7 +45,7 @@ internal static class PaethFilter } else { - DecodeScalar(scanline, previousScanline, bytesPerPixel); + DecodeScalar(scanline, previousScanline, (uint)bytesPerPixel); } } @@ -59,7 +59,7 @@ internal static class PaethFilter Vector128 d = Vector128.Zero; int rb = scanline.Length; - nint offset = 1; + nuint offset = 1; while (rb >= 4) { ref byte scanRef = ref Unsafe.Add(ref scanBaseRef, offset); @@ -113,7 +113,7 @@ internal static class PaethFilter Vector128 d = Vector128.Zero; int rb = scanline.Length; - nint offset = 1; + nuint offset = 1; const int bytesPerBatch = 4; while (rb >= bytesPerBatch) { @@ -179,15 +179,15 @@ internal static class PaethFilter } [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static void DecodeScalar(Span scanline, Span previousScanline, int bytesPerPixel) + private static void DecodeScalar(Span scanline, Span previousScanline, uint bytesPerPixel) { ref byte scanBaseRef = ref MemoryMarshal.GetReference(scanline); ref byte prevBaseRef = ref MemoryMarshal.GetReference(previousScanline); // Paeth(x) + PaethPredictor(Raw(x-bpp), Prior(x), Prior(x-bpp)) - int offset = bytesPerPixel + 1; // Add one because x starts at one. - nint x = 1; - for (; x < (uint)offset; x++) + nuint offset = bytesPerPixel + 1; // Add one because x starts at one. + nuint x = 1; + for (; x < offset; x++) { ref byte scan = ref Unsafe.Add(ref scanBaseRef, 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)) 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 */) { byte scan = Unsafe.Add(ref scanBaseRef, x); @@ -242,7 +242,7 @@ internal static class PaethFilter Vector256 zero = Vector256.Zero; Vector256 sumAccumulator = Vector256.Zero; - for (nint xLeft = x - (nint)(uint)bytesPerPixel; x <= (nint)(uint)scanline.Length - Vector256.Count; xLeft += Vector256.Count) + for (nuint xLeft = x - (uint)bytesPerPixel; (int)x <= scanline.Length - Vector256.Count; xLeft += (uint)Vector256.Count) { Vector256 scan = Unsafe.As>(ref Unsafe.Add(ref scanBaseRef, x)); Vector256 left = Unsafe.As>(ref Unsafe.Add(ref scanBaseRef, xLeft)); @@ -251,7 +251,7 @@ internal static class PaethFilter Vector256 res = Avx2.Subtract(scan, PaethPredictor(left, above, upperLeft)); Unsafe.As>(ref Unsafe.Add(ref resultBaseRef, x + 1)) = res; // +1 to skip filter type - x += Vector256.Count; + x += (uint)Vector256.Count; sumAccumulator = Avx2.Add(sumAccumulator, Avx2.SumAbsoluteDifferences(Avx2.Abs(res.AsSByte()), zero).AsInt32()); } @@ -262,7 +262,7 @@ internal static class PaethFilter { Vector sumAccumulator = Vector.Zero; - for (nint xLeft = x - (nint)(uint)bytesPerPixel; x <= (nint)(uint)scanline.Length - Vector.Count; xLeft += Vector.Count) + for (nuint xLeft = x - (uint)bytesPerPixel; (int)x <= scanline.Length - Vector.Count; xLeft += (uint)Vector.Count) { Vector scan = Unsafe.As>(ref Unsafe.Add(ref scanBaseRef, x)); Vector left = Unsafe.As>(ref Unsafe.Add(ref scanBaseRef, xLeft)); @@ -271,7 +271,7 @@ internal static class PaethFilter Vector res = scan - PaethPredictor(left, above, upperLeft); Unsafe.As>(ref Unsafe.Add(ref resultBaseRef, x + 1)) = res; // +1 to skip filter type - x += Vector.Count; + x += (uint)Vector.Count; 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 left = Unsafe.Add(ref scanBaseRef, xLeft); diff --git a/src/ImageSharp/Formats/Png/Filters/SubFilter.cs b/src/ImageSharp/Formats/Png/Filters/SubFilter.cs index 5dc7b15d74..d58ac6fb7b 100644 --- a/src/ImageSharp/Formats/Png/Filters/SubFilter.cs +++ b/src/ImageSharp/Formats/Png/Filters/SubFilter.cs @@ -36,7 +36,7 @@ internal static class SubFilter } else { - DecodeScalar(scanline, (nint)(uint)bytesPerPixel); + DecodeScalar(scanline, (uint)bytesPerPixel); } } @@ -47,7 +47,7 @@ internal static class SubFilter Vector128 d = Vector128.Zero; int rb = scanline.Length; - nint offset = 1; + nuint offset = 1; while (rb >= 4) { ref byte scanRef = ref Unsafe.Add(ref scanBaseRef, offset); @@ -70,7 +70,7 @@ internal static class SubFilter Vector64 d = Vector64.Zero; int rb = scanline.Length; - nint offset = 1; + nuint offset = 1; const int bytesPerBatch = 4; while (rb >= bytesPerBatch) { @@ -87,14 +87,14 @@ internal static class SubFilter } } - private static void DecodeScalar(Span scanline, nint bytesPerPixel) + private static void DecodeScalar(Span scanline, nuint bytesPerPixel) { ref byte scanBaseRef = ref MemoryMarshal.GetReference(scanline); // Sub(x) + Raw(x-bpp) - nint x = bytesPerPixel + 1; + nuint x = bytesPerPixel + 1; 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); byte prev = Unsafe.Add(ref scanBaseRef, x - bytesPerPixel); @@ -121,8 +121,8 @@ internal static class SubFilter // Sub(x) = Raw(x) - Raw(x-bpp) resultBaseRef = (byte)FilterType.Sub; - nint x = 0; - for (; x < (nint)(uint)bytesPerPixel; /* Note: ++x happens in the body to avoid one add operation */) + nuint x = 0; + for (; x < (uint)bytesPerPixel; /* Note: ++x happens in the body to avoid one add operation */) { byte scan = Unsafe.Add(ref scanBaseRef, x); ++x; @@ -136,14 +136,14 @@ internal static class SubFilter Vector256 zero = Vector256.Zero; Vector256 sumAccumulator = Vector256.Zero; - for (nint xLeft = x - (nint)(uint)bytesPerPixel; x <= (nint)(uint)scanline.Length - Vector256.Count; xLeft += Vector256.Count) + for (nuint xLeft = x - (uint)bytesPerPixel; x <= (uint)(scanline.Length - Vector256.Count); xLeft += (uint)Vector256.Count) { Vector256 scan = Unsafe.As>(ref Unsafe.Add(ref scanBaseRef, x)); Vector256 prev = Unsafe.As>(ref Unsafe.Add(ref scanBaseRef, xLeft)); Vector256 res = Avx2.Subtract(scan, prev); Unsafe.As>(ref Unsafe.Add(ref resultBaseRef, x + 1)) = res; // +1 to skip filter type - x += Vector256.Count; + x += (uint)Vector256.Count; sumAccumulator = Avx2.Add(sumAccumulator, Avx2.SumAbsoluteDifferences(Avx2.Abs(res.AsSByte()), zero).AsInt32()); } @@ -154,14 +154,14 @@ internal static class SubFilter { Vector sumAccumulator = Vector.Zero; - for (nint xLeft = x - (nint)(uint)bytesPerPixel; x <= (nint)(uint)scanline.Length - Vector.Count; xLeft += Vector.Count) + for (nuint xLeft = x - (uint)bytesPerPixel; x <= (uint)(scanline.Length - Vector.Count); xLeft += (uint)Vector.Count) { Vector scan = Unsafe.As>(ref Unsafe.Add(ref scanBaseRef, x)); Vector prev = Unsafe.As>(ref Unsafe.Add(ref scanBaseRef, xLeft)); Vector res = scan - prev; Unsafe.As>(ref Unsafe.Add(ref resultBaseRef, x + 1)) = res; // +1 to skip filter type - x += Vector.Count; + x += (uint)Vector.Count; 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 prev = Unsafe.Add(ref scanBaseRef, xLeft); diff --git a/src/ImageSharp/Formats/Png/Filters/UpFilter.cs b/src/ImageSharp/Formats/Png/Filters/UpFilter.cs index 55cc9ad6eb..dd3c2d8612 100644 --- a/src/ImageSharp/Formats/Png/Filters/UpFilter.cs +++ b/src/ImageSharp/Formats/Png/Filters/UpFilter.cs @@ -52,7 +52,7 @@ internal static class UpFilter // Up(x) + Prior(x) int rb = scanline.Length; - nint offset = 1; + nuint offset = 1; while (rb >= Vector256.Count) { ref byte scanRef = ref Unsafe.Add(ref scanBaseRef, offset); @@ -61,12 +61,12 @@ internal static class UpFilter Unsafe.As>(ref scanRef) = Avx2.Add(up, prior); - offset += Vector256.Count; + offset += (uint)Vector256.Count; rb -= Vector256.Count; } // 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); byte above = Unsafe.Add(ref prevBaseRef, offset); @@ -82,7 +82,7 @@ internal static class UpFilter // Up(x) + Prior(x) int rb = scanline.Length; - nint offset = 1; + nuint offset = 1; while (rb >= Vector128.Count) { ref byte scanRef = ref Unsafe.Add(ref scanBaseRef, offset); @@ -91,12 +91,12 @@ internal static class UpFilter Unsafe.As>(ref scanRef) = Sse2.Add(up, prior); - offset += Vector128.Count; + offset += (uint)Vector128.Count; rb -= Vector128.Count; } // 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); byte above = Unsafe.Add(ref prevBaseRef, offset); @@ -112,7 +112,7 @@ internal static class UpFilter // Up(x) + Prior(x) int rb = scanline.Length; - nint offset = 1; + nuint offset = 1; const int bytesPerBatch = 16; while (rb >= bytesPerBatch) { @@ -127,7 +127,7 @@ internal static class UpFilter } // 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); byte above = Unsafe.Add(ref prevBaseRef, offset); @@ -143,7 +143,7 @@ internal static class UpFilter ref byte prevBaseRef = ref MemoryMarshal.GetReference(previousScanline); // Up(x) + Prior(x) - for (nint x = 1; x < (uint)scanline.Length; x++) + for (nuint x = 1; x < (uint)scanline.Length; x++) { ref byte scan = ref Unsafe.Add(ref scanBaseRef, x); byte above = Unsafe.Add(ref prevBaseRef, x); @@ -172,21 +172,21 @@ internal static class UpFilter // Up(x) = Raw(x) - Prior(x) resultBaseRef = (byte)FilterType.Up; - nint x = 0; + nuint x = 0; if (Avx2.IsSupported) { Vector256 zero = Vector256.Zero; Vector256 sumAccumulator = Vector256.Zero; - for (; x <= (nint)(uint)(scanline.Length - Vector256.Count);) + for (; x <= (uint)(scanline.Length - Vector256.Count);) { Vector256 scan = Unsafe.As>(ref Unsafe.Add(ref scanBaseRef, x)); Vector256 above = Unsafe.As>(ref Unsafe.Add(ref prevBaseRef, x)); Vector256 res = Avx2.Subtract(scan, above); Unsafe.As>(ref Unsafe.Add(ref resultBaseRef, x + 1)) = res; // +1 to skip filter type - x += Vector256.Count; + x += (uint)Vector256.Count; sumAccumulator = Avx2.Add(sumAccumulator, Avx2.SumAbsoluteDifferences(Avx2.Abs(res.AsSByte()), zero).AsInt32()); } @@ -197,14 +197,14 @@ internal static class UpFilter { Vector sumAccumulator = Vector.Zero; - for (; x <= (nint)(uint)(scanline.Length - Vector.Count);) + for (; x <= (uint)(scanline.Length - Vector.Count);) { Vector scan = Unsafe.As>(ref Unsafe.Add(ref scanBaseRef, x)); Vector above = Unsafe.As>(ref Unsafe.Add(ref prevBaseRef, x)); Vector res = scan - above; Unsafe.As>(ref Unsafe.Add(ref resultBaseRef, x + 1)) = res; // +1 to skip filter type - x += Vector.Count; + x += (uint)Vector.Count; 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 above = Unsafe.Add(ref prevBaseRef, x); diff --git a/src/ImageSharp/Formats/Png/PngDecoderCore.cs b/src/ImageSharp/Formats/Png/PngDecoderCore.cs index ea8120a5c1..3ecc363fa4 100644 --- a/src/ImageSharp/Formats/Png/PngDecoderCore.cs +++ b/src/ImageSharp/Formats/Png/PngDecoderCore.cs @@ -777,8 +777,8 @@ internal sealed class PngDecoderCore : IImageDecoderInternals this.header, scanlineSpan, rowSpan, - this.bytesPerPixel, - this.bytesPerSample); + (uint)this.bytesPerPixel, + (uint)this.bytesPerSample); break; @@ -858,8 +858,8 @@ internal sealed class PngDecoderCore : IImageDecoderInternals this.header, scanlineSpan, rowSpan, - pixelOffset, - increment, + (uint)pixelOffset, + (uint)increment, pngMetadata.HasTransparency, pngMetadata.TransparentL16.GetValueOrDefault(), pngMetadata.TransparentL8.GetValueOrDefault()); @@ -871,10 +871,10 @@ internal sealed class PngDecoderCore : IImageDecoderInternals this.header, scanlineSpan, rowSpan, - pixelOffset, - increment, - this.bytesPerPixel, - this.bytesPerSample); + (uint)pixelOffset, + (uint)increment, + (uint)this.bytesPerPixel, + (uint)this.bytesPerSample); break; @@ -883,8 +883,8 @@ internal sealed class PngDecoderCore : IImageDecoderInternals this.header, scanlineSpan, rowSpan, - pixelOffset, - increment, + (uint)pixelOffset, + (uint)increment, this.palette, this.paletteAlpha); @@ -895,8 +895,8 @@ internal sealed class PngDecoderCore : IImageDecoderInternals this.header, scanlineSpan, rowSpan, - pixelOffset, - increment, + (uint)pixelOffset, + (uint)increment, this.bytesPerPixel, this.bytesPerSample, pngMetadata.HasTransparency, @@ -910,8 +910,8 @@ internal sealed class PngDecoderCore : IImageDecoderInternals this.header, scanlineSpan, rowSpan, - pixelOffset, - increment, + (uint)pixelOffset, + (uint)increment, this.bytesPerPixel, this.bytesPerSample); diff --git a/src/ImageSharp/Formats/Png/PngEncoderCore.cs b/src/ImageSharp/Formats/Png/PngEncoderCore.cs index 4657ab17bb..5794da3d56 100644 --- a/src/ImageSharp/Formats/Png/PngEncoderCore.cs +++ b/src/ImageSharp/Formats/Png/PngEncoderCore.cs @@ -455,7 +455,7 @@ internal sealed class PngEncoderCore : IImageEncoderInternals, IDisposable break; 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; case PngFilterMethod.Paeth: @@ -547,7 +547,7 @@ internal sealed class PngEncoderCore : IImageEncoderInternals, IDisposable 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) { min = sum; diff --git a/src/ImageSharp/Formats/Png/PngScanlineProcessor.cs b/src/ImageSharp/Formats/Png/PngScanlineProcessor.cs index 51b23242c8..04a23308cc 100644 --- a/src/ImageSharp/Formats/Png/PngScanlineProcessor.cs +++ b/src/ImageSharp/Formats/Png/PngScanlineProcessor.cs @@ -32,20 +32,21 @@ internal static class PngScanlineProcessor { 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)); pixel.FromL16(Unsafe.As(ref luminance)); - Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; + Unsafe.Add(ref rowSpanRef, x) = pixel; } } 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(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) { 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)); source.L = luminance; source.A = luminance.Equals(luminance16Trans.PackedValue) ? ushort.MinValue : ushort.MaxValue; pixel.FromLa32(source); - Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; + Unsafe.Add(ref rowSpanRef, x) = pixel; } } else { La16 source = default; 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.A = luminance.Equals(scaledLuminanceTrans) ? byte.MinValue : byte.MaxValue; 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, ReadOnlySpan scanlineSpan, Span rowSpan, - int pixelOffset, - int increment, + uint pixelOffset, + uint increment, bool hasTrans, L16 luminance16Trans, L8 luminanceTrans) @@ -101,20 +103,21 @@ internal static class PngScanlineProcessor { 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)); pixel.FromL16(Unsafe.As(ref luminance)); - Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; + Unsafe.Add(ref rowSpanRef, x) = pixel; } } 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(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) { 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)); source.L = luminance; source.A = luminance.Equals(luminance16Trans.PackedValue) ? ushort.MinValue : ushort.MaxValue; pixel.FromLa32(source); - Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; + Unsafe.Add(ref rowSpanRef, x) = pixel; } } else { La16 source = default; 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.A = luminance.Equals(scaledLuminanceTrans) ? byte.MinValue : byte.MaxValue; 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, ReadOnlySpan scanlineSpan, Span rowSpan, - int bytesPerPixel, - int bytesPerSample) + uint bytesPerPixel, + uint bytesPerSample) where TPixel : unmanaged, IPixel { TPixel pixel = default; @@ -165,26 +169,27 @@ internal static class PngScanlineProcessor if (header.BitDepth == 16) { 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.A = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + 2, 2)); pixel.FromLa32(source); - Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; + Unsafe.Add(ref rowSpanRef, x) = pixel; } } else { La16 source = default; - for (int x = 0; x < header.Width; x++) + for (nuint x = 0; x < (uint)header.Width; x++) { - int offset = x * bytesPerPixel; - source.L = Unsafe.Add(ref scanlineSpanRef, (uint)offset); - source.A = Unsafe.Add(ref scanlineSpanRef, (uint)(offset + bytesPerSample)); + nuint offset = x * bytesPerPixel; + source.L = Unsafe.Add(ref scanlineSpanRef, offset); + source.A = Unsafe.Add(ref scanlineSpanRef, offset + bytesPerSample); 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, ReadOnlySpan scanlineSpan, Span rowSpan, - int pixelOffset, - int increment, - int bytesPerPixel, - int bytesPerSample) + uint pixelOffset, + uint increment, + uint bytesPerPixel, + uint bytesPerSample) where TPixel : unmanaged, IPixel { TPixel pixel = default; @@ -206,7 +211,8 @@ internal static class PngScanlineProcessor if (header.BitDepth == 16) { 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.A = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + 2, 2)); @@ -217,15 +223,15 @@ internal static class PngScanlineProcessor } else { - int offset = 0; 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.A = Unsafe.Add(ref scanlineSpanRef, (uint)(offset + bytesPerSample)); + source.L = Unsafe.Add(ref scanlineSpanRef, offset); + source.A = Unsafe.Add(ref scanlineSpanRef, offset + bytesPerSample); pixel.FromLa16(source); - Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; + Unsafe.Add(ref rowSpanRef, x) = pixel; offset += bytesPerPixel; } } @@ -257,25 +263,25 @@ internal static class PngScanlineProcessor Rgba32 rgba = default; 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); - rgba.Rgb = Unsafe.Add(ref palettePixelsRef, (uint)index); - rgba.A = paletteAlpha.Length > index ? Unsafe.Add(ref paletteAlphaRef, (uint)index) : byte.MaxValue; + uint index = Unsafe.Add(ref scanlineSpanRef, x); + rgba.Rgb = Unsafe.Add(ref palettePixelsRef, index); + rgba.A = paletteAlpha.Length > index ? Unsafe.Add(ref paletteAlphaRef, index) : byte.MaxValue; pixel.FromRgba32(rgba); - Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; + Unsafe.Add(ref rowSpanRef, x) = pixel; } } 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); - Rgb24 rgb = Unsafe.Add(ref palettePixelsRef, (uint)index); + int index = Unsafe.Add(ref scanlineSpanRef, x); + Rgb24 rgb = Unsafe.Add(ref palettePixelsRef, index); 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, ReadOnlySpan scanlineSpan, Span rowSpan, - int pixelOffset, - int increment, + uint pixelOffset, + uint increment, ReadOnlySpan palette, byte[] paletteAlpha) where TPixel : unmanaged, IPixel @@ -302,25 +308,25 @@ internal static class PngScanlineProcessor // channel and we should try to read it. Rgba32 rgba = default; 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); - rgba.A = paletteAlpha.Length > index ? Unsafe.Add(ref paletteAlphaRef, (uint)index) : byte.MaxValue; - rgba.Rgb = Unsafe.Add(ref palettePixelsRef, (uint)index); + uint index = Unsafe.Add(ref scanlineSpanRef, o); + rgba.A = paletteAlpha.Length > index ? Unsafe.Add(ref paletteAlphaRef, index) : byte.MaxValue; + rgba.Rgb = Unsafe.Add(ref palettePixelsRef, index); pixel.FromRgba32(rgba); - Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; + Unsafe.Add(ref rowSpanRef, x) = pixel; } } 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); - Rgb24 rgb = Unsafe.Add(ref palettePixelsRef, (uint)index); + int index = Unsafe.Add(ref scanlineSpanRef, o); + Rgb24 rgb = Unsafe.Add(ref palettePixelsRef, index); 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) { 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.G = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + bytesPerSample, bytesPerSample)); rgb48.B = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + (2 * bytesPerSample), bytesPerSample)); pixel.FromRgb48(rgb48); - Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; + Unsafe.Add(ref rowSpanRef, x) = pixel; } } else @@ -367,7 +374,8 @@ internal static class PngScanlineProcessor { Rgb48 rgb48 = 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.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; pixel.FromRgba64(rgba64); - Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; + Unsafe.Add(ref rowSpanRef, x) = pixel; } } else @@ -385,14 +393,14 @@ internal static class PngScanlineProcessor Rgba32 rgba32 = default; ReadOnlySpan rgb24Span = MemoryMarshal.Cast(scanlineSpan); 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.A = rgb24.Equals(rgb24Trans) ? byte.MinValue : byte.MaxValue; 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, ReadOnlySpan scanlineSpan, Span rowSpan, - int pixelOffset, - int increment, + uint pixelOffset, + uint increment, int bytesPerPixel, int bytesPerSample, bool hasTrans, @@ -420,7 +428,8 @@ internal static class PngScanlineProcessor { Rgb48 rgb48 = 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.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; pixel.FromRgba64(rgba64); - Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; + Unsafe.Add(ref rowSpanRef, x) = pixel; } } else { 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.G = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + bytesPerSample, bytesPerSample)); rgb48.B = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + (2 * bytesPerSample), bytesPerSample)); 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) { 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.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; pixel.FromRgba32(rgba); - Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; + Unsafe.Add(ref rowSpanRef, x) = pixel; } } else { 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.G = Unsafe.Add(ref scanlineSpanRef, (uint)(o + bytesPerSample)); rgb.B = Unsafe.Add(ref scanlineSpanRef, (uint)(o + (2 * bytesPerSample))); pixel.FromRgb24(rgb); - Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; + Unsafe.Add(ref rowSpanRef, x) = pixel; } } } @@ -494,7 +506,8 @@ internal static class PngScanlineProcessor if (header.BitDepth == 16) { 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.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)); pixel.FromRgba64(rgba64); - Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; + Unsafe.Add(ref rowSpanRef, x) = pixel; } } else @@ -515,8 +528,8 @@ internal static class PngScanlineProcessor in PngHeader header, ReadOnlySpan scanlineSpan, Span rowSpan, - int pixelOffset, - int increment, + uint pixelOffset, + uint increment, int bytesPerPixel, int bytesPerSample) where TPixel : unmanaged, IPixel @@ -528,7 +541,8 @@ internal static class PngScanlineProcessor if (header.BitDepth == 16) { 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.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)); pixel.FromRgba64(rgba64); - Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; + Unsafe.Add(ref rowSpanRef, x) = pixel; } } else { 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.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))); pixel.FromRgba32(rgba); - Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; + Unsafe.Add(ref rowSpanRef, x) = pixel; } } } diff --git a/src/ImageSharp/Formats/Tiff/Compression/Decompressors/T6TiffCompression.cs b/src/ImageSharp/Formats/Tiff/Compression/Decompressors/T6TiffCompression.cs index 1cd8e0dc80..c868fec626 100644 --- a/src/ImageSharp/Formats/Tiff/Compression/Decompressors/T6TiffCompression.cs +++ b/src/ImageSharp/Formats/Tiff/Compression/Decompressors/T6TiffCompression.cs @@ -78,7 +78,7 @@ internal sealed class T6TiffCompression : TiffBaseDecompressor nint bitPos = Numerics.Modulo8(bitsWritten); nint bufferPos = bitsWritten / 8; ref byte scanLineRef = ref MemoryMarshal.GetReference(scanLine); - for (nint i = 0; i < (uint)scanLine.Length; i++) + for (nuint i = 0; i < (uint)scanLine.Length; i++) { if (Unsafe.Add(ref scanLineRef, i) != this.white) { diff --git a/src/ImageSharp/Formats/Tiff/Compression/TiffBaseCompression.cs b/src/ImageSharp/Formats/Tiff/Compression/TiffBaseCompression.cs index d57dea994f..36f8c20d72 100644 --- a/src/ImageSharp/Formats/Tiff/Compression/TiffBaseCompression.cs +++ b/src/ImageSharp/Formats/Tiff/Compression/TiffBaseCompression.cs @@ -16,7 +16,7 @@ internal abstract class TiffBaseCompression : IDisposable this.Width = width; this.BitsPerPixel = bitsPerPixel; this.Predictor = predictor; - this.BytesPerRow = (int)(((uint)(width * bitsPerPixel) + 7) / 8); + this.BytesPerRow = ((width * bitsPerPixel) + 7) / 8; } /// diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZero1TiffColor{TPixel}.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZero1TiffColor{TPixel}.cs index a5a04d19d5..a8a70f7272 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZero1TiffColor{TPixel}.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZero1TiffColor{TPixel}.cs @@ -18,21 +18,21 @@ internal class BlackIsZero1TiffColor : TiffBaseColorDecoder /// public override void Decode(ReadOnlySpan data, Buffer2D pixels, int left, int top, int width, int height) { - nint offset = 0; - var colorBlack = default(TPixel); - var colorWhite = default(TPixel); + nuint offset = 0; + TPixel colorBlack = default; + TPixel colorWhite = default; colorBlack.FromRgba32(Color.Black); colorWhite.FromRgba32(Color.White); 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 pixelRowSpan = pixels.DangerousGetRowSpan((int)y); 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++); - nint maxShift = Math.Min(left + width - x, 8); + nuint maxShift = Math.Min((uint)(left + width) - x, 8); if (maxShift == 8) { @@ -70,7 +70,7 @@ internal class BlackIsZero1TiffColor : TiffBaseColorDecoder } else { - for (nint shift = 0; shift < maxShift; shift++) + for (nuint shift = 0; shift < maxShift; shift++) { int bit = (b >> (7 - (int)shift)) & 1; diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero1TiffColor{TPixel}.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero1TiffColor{TPixel}.cs index 737f957676..c5b662979e 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero1TiffColor{TPixel}.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero1TiffColor{TPixel}.cs @@ -17,21 +17,21 @@ internal class WhiteIsZero1TiffColor : TiffBaseColorDecoder /// public override void Decode(ReadOnlySpan data, Buffer2D pixels, int left, int top, int width, int height) { - nint offset = 0; + nuint offset = 0; var colorBlack = default(TPixel); var colorWhite = default(TPixel); colorBlack.FromRgba32(Color.Black); colorWhite.FromRgba32(Color.White); 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 pixelRowSpan = pixels.DangerousGetRowSpan((int)y); 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++); - nint maxShift = Math.Min(left + width - x, 8); + nuint maxShift = Math.Min((uint)(left + width) - x, 8); if (maxShift == 8) { @@ -69,11 +69,11 @@ internal class WhiteIsZero1TiffColor : TiffBaseColorDecoder } 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; } } diff --git a/src/ImageSharp/Formats/Tiff/TiffDecoderCore.cs b/src/ImageSharp/Formats/Tiff/TiffDecoderCore.cs index 4499c55833..45bbed12d5 100644 --- a/src/ImageSharp/Formats/Tiff/TiffDecoderCore.cs +++ b/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; } diff --git a/src/ImageSharp/Formats/Webp/AlphaDecoder.cs b/src/ImageSharp/Formats/Webp/AlphaDecoder.cs index 2678a6f70f..289ebd35ca 100644 --- a/src/ImageSharp/Formats/Webp/AlphaDecoder.cs +++ b/src/ImageSharp/Formats/Webp/AlphaDecoder.cs @@ -319,7 +319,7 @@ internal class AlphaDecoder : IDisposable return; } - nint i; + nuint i; Vector128 last = Vector128.Zero.WithElement(0, dst[0]); ref byte srcRef = ref MemoryMarshal.GetReference(input); ref byte dstRef = ref MemoryMarshal.GetReference(dst); @@ -365,20 +365,24 @@ internal class AlphaDecoder : IDisposable } 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; for (i = 0; i < (uint)maxPos; i += 32) { - Vector256 a0 = Unsafe.As>(ref Unsafe.Add(ref MemoryMarshal.GetReference(input), i)); - Vector256 b0 = Unsafe.As>(ref Unsafe.Add(ref MemoryMarshal.GetReference(prev), i)); + Vector256 a0 = Unsafe.As>(ref Unsafe.Add(ref inputRef, i)); + Vector256 b0 = Unsafe.As>(ref Unsafe.Add(ref prevRef, i)); Vector256 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>(ref outputRef) = c0; } 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 diff --git a/src/ImageSharp/Formats/Webp/Lossless/ColorSpaceTransformUtils.cs b/src/ImageSharp/Formats/Webp/Lossless/ColorSpaceTransformUtils.cs index 45de1b9553..9a6dfb66e8 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/ColorSpaceTransformUtils.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/ColorSpaceTransformUtils.cs @@ -27,10 +27,10 @@ internal static class ColorSpaceTransformUtils { Span srcSpan = bgra[(y * stride)..]; 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; - nint input1Idx = x + (span / 2); + nuint input0Idx = x; + nuint input1Idx = x + (span / 2); Vector256 input0 = Unsafe.As>(ref Unsafe.Add(ref inputRef, input0Idx)).AsByte(); Vector256 input1 = Unsafe.As>(ref Unsafe.Add(ref inputRef, input1Idx)).AsByte(); Vector256 r0 = Avx2.Shuffle(input0, collectColorBlueTransformsShuffleLowMask256); @@ -77,10 +77,10 @@ internal static class ColorSpaceTransformUtils { Span srcSpan = bgra[(y * stride)..]; 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; - nint input1Idx = x + (span / 2); + nuint input0Idx = x; + nuint input1Idx = x + (span / 2); Vector128 input0 = Unsafe.As>(ref Unsafe.Add(ref inputRef, input0Idx)).AsByte(); Vector128 input1 = Unsafe.As>(ref Unsafe.Add(ref inputRef, input1Idx)).AsByte(); Vector128 r0 = Ssse3.Shuffle(input0, collectColorBlueTransformsShuffleLowMask); @@ -146,10 +146,10 @@ internal static class ColorSpaceTransformUtils { Span srcSpan = bgra[(y * stride)..]; 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; - nint input1Idx = x + (span / 2); + nuint input0Idx = x; + nuint input1Idx = x + (span / 2); Vector256 input0 = Unsafe.As>(ref Unsafe.Add(ref inputRef, input0Idx)).AsByte(); Vector256 input1 = Unsafe.As>(ref Unsafe.Add(ref inputRef, input1Idx)).AsByte(); Vector256 g0 = Avx2.And(input0, collectColorRedTransformsGreenMask256); // 0 0 | g 0 @@ -189,10 +189,10 @@ internal static class ColorSpaceTransformUtils { Span srcSpan = bgra[(y * stride)..]; 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; - nint input1Idx = x + (span / 2); + nuint input0Idx = x; + nuint input1Idx = x + (span / 2); Vector128 input0 = Unsafe.As>(ref Unsafe.Add(ref inputRef, input0Idx)).AsByte(); Vector128 input1 = Unsafe.As>(ref Unsafe.Add(ref inputRef, input1Idx)).AsByte(); Vector128 g0 = Sse2.And(input0, collectColorRedTransformsGreenMask); // 0 0 | g 0 diff --git a/src/ImageSharp/Formats/Webp/Lossless/LosslessUtils.cs b/src/ImageSharp/Formats/Webp/Lossless/LosslessUtils.cs index 5a8137754b..05b6001c91 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/LosslessUtils.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/LosslessUtils.cs @@ -94,49 +94,53 @@ internal static unsafe class LosslessUtils /// The pixel data to apply the transformation. public static void AddGreenToBlueAndRed(Span pixelData) { - if (Avx2.IsSupported) + if (Avx2.IsSupported && pixelData.Length >= 8) { Vector256 addGreenToBlueAndRedMaskAvx2 = Vector256.Create(1, 255, 1, 255, 5, 255, 5, 255, 9, 255, 9, 255, 13, 255, 13, 255, 17, 255, 17, 255, 21, 255, 21, 255, 25, 255, 25, 255, 29, 255, 29, 255); - int numPixels = pixelData.Length; - nint i; - for (i = 0; i <= (nint)(uint)numPixels - 8; i += 8) + nuint numPixels = (uint)pixelData.Length; + nuint i = 0; + do { ref uint pos = ref Unsafe.Add(ref MemoryMarshal.GetReference(pixelData), i); Vector256 input = Unsafe.As>(ref pos).AsByte(); Vector256 in0g0g = Avx2.Shuffle(input, addGreenToBlueAndRedMaskAvx2); Vector256 output = Avx2.Add(input, in0g0g); Unsafe.As>(ref pos) = output.AsUInt32(); + i += 8; } + while (i <= numPixels - 8); if (i != numPixels) { AddGreenToBlueAndRedScalar(pixelData[(int)i..]); } } - else if (Ssse3.IsSupported) + else if (Ssse3.IsSupported && pixelData.Length >= 4) { Vector128 addGreenToBlueAndRedMaskSsse3 = Vector128.Create(1, 255, 1, 255, 5, 255, 5, 255, 9, 255, 9, 255, 13, 255, 13, 255); - int numPixels = pixelData.Length; - nint i; - for (i = 0; i <= (nint)(uint)numPixels - 4; i += 4) + nuint numPixels = (uint)pixelData.Length; + nuint i = 0; + do { ref uint pos = ref Unsafe.Add(ref MemoryMarshal.GetReference(pixelData), i); Vector128 input = Unsafe.As>(ref pos).AsByte(); Vector128 in0g0g = Ssse3.Shuffle(input, addGreenToBlueAndRedMaskSsse3); Vector128 output = Sse2.Add(input, in0g0g); Unsafe.As>(ref pos) = output.AsUInt32(); + i += 4; } + while (i <= numPixels - 4); if (i != numPixels) { AddGreenToBlueAndRedScalar(pixelData[(int)i..]); } } - else if (Sse2.IsSupported) + else if (Sse2.IsSupported && pixelData.Length >= 4) { - int numPixels = pixelData.Length; - nint i; - for (i = 0; i <= (nint)(uint)numPixels - 4; i += 4) + nuint numPixels = (uint)pixelData.Length; + nuint i = 0; + do { ref uint pos = ref Unsafe.Add(ref MemoryMarshal.GetReference(pixelData), i); Vector128 input = Unsafe.As>(ref pos).AsByte(); @@ -145,7 +149,9 @@ internal static unsafe class LosslessUtils Vector128 c = Sse2.ShuffleHigh(b, SimdUtils.Shuffle.MMShuffle2200); // 0g0g Vector128 output = Sse2.Add(input.AsByte(), c.AsByte()); Unsafe.As>(ref pos) = output.AsUInt32(); + i += 4; } + while (i <= numPixels - 4); if (i != numPixels) { @@ -174,49 +180,53 @@ internal static unsafe class LosslessUtils public static void SubtractGreenFromBlueAndRed(Span pixelData) { - if (Avx2.IsSupported) + if (Avx2.IsSupported && pixelData.Length >= 8) { Vector256 subtractGreenFromBlueAndRedMaskAvx2 = Vector256.Create(1, 255, 1, 255, 5, 255, 5, 255, 9, 255, 9, 255, 13, 255, 13, 255, 17, 255, 17, 255, 21, 255, 21, 255, 25, 255, 25, 255, 29, 255, 29, 255); - int numPixels = pixelData.Length; - nint i; - for (i = 0; i <= (nint)(uint)numPixels - 8; i += 8) + nuint numPixels = (uint)pixelData.Length; + nuint i = 0; + do { ref uint pos = ref Unsafe.Add(ref MemoryMarshal.GetReference(pixelData), i); Vector256 input = Unsafe.As>(ref pos).AsByte(); Vector256 in0g0g = Avx2.Shuffle(input, subtractGreenFromBlueAndRedMaskAvx2); Vector256 output = Avx2.Subtract(input, in0g0g); Unsafe.As>(ref pos) = output.AsUInt32(); + i += 8; } + while (i <= numPixels - 8); if (i != numPixels) { SubtractGreenFromBlueAndRedScalar(pixelData[(int)i..]); } } - else if (Ssse3.IsSupported) + else if (Ssse3.IsSupported && pixelData.Length >= 4) { Vector128 subtractGreenFromBlueAndRedMaskSsse3 = Vector128.Create(1, 255, 1, 255, 5, 255, 5, 255, 9, 255, 9, 255, 13, 255, 13, 255); - int numPixels = pixelData.Length; - nint i; - for (i = 0; i <= (nint)(uint)numPixels - 4; i += 4) + nuint numPixels = (uint)pixelData.Length; + nuint i = 0; + do { ref uint pos = ref Unsafe.Add(ref MemoryMarshal.GetReference(pixelData), i); Vector128 input = Unsafe.As>(ref pos).AsByte(); Vector128 in0g0g = Ssse3.Shuffle(input, subtractGreenFromBlueAndRedMaskSsse3); Vector128 output = Sse2.Subtract(input, in0g0g); Unsafe.As>(ref pos) = output.AsUInt32(); + i += 4; } + while (i <= numPixels - 4); if (i != numPixels) { SubtractGreenFromBlueAndRedScalar(pixelData[(int)i..]); } } - else if (Sse2.IsSupported) + else if (Sse2.IsSupported && pixelData.Length >= 4) { - int numPixels = pixelData.Length; - nint i; - for (i = 0; i <= (nint)(uint)numPixels - 4; i += 4) + nuint numPixels = (uint)pixelData.Length; + nuint i = 0; + do { ref uint pos = ref Unsafe.Add(ref MemoryMarshal.GetReference(pixelData), i); Vector128 input = Unsafe.As>(ref pos).AsByte(); @@ -225,7 +235,9 @@ internal static unsafe class LosslessUtils Vector128 c = Sse2.ShuffleHigh(b, SimdUtils.Shuffle.MMShuffle2200); // 0g0g Vector128 output = Sse2.Subtract(input.AsByte(), c.AsByte()); Unsafe.As>(ref pos) = output.AsUInt32(); + i += 4; } + while (i <= numPixels - 4); if (i != numPixels) { @@ -372,8 +384,8 @@ internal static unsafe class LosslessUtils Vector256 multsrb = MkCst32(Cst5b(m.GreenToRed), Cst5b(m.GreenToBlue)); Vector256 multsb2 = MkCst32(Cst5b(m.RedToBlue), 0); - nint idx; - for (idx = 0; idx <= (nint)(uint)numPixels - 8; idx += 8) + nuint idx = 0; + do { ref uint pos = ref Unsafe.Add(ref MemoryMarshal.GetReference(pixelData), idx); Vector256 input = Unsafe.As>(ref pos); @@ -388,21 +400,23 @@ internal static unsafe class LosslessUtils Vector256 i = Avx2.And(h, transformColorRedBlueMask256); Vector256 output = Avx2.Subtract(input.AsByte(), i); Unsafe.As>(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); } } - else if (Sse2.IsSupported) + else if (Sse2.IsSupported && numPixels >= 4) { Vector128 transformColorAlphaGreenMask = Vector128.Create(0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255); Vector128 transformColorRedBlueMask = Vector128.Create(255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0); Vector128 multsrb = MkCst16(Cst5b(m.GreenToRed), Cst5b(m.GreenToBlue)); Vector128 multsb2 = MkCst16(Cst5b(m.RedToBlue), 0); - nint idx; - for (idx = 0; idx <= (nint)(uint)numPixels - 4; idx += 4) + nuint idx = 0; + do { ref uint pos = ref Unsafe.Add(ref MemoryMarshal.GetReference(pixelData), idx); Vector128 input = Unsafe.As>(ref pos); @@ -417,9 +431,11 @@ internal static unsafe class LosslessUtils Vector128 i = Sse2.And(h, transformColorRedBlueMask); Vector128 output = Sse2.Subtract(input.AsByte(), i); Unsafe.As>(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); } @@ -460,8 +476,8 @@ internal static unsafe class LosslessUtils Vector256 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 multsrb = MkCst32(Cst5b(m.GreenToRed), Cst5b(m.GreenToBlue)); Vector256 multsb2 = MkCst32(Cst5b(m.RedToBlue), 0); - nint idx; - for (idx = 0; idx <= (nint)(uint)pixelData.Length - 8; idx += 8) + nuint idx; + for (idx = 0; idx <= (uint)pixelData.Length - 8; idx += 8) { ref uint pos = ref Unsafe.Add(ref MemoryMarshal.GetReference(pixelData), idx); Vector256 input = Unsafe.As>(ref pos); @@ -479,19 +495,19 @@ internal static unsafe class LosslessUtils Unsafe.As>(ref pos) = output.AsUInt32(); } - if (idx != pixelData.Length) + if (idx != (uint)pixelData.Length) { TransformColorInverseScalar(m, pixelData[(int)idx..]); } } - else if (Sse2.IsSupported) + else if (Sse2.IsSupported && pixelData.Length >= 4) { Vector128 transformColorInverseAlphaGreenMask = Vector128.Create(0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255); Vector128 multsrb = MkCst16(Cst5b(m.GreenToRed), Cst5b(m.GreenToBlue)); Vector128 multsb2 = MkCst16(Cst5b(m.RedToBlue), 0); - nint idx; - for (idx = 0; idx <= (nint)(uint)pixelData.Length - 4; idx += 4) + nuint idx; + for (idx = 0; idx <= (uint)pixelData.Length - 4; idx += 4) { ref uint pos = ref Unsafe.Add(ref MemoryMarshal.GetReference(pixelData), idx); Vector128 input = Unsafe.As>(ref pos); @@ -509,7 +525,7 @@ internal static unsafe class LosslessUtils Unsafe.As>(ref pos) = output.AsUInt32(); } - if (idx != pixelData.Length) + if (idx != (uint)pixelData.Length) { TransformColorInverseScalar(m, pixelData[(int)idx..]); } @@ -740,7 +756,7 @@ internal static unsafe class LosslessUtils Vector256 sumXY256 = Vector256.Zero; Vector256 sumX256 = Vector256.Zero; ref int tmpRef = ref Unsafe.As, int>(ref tmp); - for (nint i = 0; i < 256; i += 8) + for (nuint i = 0; i < 256; i += 8) { Vector256 xVec = Unsafe.As>(ref Unsafe.Add(ref xRef, i)); Vector256 yVec = Unsafe.As>(ref Unsafe.Add(ref yRef, i)); diff --git a/src/ImageSharp/Formats/Webp/Lossless/Vp8LHistogram.cs b/src/ImageSharp/Formats/Webp/Lossless/Vp8LHistogram.cs index 3f44a1bc05..3df979f96b 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/Vp8LHistogram.cs +++ b/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 bRef = ref MemoryMarshal.GetReference(b); 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. Vector256 a0 = Unsafe.As>(ref Unsafe.Add(ref aRef, idx)); diff --git a/src/ImageSharp/Formats/Webp/Lossy/LossyUtils.cs b/src/ImageSharp/Formats/Webp/Lossy/LossyUtils.cs index 2dc2881b03..de3f1586af 100644 --- a/src/ImageSharp/Formats/Webp/Lossy/LossyUtils.cs +++ b/src/ImageSharp/Formats/Webp/Lossy/LossyUtils.cs @@ -161,7 +161,7 @@ internal static class LossyUtils private static int Vp8_Sse16xN_Sse2(Span a, Span b, int numPairs) { Vector128 sum = Vector128.Zero; - nint offset = 0; + nuint offset = 0; ref byte aRef = ref MemoryMarshal.GetReference(a); ref byte bRef = ref MemoryMarshal.GetReference(b); for (int i = 0; i < numPairs; i++) @@ -186,7 +186,7 @@ internal static class LossyUtils private static int Vp8_Sse16xN_Avx2(Span a, Span b, int numPairs) { Vector256 sum = Vector256.Zero; - nint offset = 0; + nuint offset = 0; ref byte aRef = ref MemoryMarshal.GetReference(a); ref byte bRef = ref MemoryMarshal.GetReference(b); 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 // p0 = f1 e1 d1 c1 b1 a1 91 81 f0 e0 d0 c0 b0 a0 90 80 // q1 = f3 e3 d3 c3 b3 a3 93 83 f2 e2 d2 c2 b2 a2 92 82 - Load8x4(ref r0, (nint)(uint)stride, out Vector128 t1, out Vector128 t2); - Load8x4(ref r8, (nint)(uint)stride, out p0, out q1); + Load8x4(ref r0, (uint)stride, out Vector128 t1, out Vector128 t2); + 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 // p0 = f1 e1 d1 c1 b1 a1 91 81 71 61 51 41 31 21 11 01 @@ -2292,7 +2292,7 @@ internal static class LossyUtils } // Reads 8 rows across a vertical edge. - private static void Load8x4(ref byte bRef, nint stride, out Vector128 p, out Vector128 q) + private static void Load8x4(ref byte bRef, nuint stride, out Vector128 p, out Vector128 q) { // A0 = 63 62 61 60 23 22 21 20 43 42 41 40 03 02 01 00 // A1 = 73 72 71 70 33 32 31 30 53 52 51 50 13 12 11 10 diff --git a/src/ImageSharp/Formats/Webp/Lossy/QuantEnc.cs b/src/ImageSharp/Formats/Webp/Lossy/QuantEnc.cs index 75b92a1aaa..76de2e8f4a 100644 --- a/src/ImageSharp/Formats/Webp/Lossy/QuantEnc.cs +++ b/src/ImageSharp/Formats/Webp/Lossy/QuantEnc.cs @@ -770,7 +770,7 @@ internal static unsafe class QuantEnc { uint v = src[0] * 0x01010101u; Span 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) || !src.Slice(8, 4).SequenceEqual(vSpan) || !src.Slice(12, 4).SequenceEqual(vSpan)) @@ -789,10 +789,10 @@ internal static unsafe class QuantEnc { int score = 0; ref short levelsRef = ref MemoryMarshal.GetReference(levels); - nint offset = 0; + nuint offset = 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 score += Unsafe.Add(ref levelsRef, offset) != 0 ? 1 : 0; diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Abgr32.PixelOperations.Generated.cs b/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Abgr32.PixelOperations.Generated.cs index 9fca0cdc35..f24ed6fae8 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Abgr32.PixelOperations.Generated.cs +++ b/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)); } - + /// public override void ToRgba32( Configuration configuration, @@ -71,7 +71,7 @@ public partial struct Abgr32 Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromAbgr32.ToRgba32(source, dest); } - + /// public override void FromRgba32( Configuration configuration, @@ -84,8 +84,8 @@ public partial struct Abgr32 ReadOnlySpan source = MemoryMarshal.Cast(sourcePixels); Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromRgba32.ToAbgr32(source, dest); - } - + } + /// public override void ToArgb32( Configuration configuration, @@ -99,7 +99,7 @@ public partial struct Abgr32 Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromAbgr32.ToArgb32(source, dest); } - + /// public override void FromArgb32( Configuration configuration, @@ -112,8 +112,8 @@ public partial struct Abgr32 ReadOnlySpan source = MemoryMarshal.Cast(sourcePixels); Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromArgb32.ToAbgr32(source, dest); - } - + } + /// public override void ToBgra32( Configuration configuration, @@ -127,7 +127,7 @@ public partial struct Abgr32 Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromAbgr32.ToBgra32(source, dest); } - + /// public override void FromBgra32( Configuration configuration, @@ -140,8 +140,8 @@ public partial struct Abgr32 ReadOnlySpan source = MemoryMarshal.Cast(sourcePixels); Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromBgra32.ToAbgr32(source, dest); - } - + } + /// public override void ToRgb24( Configuration configuration, @@ -155,7 +155,7 @@ public partial struct Abgr32 Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromAbgr32.ToRgb24(source, dest); } - + /// public override void FromRgb24( Configuration configuration, @@ -168,8 +168,8 @@ public partial struct Abgr32 ReadOnlySpan source = MemoryMarshal.Cast(sourcePixels); Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromRgb24.ToAbgr32(source, dest); - } - + } + /// public override void ToBgr24( Configuration configuration, @@ -183,7 +183,7 @@ public partial struct Abgr32 Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromAbgr32.ToBgr24(source, dest); } - + /// public override void FromBgr24( Configuration configuration, @@ -196,7 +196,7 @@ public partial struct Abgr32 ReadOnlySpan source = MemoryMarshal.Cast(sourcePixels); Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromBgr24.ToAbgr32(source, dest); - } + } /// public override void ToL8( @@ -210,7 +210,7 @@ public partial struct Abgr32 ref Abgr32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref L8 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Abgr32 sp = ref Unsafe.Add(ref sourceRef, i); ref L8 dp = ref Unsafe.Add(ref destRef, i); @@ -231,7 +231,7 @@ public partial struct Abgr32 ref Abgr32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref L16 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Abgr32 sp = ref Unsafe.Add(ref sourceRef, i); ref L16 dp = ref Unsafe.Add(ref destRef, i); @@ -252,7 +252,7 @@ public partial struct Abgr32 ref Abgr32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref La16 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Abgr32 sp = ref Unsafe.Add(ref sourceRef, i); ref La16 dp = ref Unsafe.Add(ref destRef, i); @@ -273,7 +273,7 @@ public partial struct Abgr32 ref Abgr32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref La32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Abgr32 sp = ref Unsafe.Add(ref sourceRef, i); ref La32 dp = ref Unsafe.Add(ref destRef, i); @@ -294,7 +294,7 @@ public partial struct Abgr32 ref Abgr32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgb48 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Abgr32 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb48 dp = ref Unsafe.Add(ref destRef, i); @@ -315,7 +315,7 @@ public partial struct Abgr32 ref Abgr32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgba64 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Abgr32 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgba64 dp = ref Unsafe.Add(ref destRef, i); @@ -336,7 +336,7 @@ public partial struct Abgr32 ref Abgr32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Abgr32 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgra5551 dp = ref Unsafe.Add(ref destRef, i); diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Argb32.PixelOperations.Generated.cs b/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Argb32.PixelOperations.Generated.cs index e87926be8b..37ac39a851 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Argb32.PixelOperations.Generated.cs +++ b/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)); } - + /// public override void ToRgba32( Configuration configuration, @@ -71,7 +71,7 @@ public partial struct Argb32 Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromArgb32.ToRgba32(source, dest); } - + /// public override void FromRgba32( Configuration configuration, @@ -84,8 +84,8 @@ public partial struct Argb32 ReadOnlySpan source = MemoryMarshal.Cast(sourcePixels); Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromRgba32.ToArgb32(source, dest); - } - + } + /// public override void ToAbgr32( Configuration configuration, @@ -99,7 +99,7 @@ public partial struct Argb32 Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromArgb32.ToAbgr32(source, dest); } - + /// public override void FromAbgr32( Configuration configuration, @@ -112,8 +112,8 @@ public partial struct Argb32 ReadOnlySpan source = MemoryMarshal.Cast(sourcePixels); Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromAbgr32.ToArgb32(source, dest); - } - + } + /// public override void ToBgra32( Configuration configuration, @@ -127,7 +127,7 @@ public partial struct Argb32 Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromArgb32.ToBgra32(source, dest); } - + /// public override void FromBgra32( Configuration configuration, @@ -140,8 +140,8 @@ public partial struct Argb32 ReadOnlySpan source = MemoryMarshal.Cast(sourcePixels); Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromBgra32.ToArgb32(source, dest); - } - + } + /// public override void ToRgb24( Configuration configuration, @@ -155,7 +155,7 @@ public partial struct Argb32 Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromArgb32.ToRgb24(source, dest); } - + /// public override void FromRgb24( Configuration configuration, @@ -168,8 +168,8 @@ public partial struct Argb32 ReadOnlySpan source = MemoryMarshal.Cast(sourcePixels); Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromRgb24.ToArgb32(source, dest); - } - + } + /// public override void ToBgr24( Configuration configuration, @@ -183,7 +183,7 @@ public partial struct Argb32 Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromArgb32.ToBgr24(source, dest); } - + /// public override void FromBgr24( Configuration configuration, @@ -196,7 +196,7 @@ public partial struct Argb32 ReadOnlySpan source = MemoryMarshal.Cast(sourcePixels); Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromBgr24.ToArgb32(source, dest); - } + } /// public override void ToL8( @@ -210,7 +210,7 @@ public partial struct Argb32 ref Argb32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref L8 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Argb32 sp = ref Unsafe.Add(ref sourceRef, i); ref L8 dp = ref Unsafe.Add(ref destRef, i); @@ -231,7 +231,7 @@ public partial struct Argb32 ref Argb32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref L16 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Argb32 sp = ref Unsafe.Add(ref sourceRef, i); ref L16 dp = ref Unsafe.Add(ref destRef, i); @@ -252,7 +252,7 @@ public partial struct Argb32 ref Argb32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref La16 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Argb32 sp = ref Unsafe.Add(ref sourceRef, i); ref La16 dp = ref Unsafe.Add(ref destRef, i); @@ -273,7 +273,7 @@ public partial struct Argb32 ref Argb32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref La32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Argb32 sp = ref Unsafe.Add(ref sourceRef, i); ref La32 dp = ref Unsafe.Add(ref destRef, i); @@ -294,7 +294,7 @@ public partial struct Argb32 ref Argb32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgb48 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Argb32 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb48 dp = ref Unsafe.Add(ref destRef, i); @@ -315,7 +315,7 @@ public partial struct Argb32 ref Argb32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgba64 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Argb32 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgba64 dp = ref Unsafe.Add(ref destRef, i); @@ -336,7 +336,7 @@ public partial struct Argb32 ref Argb32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Argb32 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgra5551 dp = ref Unsafe.Add(ref destRef, i); diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Bgr24.PixelOperations.Generated.cs b/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Bgr24.PixelOperations.Generated.cs index 32eed0ce40..f604d6f970 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Bgr24.PixelOperations.Generated.cs +++ b/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)); } - + /// public override void ToRgba32( Configuration configuration, @@ -71,7 +71,7 @@ public partial struct Bgr24 Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromBgr24.ToRgba32(source, dest); } - + /// public override void FromRgba32( Configuration configuration, @@ -84,8 +84,8 @@ public partial struct Bgr24 ReadOnlySpan source = MemoryMarshal.Cast(sourcePixels); Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromRgba32.ToBgr24(source, dest); - } - + } + /// public override void ToArgb32( Configuration configuration, @@ -99,7 +99,7 @@ public partial struct Bgr24 Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromBgr24.ToArgb32(source, dest); } - + /// public override void FromArgb32( Configuration configuration, @@ -112,8 +112,8 @@ public partial struct Bgr24 ReadOnlySpan source = MemoryMarshal.Cast(sourcePixels); Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromArgb32.ToBgr24(source, dest); - } - + } + /// public override void ToAbgr32( Configuration configuration, @@ -127,7 +127,7 @@ public partial struct Bgr24 Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromBgr24.ToAbgr32(source, dest); } - + /// public override void FromAbgr32( Configuration configuration, @@ -140,8 +140,8 @@ public partial struct Bgr24 ReadOnlySpan source = MemoryMarshal.Cast(sourcePixels); Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromAbgr32.ToBgr24(source, dest); - } - + } + /// public override void ToBgra32( Configuration configuration, @@ -155,7 +155,7 @@ public partial struct Bgr24 Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromBgr24.ToBgra32(source, dest); } - + /// public override void FromBgra32( Configuration configuration, @@ -168,8 +168,8 @@ public partial struct Bgr24 ReadOnlySpan source = MemoryMarshal.Cast(sourcePixels); Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromBgra32.ToBgr24(source, dest); - } - + } + /// public override void ToRgb24( Configuration configuration, @@ -183,7 +183,7 @@ public partial struct Bgr24 Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromBgr24.ToRgb24(source, dest); } - + /// public override void FromRgb24( Configuration configuration, @@ -196,7 +196,7 @@ public partial struct Bgr24 ReadOnlySpan source = MemoryMarshal.Cast(sourcePixels); Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromRgb24.ToBgr24(source, dest); - } + } /// public override void ToL8( @@ -210,7 +210,7 @@ public partial struct Bgr24 ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref L8 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i); ref L8 dp = ref Unsafe.Add(ref destRef, i); @@ -231,7 +231,7 @@ public partial struct Bgr24 ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref L16 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i); ref L16 dp = ref Unsafe.Add(ref destRef, i); @@ -252,7 +252,7 @@ public partial struct Bgr24 ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref La16 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i); ref La16 dp = ref Unsafe.Add(ref destRef, i); @@ -273,7 +273,7 @@ public partial struct Bgr24 ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref La32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i); ref La32 dp = ref Unsafe.Add(ref destRef, i); @@ -294,7 +294,7 @@ public partial struct Bgr24 ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgb48 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb48 dp = ref Unsafe.Add(ref destRef, i); @@ -315,7 +315,7 @@ public partial struct Bgr24 ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgba64 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgba64 dp = ref Unsafe.Add(ref destRef, i); @@ -336,7 +336,7 @@ public partial struct Bgr24 ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgra5551 dp = ref Unsafe.Add(ref destRef, i); diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Bgra32.PixelOperations.Generated.cs b/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Bgra32.PixelOperations.Generated.cs index 4e7800c624..b9f7a49e11 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Bgra32.PixelOperations.Generated.cs +++ b/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)); } - + /// public override void ToRgba32( Configuration configuration, @@ -71,7 +71,7 @@ public partial struct Bgra32 Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromBgra32.ToRgba32(source, dest); } - + /// public override void FromRgba32( Configuration configuration, @@ -84,8 +84,8 @@ public partial struct Bgra32 ReadOnlySpan source = MemoryMarshal.Cast(sourcePixels); Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromRgba32.ToBgra32(source, dest); - } - + } + /// public override void ToArgb32( Configuration configuration, @@ -99,7 +99,7 @@ public partial struct Bgra32 Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromBgra32.ToArgb32(source, dest); } - + /// public override void FromArgb32( Configuration configuration, @@ -112,8 +112,8 @@ public partial struct Bgra32 ReadOnlySpan source = MemoryMarshal.Cast(sourcePixels); Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromArgb32.ToBgra32(source, dest); - } - + } + /// public override void ToAbgr32( Configuration configuration, @@ -127,7 +127,7 @@ public partial struct Bgra32 Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromBgra32.ToAbgr32(source, dest); } - + /// public override void FromAbgr32( Configuration configuration, @@ -140,8 +140,8 @@ public partial struct Bgra32 ReadOnlySpan source = MemoryMarshal.Cast(sourcePixels); Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromAbgr32.ToBgra32(source, dest); - } - + } + /// public override void ToRgb24( Configuration configuration, @@ -155,7 +155,7 @@ public partial struct Bgra32 Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromBgra32.ToRgb24(source, dest); } - + /// public override void FromRgb24( Configuration configuration, @@ -168,8 +168,8 @@ public partial struct Bgra32 ReadOnlySpan source = MemoryMarshal.Cast(sourcePixels); Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromRgb24.ToBgra32(source, dest); - } - + } + /// public override void ToBgr24( Configuration configuration, @@ -183,7 +183,7 @@ public partial struct Bgra32 Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromBgra32.ToBgr24(source, dest); } - + /// public override void FromBgr24( Configuration configuration, @@ -196,7 +196,7 @@ public partial struct Bgra32 ReadOnlySpan source = MemoryMarshal.Cast(sourcePixels); Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromBgr24.ToBgra32(source, dest); - } + } /// public override void ToL8( @@ -210,7 +210,7 @@ public partial struct Bgra32 ref Bgra32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref L8 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Bgra32 sp = ref Unsafe.Add(ref sourceRef, i); ref L8 dp = ref Unsafe.Add(ref destRef, i); @@ -231,7 +231,7 @@ public partial struct Bgra32 ref Bgra32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref L16 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Bgra32 sp = ref Unsafe.Add(ref sourceRef, i); ref L16 dp = ref Unsafe.Add(ref destRef, i); @@ -252,7 +252,7 @@ public partial struct Bgra32 ref Bgra32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref La16 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Bgra32 sp = ref Unsafe.Add(ref sourceRef, i); ref La16 dp = ref Unsafe.Add(ref destRef, i); @@ -273,7 +273,7 @@ public partial struct Bgra32 ref Bgra32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref La32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Bgra32 sp = ref Unsafe.Add(ref sourceRef, i); ref La32 dp = ref Unsafe.Add(ref destRef, i); @@ -294,7 +294,7 @@ public partial struct Bgra32 ref Bgra32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgb48 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Bgra32 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb48 dp = ref Unsafe.Add(ref destRef, i); @@ -315,7 +315,7 @@ public partial struct Bgra32 ref Bgra32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgba64 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Bgra32 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgba64 dp = ref Unsafe.Add(ref destRef, i); @@ -336,7 +336,7 @@ public partial struct Bgra32 ref Bgra32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Bgra32 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgra5551 dp = ref Unsafe.Add(ref destRef, i); diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Bgra5551.PixelOperations.Generated.cs b/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Bgra5551.PixelOperations.Generated.cs index 62864ad209..c1ba4f0618 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Bgra5551.PixelOperations.Generated.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Bgra5551.PixelOperations.Generated.cs @@ -50,7 +50,7 @@ public partial struct Bgra5551 ref Bgra5551 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Argb32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Bgra5551 sp = ref Unsafe.Add(ref sourceRef, i); ref Argb32 dp = ref Unsafe.Add(ref destRef, i); @@ -71,7 +71,7 @@ public partial struct Bgra5551 ref Bgra5551 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Abgr32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Bgra5551 sp = ref Unsafe.Add(ref sourceRef, i); ref Abgr32 dp = ref Unsafe.Add(ref destRef, i); @@ -92,7 +92,7 @@ public partial struct Bgra5551 ref Bgra5551 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Bgr24 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Bgra5551 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgr24 dp = ref Unsafe.Add(ref destRef, i); @@ -113,7 +113,7 @@ public partial struct Bgra5551 ref Bgra5551 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Bgra32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Bgra5551 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgra32 dp = ref Unsafe.Add(ref destRef, i); @@ -134,7 +134,7 @@ public partial struct Bgra5551 ref Bgra5551 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref L8 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Bgra5551 sp = ref Unsafe.Add(ref sourceRef, i); ref L8 dp = ref Unsafe.Add(ref destRef, i); @@ -155,7 +155,7 @@ public partial struct Bgra5551 ref Bgra5551 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref L16 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Bgra5551 sp = ref Unsafe.Add(ref sourceRef, i); ref L16 dp = ref Unsafe.Add(ref destRef, i); @@ -176,7 +176,7 @@ public partial struct Bgra5551 ref Bgra5551 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref La16 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Bgra5551 sp = ref Unsafe.Add(ref sourceRef, i); ref La16 dp = ref Unsafe.Add(ref destRef, i); @@ -197,7 +197,7 @@ public partial struct Bgra5551 ref Bgra5551 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref La32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Bgra5551 sp = ref Unsafe.Add(ref sourceRef, i); ref La32 dp = ref Unsafe.Add(ref destRef, i); @@ -218,7 +218,7 @@ public partial struct Bgra5551 ref Bgra5551 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgb24 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Bgra5551 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb24 dp = ref Unsafe.Add(ref destRef, i); @@ -239,7 +239,7 @@ public partial struct Bgra5551 ref Bgra5551 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgba32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Bgra5551 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgba32 dp = ref Unsafe.Add(ref destRef, i); @@ -260,7 +260,7 @@ public partial struct Bgra5551 ref Bgra5551 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgb48 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Bgra5551 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb48 dp = ref Unsafe.Add(ref destRef, i); @@ -281,7 +281,7 @@ public partial struct Bgra5551 ref Bgra5551 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgba64 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Bgra5551 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgba64 dp = ref Unsafe.Add(ref destRef, i); diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/L16.PixelOperations.Generated.cs b/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/L16.PixelOperations.Generated.cs index b37d9d86aa..c38d752ea6 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/L16.PixelOperations.Generated.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/L16.PixelOperations.Generated.cs @@ -50,7 +50,7 @@ public partial struct L16 ref L16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Argb32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref L16 sp = ref Unsafe.Add(ref sourceRef, i); ref Argb32 dp = ref Unsafe.Add(ref destRef, i); @@ -71,7 +71,7 @@ public partial struct L16 ref L16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Abgr32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref L16 sp = ref Unsafe.Add(ref sourceRef, i); ref Abgr32 dp = ref Unsafe.Add(ref destRef, i); @@ -92,7 +92,7 @@ public partial struct L16 ref L16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Bgr24 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref L16 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgr24 dp = ref Unsafe.Add(ref destRef, i); @@ -113,7 +113,7 @@ public partial struct L16 ref L16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Bgra32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref L16 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgra32 dp = ref Unsafe.Add(ref destRef, i); @@ -134,7 +134,7 @@ public partial struct L16 ref L16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref L8 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref L16 sp = ref Unsafe.Add(ref sourceRef, i); ref L8 dp = ref Unsafe.Add(ref destRef, i); @@ -155,7 +155,7 @@ public partial struct L16 ref L16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref La16 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref L16 sp = ref Unsafe.Add(ref sourceRef, i); ref La16 dp = ref Unsafe.Add(ref destRef, i); @@ -176,7 +176,7 @@ public partial struct L16 ref L16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref La32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref L16 sp = ref Unsafe.Add(ref sourceRef, i); ref La32 dp = ref Unsafe.Add(ref destRef, i); @@ -197,7 +197,7 @@ public partial struct L16 ref L16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgb24 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref L16 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb24 dp = ref Unsafe.Add(ref destRef, i); @@ -218,7 +218,7 @@ public partial struct L16 ref L16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgba32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref L16 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgba32 dp = ref Unsafe.Add(ref destRef, i); @@ -239,7 +239,7 @@ public partial struct L16 ref L16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgb48 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref L16 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb48 dp = ref Unsafe.Add(ref destRef, i); @@ -260,7 +260,7 @@ public partial struct L16 ref L16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgba64 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref L16 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgba64 dp = ref Unsafe.Add(ref destRef, i); @@ -281,7 +281,7 @@ public partial struct L16 ref L16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref L16 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgra5551 dp = ref Unsafe.Add(ref destRef, i); diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/L8.PixelOperations.Generated.cs b/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/L8.PixelOperations.Generated.cs index 9d67d8741f..656a0546ba 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/L8.PixelOperations.Generated.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/L8.PixelOperations.Generated.cs @@ -50,7 +50,7 @@ public partial struct L8 ref L8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Argb32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref L8 sp = ref Unsafe.Add(ref sourceRef, i); ref Argb32 dp = ref Unsafe.Add(ref destRef, i); @@ -71,7 +71,7 @@ public partial struct L8 ref L8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Abgr32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref L8 sp = ref Unsafe.Add(ref sourceRef, i); ref Abgr32 dp = ref Unsafe.Add(ref destRef, i); @@ -92,7 +92,7 @@ public partial struct L8 ref L8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Bgr24 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref L8 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgr24 dp = ref Unsafe.Add(ref destRef, i); @@ -113,7 +113,7 @@ public partial struct L8 ref L8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Bgra32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref L8 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgra32 dp = ref Unsafe.Add(ref destRef, i); @@ -134,7 +134,7 @@ public partial struct L8 ref L8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref L16 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref L8 sp = ref Unsafe.Add(ref sourceRef, i); ref L16 dp = ref Unsafe.Add(ref destRef, i); @@ -155,7 +155,7 @@ public partial struct L8 ref L8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref La16 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref L8 sp = ref Unsafe.Add(ref sourceRef, i); ref La16 dp = ref Unsafe.Add(ref destRef, i); @@ -176,7 +176,7 @@ public partial struct L8 ref L8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref La32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref L8 sp = ref Unsafe.Add(ref sourceRef, i); ref La32 dp = ref Unsafe.Add(ref destRef, i); @@ -197,7 +197,7 @@ public partial struct L8 ref L8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgb24 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref L8 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb24 dp = ref Unsafe.Add(ref destRef, i); @@ -218,7 +218,7 @@ public partial struct L8 ref L8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgba32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref L8 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgba32 dp = ref Unsafe.Add(ref destRef, i); @@ -239,7 +239,7 @@ public partial struct L8 ref L8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgb48 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref L8 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb48 dp = ref Unsafe.Add(ref destRef, i); @@ -260,7 +260,7 @@ public partial struct L8 ref L8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgba64 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref L8 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgba64 dp = ref Unsafe.Add(ref destRef, i); @@ -281,7 +281,7 @@ public partial struct L8 ref L8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref L8 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgra5551 dp = ref Unsafe.Add(ref destRef, i); diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/La16.PixelOperations.Generated.cs b/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/La16.PixelOperations.Generated.cs index 5afea82021..82be1323cd 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/La16.PixelOperations.Generated.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/La16.PixelOperations.Generated.cs @@ -50,7 +50,7 @@ public partial struct La16 ref La16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Argb32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref La16 sp = ref Unsafe.Add(ref sourceRef, i); ref Argb32 dp = ref Unsafe.Add(ref destRef, i); @@ -71,7 +71,7 @@ public partial struct La16 ref La16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Abgr32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref La16 sp = ref Unsafe.Add(ref sourceRef, i); ref Abgr32 dp = ref Unsafe.Add(ref destRef, i); @@ -92,7 +92,7 @@ public partial struct La16 ref La16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Bgr24 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref La16 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgr24 dp = ref Unsafe.Add(ref destRef, i); @@ -113,7 +113,7 @@ public partial struct La16 ref La16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); 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 Bgra32 dp = ref Unsafe.Add(ref destRef, i); @@ -134,7 +134,7 @@ public partial struct La16 ref La16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); 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 L8 dp = ref Unsafe.Add(ref destRef, i); @@ -155,7 +155,7 @@ public partial struct La16 ref La16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); 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 L16 dp = ref Unsafe.Add(ref destRef, i); @@ -176,7 +176,7 @@ public partial struct La16 ref La16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); 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 La32 dp = ref Unsafe.Add(ref destRef, i); @@ -197,7 +197,7 @@ public partial struct La16 ref La16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); 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 Rgb24 dp = ref Unsafe.Add(ref destRef, i); @@ -218,7 +218,7 @@ public partial struct La16 ref La16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); 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 Rgba32 dp = ref Unsafe.Add(ref destRef, i); @@ -239,7 +239,7 @@ public partial struct La16 ref La16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); 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 Rgb48 dp = ref Unsafe.Add(ref destRef, i); @@ -260,7 +260,7 @@ public partial struct La16 ref La16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); 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 Rgba64 dp = ref Unsafe.Add(ref destRef, i); @@ -281,7 +281,7 @@ public partial struct La16 ref La16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); 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 Bgra5551 dp = ref Unsafe.Add(ref destRef, i); diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/La32.PixelOperations.Generated.cs b/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/La32.PixelOperations.Generated.cs index 76da66a1ad..a9ee9d6b78 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/La32.PixelOperations.Generated.cs +++ b/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 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 Argb32 dp = ref Unsafe.Add(ref destRef, i); @@ -71,7 +71,7 @@ public partial struct La32 ref La32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); 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 Abgr32 dp = ref Unsafe.Add(ref destRef, i); @@ -92,7 +92,7 @@ public partial struct La32 ref La32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); 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 Bgr24 dp = ref Unsafe.Add(ref destRef, i); @@ -113,7 +113,7 @@ public partial struct La32 ref La32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); 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 Bgra32 dp = ref Unsafe.Add(ref destRef, i); @@ -134,7 +134,7 @@ public partial struct La32 ref La32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); 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 L8 dp = ref Unsafe.Add(ref destRef, i); @@ -155,7 +155,7 @@ public partial struct La32 ref La32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); 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 L16 dp = ref Unsafe.Add(ref destRef, i); @@ -176,7 +176,7 @@ public partial struct La32 ref La32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); 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 La16 dp = ref Unsafe.Add(ref destRef, i); @@ -197,7 +197,7 @@ public partial struct La32 ref La32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); 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 Rgb24 dp = ref Unsafe.Add(ref destRef, i); @@ -218,7 +218,7 @@ public partial struct La32 ref La32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); 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 Rgba32 dp = ref Unsafe.Add(ref destRef, i); @@ -239,7 +239,7 @@ public partial struct La32 ref La32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); 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 Rgb48 dp = ref Unsafe.Add(ref destRef, i); @@ -260,7 +260,7 @@ public partial struct La32 ref La32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); 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 Rgba64 dp = ref Unsafe.Add(ref destRef, i); @@ -281,7 +281,7 @@ public partial struct La32 ref La32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); 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 Bgra5551 dp = ref Unsafe.Add(ref destRef, i); diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Rgb24.PixelOperations.Generated.cs b/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Rgb24.PixelOperations.Generated.cs index 519f1a6936..1d87121e92 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Rgb24.PixelOperations.Generated.cs +++ b/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)); } - + /// public override void ToRgba32( Configuration configuration, @@ -71,7 +71,7 @@ public partial struct Rgb24 Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromRgb24.ToRgba32(source, dest); } - + /// public override void FromRgba32( Configuration configuration, @@ -84,8 +84,8 @@ public partial struct Rgb24 ReadOnlySpan source = MemoryMarshal.Cast(sourcePixels); Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromRgba32.ToRgb24(source, dest); - } - + } + /// public override void ToArgb32( Configuration configuration, @@ -99,7 +99,7 @@ public partial struct Rgb24 Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromRgb24.ToArgb32(source, dest); } - + /// public override void FromArgb32( Configuration configuration, @@ -112,8 +112,8 @@ public partial struct Rgb24 ReadOnlySpan source = MemoryMarshal.Cast(sourcePixels); Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromArgb32.ToRgb24(source, dest); - } - + } + /// public override void ToAbgr32( Configuration configuration, @@ -127,7 +127,7 @@ public partial struct Rgb24 Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromRgb24.ToAbgr32(source, dest); } - + /// public override void FromAbgr32( Configuration configuration, @@ -140,8 +140,8 @@ public partial struct Rgb24 ReadOnlySpan source = MemoryMarshal.Cast(sourcePixels); Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromAbgr32.ToRgb24(source, dest); - } - + } + /// public override void ToBgra32( Configuration configuration, @@ -155,7 +155,7 @@ public partial struct Rgb24 Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromRgb24.ToBgra32(source, dest); } - + /// public override void FromBgra32( Configuration configuration, @@ -168,8 +168,8 @@ public partial struct Rgb24 ReadOnlySpan source = MemoryMarshal.Cast(sourcePixels); Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromBgra32.ToRgb24(source, dest); - } - + } + /// public override void ToBgr24( Configuration configuration, @@ -183,7 +183,7 @@ public partial struct Rgb24 Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromRgb24.ToBgr24(source, dest); } - + /// public override void FromBgr24( Configuration configuration, @@ -196,7 +196,7 @@ public partial struct Rgb24 ReadOnlySpan source = MemoryMarshal.Cast(sourcePixels); Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromBgr24.ToRgb24(source, dest); - } + } /// public override void ToL8( @@ -210,7 +210,7 @@ public partial struct Rgb24 ref Rgb24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref L8 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Rgb24 sp = ref Unsafe.Add(ref sourceRef, i); ref L8 dp = ref Unsafe.Add(ref destRef, i); @@ -231,7 +231,7 @@ public partial struct Rgb24 ref Rgb24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref L16 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Rgb24 sp = ref Unsafe.Add(ref sourceRef, i); ref L16 dp = ref Unsafe.Add(ref destRef, i); @@ -252,7 +252,7 @@ public partial struct Rgb24 ref Rgb24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref La16 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Rgb24 sp = ref Unsafe.Add(ref sourceRef, i); ref La16 dp = ref Unsafe.Add(ref destRef, i); @@ -273,7 +273,7 @@ public partial struct Rgb24 ref Rgb24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref La32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Rgb24 sp = ref Unsafe.Add(ref sourceRef, i); ref La32 dp = ref Unsafe.Add(ref destRef, i); @@ -294,7 +294,7 @@ public partial struct Rgb24 ref Rgb24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgb48 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Rgb24 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb48 dp = ref Unsafe.Add(ref destRef, i); @@ -315,7 +315,7 @@ public partial struct Rgb24 ref Rgb24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgba64 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Rgb24 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgba64 dp = ref Unsafe.Add(ref destRef, i); @@ -336,7 +336,7 @@ public partial struct Rgb24 ref Rgb24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Rgb24 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgra5551 dp = ref Unsafe.Add(ref destRef, i); diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Rgb48.PixelOperations.Generated.cs b/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Rgb48.PixelOperations.Generated.cs index e58818deac..60cfdad4b6 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Rgb48.PixelOperations.Generated.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Rgb48.PixelOperations.Generated.cs @@ -50,7 +50,7 @@ public partial struct Rgb48 ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Argb32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i); ref Argb32 dp = ref Unsafe.Add(ref destRef, i); @@ -71,7 +71,7 @@ public partial struct Rgb48 ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Abgr32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i); ref Abgr32 dp = ref Unsafe.Add(ref destRef, i); @@ -92,7 +92,7 @@ public partial struct Rgb48 ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Bgr24 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgr24 dp = ref Unsafe.Add(ref destRef, i); @@ -113,7 +113,7 @@ public partial struct Rgb48 ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Bgra32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgra32 dp = ref Unsafe.Add(ref destRef, i); @@ -134,7 +134,7 @@ public partial struct Rgb48 ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref L8 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i); ref L8 dp = ref Unsafe.Add(ref destRef, i); @@ -155,7 +155,7 @@ public partial struct Rgb48 ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref L16 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i); ref L16 dp = ref Unsafe.Add(ref destRef, i); @@ -176,7 +176,7 @@ public partial struct Rgb48 ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref La16 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i); ref La16 dp = ref Unsafe.Add(ref destRef, i); @@ -197,7 +197,7 @@ public partial struct Rgb48 ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref La32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i); ref La32 dp = ref Unsafe.Add(ref destRef, i); @@ -218,7 +218,7 @@ public partial struct Rgb48 ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgb24 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb24 dp = ref Unsafe.Add(ref destRef, i); @@ -239,7 +239,7 @@ public partial struct Rgb48 ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgba32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgba32 dp = ref Unsafe.Add(ref destRef, i); @@ -260,7 +260,7 @@ public partial struct Rgb48 ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgba64 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgba64 dp = ref Unsafe.Add(ref destRef, i); @@ -281,7 +281,7 @@ public partial struct Rgb48 ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgra5551 dp = ref Unsafe.Add(ref destRef, i); diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Rgba32.PixelOperations.Generated.cs b/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Rgba32.PixelOperations.Generated.cs index c635a4d6a4..da7c9a6c91 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Rgba32.PixelOperations.Generated.cs +++ b/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)); } - + /// public override void ToArgb32( Configuration configuration, @@ -51,7 +51,7 @@ public partial struct Rgba32 Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromRgba32.ToArgb32(source, dest); } - + /// public override void FromArgb32( Configuration configuration, @@ -64,8 +64,8 @@ public partial struct Rgba32 ReadOnlySpan source = MemoryMarshal.Cast(sourcePixels); Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromArgb32.ToRgba32(source, dest); - } - + } + /// public override void ToAbgr32( Configuration configuration, @@ -79,7 +79,7 @@ public partial struct Rgba32 Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromRgba32.ToAbgr32(source, dest); } - + /// public override void FromAbgr32( Configuration configuration, @@ -92,8 +92,8 @@ public partial struct Rgba32 ReadOnlySpan source = MemoryMarshal.Cast(sourcePixels); Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromAbgr32.ToRgba32(source, dest); - } - + } + /// public override void ToBgra32( Configuration configuration, @@ -107,7 +107,7 @@ public partial struct Rgba32 Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromRgba32.ToBgra32(source, dest); } - + /// public override void FromBgra32( Configuration configuration, @@ -120,8 +120,8 @@ public partial struct Rgba32 ReadOnlySpan source = MemoryMarshal.Cast(sourcePixels); Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromBgra32.ToRgba32(source, dest); - } - + } + /// public override void ToRgb24( Configuration configuration, @@ -135,7 +135,7 @@ public partial struct Rgba32 Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromRgba32.ToRgb24(source, dest); } - + /// public override void FromRgb24( Configuration configuration, @@ -148,8 +148,8 @@ public partial struct Rgba32 ReadOnlySpan source = MemoryMarshal.Cast(sourcePixels); Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromRgb24.ToRgba32(source, dest); - } - + } + /// public override void ToBgr24( Configuration configuration, @@ -163,7 +163,7 @@ public partial struct Rgba32 Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromRgba32.ToBgr24(source, dest); } - + /// public override void FromBgr24( Configuration configuration, @@ -176,7 +176,7 @@ public partial struct Rgba32 ReadOnlySpan source = MemoryMarshal.Cast(sourcePixels); Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromBgr24.ToRgba32(source, dest); - } + } /// public override void ToL8( @@ -190,7 +190,7 @@ public partial struct Rgba32 ref Rgba32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); 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 L8 dp = ref Unsafe.Add(ref destRef, i); @@ -211,7 +211,7 @@ public partial struct Rgba32 ref Rgba32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); 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 L16 dp = ref Unsafe.Add(ref destRef, i); @@ -232,7 +232,7 @@ public partial struct Rgba32 ref Rgba32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); 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 La16 dp = ref Unsafe.Add(ref destRef, i); @@ -253,7 +253,7 @@ public partial struct Rgba32 ref Rgba32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); 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 La32 dp = ref Unsafe.Add(ref destRef, i); @@ -274,7 +274,7 @@ public partial struct Rgba32 ref Rgba32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); 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 Rgb48 dp = ref Unsafe.Add(ref destRef, i); @@ -295,7 +295,7 @@ public partial struct Rgba32 ref Rgba32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); 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 Rgba64 dp = ref Unsafe.Add(ref destRef, i); @@ -316,7 +316,7 @@ public partial struct Rgba32 ref Rgba32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); 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 Bgra5551 dp = ref Unsafe.Add(ref destRef, i); diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Rgba64.PixelOperations.Generated.cs b/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Rgba64.PixelOperations.Generated.cs index 395f7e88e0..b6236f8a66 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Rgba64.PixelOperations.Generated.cs +++ b/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 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 Argb32 dp = ref Unsafe.Add(ref destRef, i); @@ -71,7 +71,7 @@ public partial struct Rgba64 ref Rgba64 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); 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 Abgr32 dp = ref Unsafe.Add(ref destRef, i); @@ -92,7 +92,7 @@ public partial struct Rgba64 ref Rgba64 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); 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 Bgr24 dp = ref Unsafe.Add(ref destRef, i); @@ -113,7 +113,7 @@ public partial struct Rgba64 ref Rgba64 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); 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 Bgra32 dp = ref Unsafe.Add(ref destRef, i); @@ -134,7 +134,7 @@ public partial struct Rgba64 ref Rgba64 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); 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 L8 dp = ref Unsafe.Add(ref destRef, i); @@ -155,7 +155,7 @@ public partial struct Rgba64 ref Rgba64 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); 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 L16 dp = ref Unsafe.Add(ref destRef, i); @@ -176,7 +176,7 @@ public partial struct Rgba64 ref Rgba64 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); 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 La16 dp = ref Unsafe.Add(ref destRef, i); @@ -197,7 +197,7 @@ public partial struct Rgba64 ref Rgba64 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); 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 La32 dp = ref Unsafe.Add(ref destRef, i); @@ -218,7 +218,7 @@ public partial struct Rgba64 ref Rgba64 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); 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 Rgb24 dp = ref Unsafe.Add(ref destRef, i); @@ -239,7 +239,7 @@ public partial struct Rgba64 ref Rgba64 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); 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 Rgba32 dp = ref Unsafe.Add(ref destRef, i); @@ -260,7 +260,7 @@ public partial struct Rgba64 ref Rgba64 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); 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 Rgb48 dp = ref Unsafe.Add(ref destRef, i); @@ -281,7 +281,7 @@ public partial struct Rgba64 ref Rgba64 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); 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 Bgra5551 dp = ref Unsafe.Add(ref destRef, i); diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/_Common.ttinclude b/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/_Common.ttinclude index 5a5d135db1..f7e178d7f2 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/_Common.ttinclude +++ b/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/_Common.ttinclude @@ -103,7 +103,7 @@ using SixLabors.ImageSharp.PixelFormats.Utils; ref <#=fromPixelType#> sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref <#=toPixelType#> destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref <#=fromPixelType#> sp = ref Unsafe.Add(ref sourceRef, i); ref <#=toPixelType#> dp = ref Unsafe.Add(ref destRef, i); diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/RgbaVector.PixelOperations.cs b/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/RgbaVector.PixelOperations.cs index ed1d3cb2bd..a3833583fc 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/RgbaVector.PixelOperations.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/RgbaVector.PixelOperations.cs @@ -72,7 +72,7 @@ public partial struct RgbaVector ref Vector4 sourceBaseRef = ref Unsafe.As(ref MemoryMarshal.GetReference(sourcePixels)); 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 L8 dp = ref Unsafe.Add(ref destBaseRef, i); @@ -91,7 +91,7 @@ public partial struct RgbaVector ref Vector4 sourceBaseRef = ref Unsafe.As(ref MemoryMarshal.GetReference(sourcePixels)); 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 L16 dp = ref Unsafe.Add(ref destBaseRef, i); diff --git a/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.Generated.cs b/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.Generated.cs index 26ca4d1b5a..7e84bd6392 100644 --- a/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.Generated.cs +++ b/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.Generated.cs @@ -22,7 +22,7 @@ public partial class PixelOperations ref Argb32 sourceBaseRef = ref MemoryMarshal.GetReference(source); 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 TPixel dp = ref Unsafe.Add(ref destBaseRef, i); @@ -58,7 +58,7 @@ public partial class PixelOperations ref TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels); 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 Argb32 dp = ref Unsafe.Add(ref destBaseRef, i); @@ -94,7 +94,7 @@ public partial class PixelOperations ref Abgr32 sourceBaseRef = ref MemoryMarshal.GetReference(source); 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 TPixel dp = ref Unsafe.Add(ref destBaseRef, i); @@ -130,7 +130,7 @@ public partial class PixelOperations ref TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels); 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 Abgr32 dp = ref Unsafe.Add(ref destBaseRef, i); @@ -166,7 +166,7 @@ public partial class PixelOperations ref Bgr24 sourceBaseRef = ref MemoryMarshal.GetReference(source); 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 TPixel dp = ref Unsafe.Add(ref destBaseRef, i); @@ -202,7 +202,7 @@ public partial class PixelOperations ref TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels); 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 Bgr24 dp = ref Unsafe.Add(ref destBaseRef, i); @@ -238,7 +238,7 @@ public partial class PixelOperations ref Bgra32 sourceBaseRef = ref MemoryMarshal.GetReference(source); 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 TPixel dp = ref Unsafe.Add(ref destBaseRef, i); @@ -274,7 +274,7 @@ public partial class PixelOperations ref TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels); 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 Bgra32 dp = ref Unsafe.Add(ref destBaseRef, i); @@ -310,7 +310,7 @@ public partial class PixelOperations ref L8 sourceBaseRef = ref MemoryMarshal.GetReference(source); 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 TPixel dp = ref Unsafe.Add(ref destBaseRef, i); @@ -346,7 +346,7 @@ public partial class PixelOperations ref TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels); 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 L8 dp = ref Unsafe.Add(ref destBaseRef, i); @@ -382,7 +382,7 @@ public partial class PixelOperations ref L16 sourceBaseRef = ref MemoryMarshal.GetReference(source); 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 TPixel dp = ref Unsafe.Add(ref destBaseRef, i); @@ -418,7 +418,7 @@ public partial class PixelOperations ref TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels); 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 L16 dp = ref Unsafe.Add(ref destBaseRef, i); @@ -454,7 +454,7 @@ public partial class PixelOperations ref La16 sourceBaseRef = ref MemoryMarshal.GetReference(source); 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 TPixel dp = ref Unsafe.Add(ref destBaseRef, i); @@ -490,7 +490,7 @@ public partial class PixelOperations ref TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels); 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 La16 dp = ref Unsafe.Add(ref destBaseRef, i); @@ -526,7 +526,7 @@ public partial class PixelOperations ref La32 sourceBaseRef = ref MemoryMarshal.GetReference(source); 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 TPixel dp = ref Unsafe.Add(ref destBaseRef, i); @@ -562,7 +562,7 @@ public partial class PixelOperations ref TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels); 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 La32 dp = ref Unsafe.Add(ref destBaseRef, i); @@ -598,7 +598,7 @@ public partial class PixelOperations ref Rgb24 sourceBaseRef = ref MemoryMarshal.GetReference(source); 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 TPixel dp = ref Unsafe.Add(ref destBaseRef, i); @@ -634,7 +634,7 @@ public partial class PixelOperations ref TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels); 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 Rgb24 dp = ref Unsafe.Add(ref destBaseRef, i); @@ -670,7 +670,7 @@ public partial class PixelOperations ref Rgba32 sourceBaseRef = ref MemoryMarshal.GetReference(source); 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 TPixel dp = ref Unsafe.Add(ref destBaseRef, i); @@ -706,7 +706,7 @@ public partial class PixelOperations ref TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels); 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 Rgba32 dp = ref Unsafe.Add(ref destBaseRef, i); @@ -742,7 +742,7 @@ public partial class PixelOperations ref Rgb48 sourceBaseRef = ref MemoryMarshal.GetReference(source); 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 TPixel dp = ref Unsafe.Add(ref destBaseRef, i); @@ -778,7 +778,7 @@ public partial class PixelOperations ref TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels); 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 Rgb48 dp = ref Unsafe.Add(ref destBaseRef, i); @@ -814,7 +814,7 @@ public partial class PixelOperations ref Rgba64 sourceBaseRef = ref MemoryMarshal.GetReference(source); 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 TPixel dp = ref Unsafe.Add(ref destBaseRef, i); @@ -850,7 +850,7 @@ public partial class PixelOperations ref TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels); 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 Rgba64 dp = ref Unsafe.Add(ref destBaseRef, i); @@ -886,7 +886,7 @@ public partial class PixelOperations ref Bgra5551 sourceBaseRef = ref MemoryMarshal.GetReference(source); 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 TPixel dp = ref Unsafe.Add(ref destBaseRef, i); @@ -922,7 +922,7 @@ public partial class PixelOperations ref TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels); 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 Bgra5551 dp = ref Unsafe.Add(ref destBaseRef, i); diff --git a/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.Generated.tt b/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.Generated.tt index 39cf873bfd..8ba3398e39 100644 --- a/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.Generated.tt +++ b/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.Generated.tt @@ -28,7 +28,7 @@ ref <#=pixelType#> sourceBaseRef = ref MemoryMarshal.GetReference(source); ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); - for (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 TPixel dp = ref Unsafe.Add(ref destBaseRef, i); @@ -70,7 +70,7 @@ ref TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels); ref <#=pixelType#> destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); - for (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 <#=pixelType#> dp = ref Unsafe.Add(ref destBaseRef, i); diff --git a/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.cs b/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.cs index b18e38f4d5..9d93d27aca 100644 --- a/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.cs +++ b/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.cs @@ -187,7 +187,7 @@ public partial class PixelOperations ref byte b = ref MemoryMarshal.GetReference(blueChannel); 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.G = Unsafe.Add(ref g, i); @@ -218,7 +218,7 @@ public partial class PixelOperations ref float g = ref MemoryMarshal.GetReference(greenChannel); ref float b = ref MemoryMarshal.GetReference(blueChannel); 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 r, i) = rgba32.R; diff --git a/src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationSlidingWindowProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationSlidingWindowProcessor{TPixel}.cs index bbac9b9d8e..d2bec0b49b 100644 --- a/src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationSlidingWindowProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationSlidingWindowProcessor{TPixel}.cs @@ -254,9 +254,9 @@ internal class AdaptiveHistogramEqualizationSlidingWindowProcessor : His [MethodImpl(InliningOptions.ShortMethod)] 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)++; } } @@ -271,9 +271,9 @@ internal class AdaptiveHistogramEqualizationSlidingWindowProcessor : His [MethodImpl(InliningOptions.ShortMethod)] 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)--; } } diff --git a/src/ImageSharp/Processing/Processors/Normalization/HistogramEqualizationProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Normalization/HistogramEqualizationProcessor{TPixel}.cs index 80f2b15bc1..6ac36f3ce0 100644 --- a/src/ImageSharp/Processing/Processors/Normalization/HistogramEqualizationProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Normalization/HistogramEqualizationProcessor{TPixel}.cs @@ -73,7 +73,7 @@ internal abstract class HistogramEqualizationProcessor : ImageProcessor< int cdfMin = 0; 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); if (!cdfMinFound && histSum != 0) @@ -101,7 +101,7 @@ internal abstract class HistogramEqualizationProcessor : ImageProcessor< int sumOverClip = 0; 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); if (histogramLevel > clipLimit) @@ -115,7 +115,7 @@ internal abstract class HistogramEqualizationProcessor : ImageProcessor< int addToEachBin = sumOverClip > 0 ? (int)MathF.Floor(sumOverClip / this.luminanceLevelsFloat) : 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; } @@ -124,8 +124,8 @@ internal abstract class HistogramEqualizationProcessor : ImageProcessor< int residual = sumOverClip - (addToEachBin * this.LuminanceLevels); if (residual != 0) { - int residualStep = Math.Max(this.LuminanceLevels / residual, 1); - for (nint i = 0; i < (uint)this.LuminanceLevels && residual > 0; i += residualStep, residual--) + uint residualStep = (uint)Math.Max(this.LuminanceLevels / residual, 1); + for (nuint i = 0; i < (uint)this.LuminanceLevels && residual > 0; i += residualStep, residual--) { ref int histogramLevel = ref Unsafe.Add(ref histogramBase, i); histogramLevel++; diff --git a/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeKernelMap.cs b/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeKernelMap.cs index e492011788..c1907bb520 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeKernelMap.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeKernelMap.cs @@ -100,7 +100,7 @@ internal partial class ResizeKernelMap : IDisposable /// Returns a for an index value between 0 and DestinationSize - 1. /// [MethodImpl(InliningOptions.ShortMethod)] - internal ref ResizeKernel GetKernel(nint destIdx) => ref this.kernels[destIdx]; + internal ref ResizeKernel GetKernel(nuint destIdx) => ref this.kernels[(int)destIdx]; /// /// Computes the weights to apply at each pixel when resizing. diff --git a/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeWorker.cs b/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeWorker.cs index 10525641ca..cce27a401c 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeWorker.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeWorker.cs @@ -119,7 +119,7 @@ internal sealed class ResizeWorker : IDisposable for (int y = rowInterval.Min; y < rowInterval.Max; y++) { // 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) { @@ -132,9 +132,9 @@ internal sealed class ResizeWorker : IDisposable 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 Unsafe.Add(ref tempRowBase, x) = kernel.ConvolveCore(ref firstPassColumnBase); @@ -169,9 +169,9 @@ internal sealed class ResizeWorker : IDisposable Span tempRowSpan = this.tempRowBuffer.GetSpan(); Span transposedFirstPassBufferSpan = this.transposedFirstPassBuffer.DangerousGetSingleSpan(); - int left = this.targetWorkingRect.Left; - int right = this.targetWorkingRect.Right; - int targetOriginX = this.targetOrigin.X; + nuint left = (uint)this.targetWorkingRect.Left; + nuint right = (uint)this.targetWorkingRect.Right; + nuint targetOriginX = (uint)this.targetOrigin.X; for (int y = calculationInterval.Min; y < calculationInterval.Max; y++) { Span sourceRow = this.source.DangerousGetRowSpan(y); @@ -186,13 +186,13 @@ internal sealed class ResizeWorker : IDisposable // Span firstPassSpan = transposedFirstPassBufferSpan.Slice(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); // optimization for: // 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); } } } diff --git a/tests/ImageSharp.Benchmarks/Bulk/FromVector4.cs b/tests/ImageSharp.Benchmarks/Bulk/FromVector4.cs index ed129fca2f..f0eeb5afb7 100644 --- a/tests/ImageSharp.Benchmarks/Bulk/FromVector4.cs +++ b/tests/ImageSharp.Benchmarks/Bulk/FromVector4.cs @@ -47,7 +47,7 @@ public abstract class FromVector4 { ref Vector4 s = ref MemoryMarshal.GetReference(this.source.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)); } @@ -103,7 +103,7 @@ public class FromVector4Rgba32 : FromVector4 Span src = MemoryMarshal.Cast(this.source.GetSpan()); Span dest = MemoryMarshal.Cast(this.destination.GetSpan()); - nint n = (nint)(uint)dest.Length / Vector.Count; + nuint n = (uint)(dest.Length / Vector.Count); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(src)); @@ -114,7 +114,7 @@ public class FromVector4Rgba32 : FromVector4 var maxBytes = Vector256.Create(255f); - for (nint i = 0; i < n; i++) + for (nuint i = 0; i < n; i++) { ref Vector256 s = ref Unsafe.Add(ref sourceBase, i * 4); diff --git a/tests/ImageSharp.Benchmarks/Bulk/PremultiplyVector4.cs b/tests/ImageSharp.Benchmarks/Bulk/PremultiplyVector4.cs index 355216de34..4e2d2d36e9 100644 --- a/tests/ImageSharp.Benchmarks/Bulk/PremultiplyVector4.cs +++ b/tests/ImageSharp.Benchmarks/Bulk/PremultiplyVector4.cs @@ -17,7 +17,7 @@ public class PremultiplyVector4 { ref Vector4 baseRef = ref MemoryMarshal.GetReference(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); Premultiply(ref v); @@ -29,7 +29,7 @@ public class PremultiplyVector4 { ref Vector4 baseRef = ref MemoryMarshal.GetReference(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); Numerics.Premultiply(ref v); diff --git a/tests/ImageSharp.Benchmarks/Bulk/ToVector4_Rgba32.cs b/tests/ImageSharp.Benchmarks/Bulk/ToVector4_Rgba32.cs index 913ab24dc1..ce3fb70c88 100644 --- a/tests/ImageSharp.Benchmarks/Bulk/ToVector4_Rgba32.cs +++ b/tests/ImageSharp.Benchmarks/Bulk/ToVector4_Rgba32.cs @@ -54,13 +54,13 @@ public class ToVector4_Rgba32 : ToVector4 Span sBytes = MemoryMarshal.Cast(this.source.GetSpan()); Span dFloats = MemoryMarshal.Cast(this.destination.GetSpan()); - nint n = (nint)(uint)dFloats.Length / Vector.Count; + nuint n = (uint)(dFloats.Length / Vector.Count); ref Vector sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference((ReadOnlySpan)sBytes)); ref Vector destBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(dFloats)); ref Vector destBaseU = ref Unsafe.As, Vector>(ref destBase); - for (nint i = 0; i < n; i++) + for (nuint i = 0; i < n; i++) { Vector b = Unsafe.Add(ref sourceBase, i); @@ -75,10 +75,10 @@ public class ToVector4_Rgba32 : ToVector4 Unsafe.Add(ref d, 3) = w3; } - n = (nint)(uint)dFloats.Length / Vector.Count; + n = (uint)(dFloats.Length / Vector.Count); var scale = new Vector(1f / 255f); - for (nint i = 0; i < n; i++) + for (nuint i = 0; i < n; i++) { ref Vector dRef = ref Unsafe.Add(ref destBase, i); @@ -96,13 +96,13 @@ public class ToVector4_Rgba32 : ToVector4 Span sBytes = MemoryMarshal.Cast(this.source.GetSpan()); Span dFloats = MemoryMarshal.Cast(this.destination.GetSpan()); - nint n = (nint)(uint)dFloats.Length / Vector.Count; + nuint n = (uint)(dFloats.Length / Vector.Count); ref Vector sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference((ReadOnlySpan)sBytes)); ref Vector destBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(dFloats)); var scale = new Vector(1f / 255f); - for (nint i = 0; i < n; i++) + for (nuint i = 0; i < n; i++) { Vector b = Unsafe.Add(ref sourceBase, i); diff --git a/tests/ImageSharp.Benchmarks/Bulk/UnPremultiplyVector4.cs b/tests/ImageSharp.Benchmarks/Bulk/UnPremultiplyVector4.cs index 309eea34fd..95fdd9a8c3 100644 --- a/tests/ImageSharp.Benchmarks/Bulk/UnPremultiplyVector4.cs +++ b/tests/ImageSharp.Benchmarks/Bulk/UnPremultiplyVector4.cs @@ -17,7 +17,7 @@ public class UnPremultiplyVector4 { ref Vector4 baseRef = ref MemoryMarshal.GetReference(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); @@ -30,7 +30,7 @@ public class UnPremultiplyVector4 { ref Vector4 baseRef = ref MemoryMarshal.GetReference(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); Numerics.UnPremultiply(ref v); diff --git a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_CopyTo1x1.cs b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_CopyTo1x1.cs index abdd6908da..14598c747a 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_CopyTo1x1.cs +++ b/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 float origin = ref Unsafe.AsRef(this.bufferPtr); - nint stride = (nint)(uint)Width; + nuint stride = (uint)Width; ref Vector d0 = ref Unsafe.As>(ref origin); ref Vector d1 = ref Unsafe.As>(ref Unsafe.Add(ref origin, stride)); @@ -117,7 +117,7 @@ public unsafe class Block8x8F_CopyTo1x1 { ref Block8x8F s = ref this.block; ref float origin = ref Unsafe.AsRef(this.bufferPtr); - nint stride = (nint)(uint)Width; + nuint stride = (uint)Width; ref Vector d0 = ref Unsafe.As>(ref origin); ref Vector d1 = ref Unsafe.As>(ref Unsafe.Add(ref origin, stride)); @@ -141,7 +141,7 @@ public unsafe class Block8x8F_CopyTo1x1 [Benchmark] 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 Vector s = ref Unsafe.As>(ref this.block); @@ -254,7 +254,7 @@ public unsafe class Block8x8F_CopyTo1x1 [Benchmark] public void UseVector256_Avx2_Variant3_RefCast() { - nint stride = (nint)(uint)Width; + nuint stride = (uint)Width; ref float d = ref this.unpinnedBuffer[0]; ref Vector256 s = ref Unsafe.As>(ref this.block); @@ -282,7 +282,7 @@ public unsafe class Block8x8F_CopyTo1x1 [Benchmark] 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 Vector256 s = ref Unsafe.As>(ref this.block); diff --git a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_Round.cs b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_Round.cs index 2cc084885f..8a520b22d3 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_Round.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_Round.cs @@ -54,7 +54,7 @@ public unsafe class Block8x8F_Round { ref float b = ref Unsafe.As(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); v = (float)Math.Round(v); @@ -178,7 +178,7 @@ public unsafe class Block8x8F_Round { ref Vector128 p = ref Unsafe.As>(ref this.block); p = Sse41.RoundToNearestInteger(p); - nint offset = sizeof(Vector128); + nuint offset = (uint)sizeof(Vector128); p = Sse41.RoundToNearestInteger(p); p = ref Unsafe.AddByteOffset(ref p, offset); @@ -218,7 +218,7 @@ public unsafe class Block8x8F_Round { ref Vector128 p = ref Unsafe.As>(ref this.block); p = Sse41.RoundToNearestInteger(p); - nint offset = sizeof(Vector128); + nuint offset = (uint)sizeof(Vector128); for (int i = 0; i < 15; i++) { @@ -231,7 +231,7 @@ public unsafe class Block8x8F_Round public unsafe void Sse41_V4() { ref Vector128 p = ref Unsafe.As>(ref this.block); - nint offset = sizeof(Vector128); + nuint offset = (uint)sizeof(Vector128); ref Vector128 a = ref p; ref Vector128 b = ref Unsafe.AddByteOffset(ref a, offset); diff --git a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertFromRgba32.cs b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertFromRgba32.cs index 29e03111b9..8d16849825 100644 --- a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertFromRgba32.cs +++ b/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 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)); } @@ -48,7 +48,7 @@ public abstract class PixelConversion_ConvertFromRgba32 ref T destBaseRef = ref this.Dest[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)); } @@ -62,7 +62,7 @@ public abstract class PixelConversion_ConvertFromRgba32 ref T destBaseRef = ref this.Dest[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); 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 dBase = ref Unsafe.As(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); } @@ -151,7 +151,7 @@ public class PixelConversion_ConvertFromRgba32_Permuted_RgbaToArgb : PixelConver ref Rgba32 sBase = ref this.PermutedRunnerRgbaToArgb.Source[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); ref TestArgb d = ref Unsafe.Add(ref dBase, i); diff --git a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertFromVector4.cs b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertFromVector4.cs index faf23efe09..dd85d06417 100644 --- a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertFromVector4.cs +++ b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertFromVector4.cs @@ -71,7 +71,7 @@ public class PixelConversion_ConvertFromVector4 ref T destBaseRef = ref this.dest[0]; ref Vector4 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).FromVector4(ref Unsafe.Add(ref sourceBaseRef, i)); } @@ -85,7 +85,7 @@ public class PixelConversion_ConvertFromVector4 ref T destBaseRef = ref this.dest[0]; ref Vector4 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).FromVector4(Unsafe.Add(ref sourceBaseRef, i)); } diff --git a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToRgba32.cs b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToRgba32.cs index ef1ebdd429..1a03a0c04f 100644 --- a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToRgba32.cs +++ b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToRgba32.cs @@ -38,7 +38,7 @@ public class PixelConversion_ConvertToRgba32 ref T sourceBaseRef = ref this.source[0]; ref Rgba32 destBaseRef = ref this.dest[0]; - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { Unsafe.Add(ref destBaseRef, i) = Unsafe.Add(ref sourceBaseRef, i).ToRgba32(); } @@ -52,7 +52,7 @@ public class PixelConversion_ConvertToRgba32 ref T sourceBaseRef = ref this.source[0]; ref Rgba32 destBaseRef = ref this.dest[0]; - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { Unsafe.Add(ref sourceBaseRef, i).CopyToRgba32(ref Unsafe.Add(ref destBaseRef, i)); } diff --git a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToRgba32_AsPartOfCompositeOperation.cs b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToRgba32_AsPartOfCompositeOperation.cs index 29412e6ed6..69a71734a3 100644 --- a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToRgba32_AsPartOfCompositeOperation.cs +++ b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToRgba32_AsPartOfCompositeOperation.cs @@ -33,7 +33,7 @@ public class PixelConversion_ConvertToRgba32_AsPartOfCompositeOperation Rgba32 temp; - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { temp = Unsafe.Add(ref sourceBaseRef, i).ToRgba32(); @@ -54,7 +54,7 @@ public class PixelConversion_ConvertToRgba32_AsPartOfCompositeOperation Rgba32 temp = default; - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { Unsafe.Add(ref sourceBaseRef, i).CopyToRgba32(ref temp); diff --git a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToVector4.cs b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToVector4.cs index 29e8b00b6f..9b498b0f2e 100644 --- a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToVector4.cs +++ b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToVector4.cs @@ -30,7 +30,7 @@ public class PixelConversion_ConvertToVector4 ref T sourceBaseRef = ref this.source[0]; ref Vector4 destBaseRef = ref this.dest[0]; - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { Unsafe.Add(ref destBaseRef, i) = Unsafe.Add(ref sourceBaseRef, i).ToVector4(); } @@ -44,7 +44,7 @@ public class PixelConversion_ConvertToVector4 ref T sourceBaseRef = ref this.source[0]; ref Vector4 destBaseRef = ref this.dest[0]; - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { Unsafe.Add(ref sourceBaseRef, i).CopyToVector4(ref Unsafe.Add(ref destBaseRef, i)); } diff --git a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToVector4_AsPartOfCompositeOperation.cs b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToVector4_AsPartOfCompositeOperation.cs index 65b1717349..50c3d0d131 100644 --- a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToVector4_AsPartOfCompositeOperation.cs +++ b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToVector4_AsPartOfCompositeOperation.cs @@ -32,7 +32,7 @@ public class PixelConversion_ConvertToVector4_AsPartOfCompositeOperation Vector4 temp; - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { temp = Unsafe.Add(ref sourceBaseRef, i).ToVector4(); @@ -53,7 +53,7 @@ public class PixelConversion_ConvertToVector4_AsPartOfCompositeOperation Vector4 temp = default; - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { Unsafe.Add(ref sourceBaseRef, i).CopyToVector4(ref temp); diff --git a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_PackFromRgbPlanes.cs b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_PackFromRgbPlanes.cs index 5c9bfd763a..e3677d238d 100644 --- a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_PackFromRgbPlanes.cs +++ b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_PackFromRgbPlanes.cs @@ -92,7 +92,7 @@ public unsafe class PixelConversion_PackFromRgbPlanes ref byte b = ref this.rBuf[0]; ref Rgb24 rgb = ref this.rgbBuf[0]; - for (nint i = 0; i < (uint)this.Count; i++) + for (nuint i = 0; i < (uint)this.Count; i++) { ref Rgb24 d = ref Unsafe.Add(ref rgb, i); d.R = Unsafe.Add(ref r, i); @@ -110,7 +110,7 @@ public unsafe class PixelConversion_PackFromRgbPlanes ref Rgb24 rgb = ref this.rgbBuf[0]; int count = this.Count / 8; - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref Rgb24 d0 = ref Unsafe.Add(ref rgb, i * 8); ref Rgb24 d1 = ref Unsafe.Add(ref d0, 1); @@ -168,7 +168,7 @@ public unsafe class PixelConversion_PackFromRgbPlanes ref Rgb24 rgb = ref this.rgbBuf[0]; int count = this.Count / 4; - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref Rgb24 d0 = ref Unsafe.Add(ref rgb, i * 4); ref Rgb24 d1 = ref Unsafe.Add(ref d0, 1); @@ -205,14 +205,14 @@ public unsafe class PixelConversion_PackFromRgbPlanes ref Vector256 bBase = ref Unsafe.As>(ref this.bFloat[0]); ref Vector256 resultBase = ref Unsafe.As>(ref this.rgbaFloat[0]); - nint count = (nint)(uint)this.Count / Vector256.Count; + nuint count = (uint)(this.Count / Vector256.Count); ref byte control = ref MemoryMarshal.GetReference(SimdUtils.HwIntrinsics.PermuteMaskEvenOdd8x32); Vector256 vcontrol = Unsafe.As>(ref control); var va = Vector256.Create(1F); - for (nint i = 0; i < count; i++) + for (nuint i = 0; i < count; i++) { Vector256 r = Unsafe.Add(ref rBase, i); Vector256 g = Unsafe.Add(ref gBase, i); diff --git a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_Rgba32_To_Argb32.cs b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_Rgba32_To_Argb32.cs index f1d08b9fb9..0ee507832a 100644 --- a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_Rgba32_To_Argb32.cs +++ b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_Rgba32_To_Argb32.cs @@ -31,7 +31,7 @@ public class PixelConversion_Rgba32_To_Argb32 ref Rgba32 sBase = ref this.source[0]; ref Argb32 dBase = ref this.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); Unsafe.Add(ref dBase, i).FromRgba32(s); @@ -45,7 +45,7 @@ public class PixelConversion_Rgba32_To_Argb32 ref Rgba32 sBase = ref MemoryMarshal.GetReference(source); ref TPixel dBase = ref MemoryMarshal.GetReference(dest); - for (nint i = 0; i < (uint)source.Length; i++) + for (nuint i = 0; i < (uint)source.Length; i++) { Rgba32 s = Unsafe.Add(ref sBase, i); Unsafe.Add(ref dBase, i).FromRgba32(s); @@ -64,7 +64,7 @@ public class PixelConversion_Rgba32_To_Argb32 ref Rgba32 sBase = ref this.source[0]; ref Argb32 dBase = ref this.dest[0]; - for (nint i = 0; i < (uint)this.Count; i += 2) + for (nuint i = 0; i < (uint)this.Count; i += 2) { ref Rgba32 s0 = ref Unsafe.Add(ref sBase, i); Rgba32 s1 = Unsafe.Add(ref s0, 1); @@ -81,7 +81,7 @@ public class PixelConversion_Rgba32_To_Argb32 ref Rgba32 sBase = ref this.source[0]; ref Argb32 dBase = ref this.dest[0]; - for (nint i = 0; i < (uint)this.Count; i += 4) + for (nuint i = 0; i < (uint)this.Count; i += 4) { ref Rgba32 s0 = ref Unsafe.Add(ref sBase, i); ref Rgba32 s1 = ref Unsafe.Add(ref s0, 1); @@ -105,7 +105,7 @@ public class PixelConversion_Rgba32_To_Argb32 ref uint sBase = ref Unsafe.As(ref this.source[0]); ref uint dBase = ref Unsafe.As(ref this.dest[0]); - for (nint i = 0; i < (uint)this.Count; i++) + for (nuint i = 0; i < (uint)this.Count; i++) { uint s = Unsafe.Add(ref sBase, i); Unsafe.Add(ref dBase, i) = FromRgba32.ToArgb32(s); @@ -118,7 +118,7 @@ public class PixelConversion_Rgba32_To_Argb32 ref ulong sBase = ref Unsafe.As(ref this.source[0]); ref ulong dBase = ref Unsafe.As(ref this.dest[0]); - for (nint i = 0; i < (uint)this.Count / 2; i++) + for (nuint i = 0; i < (uint)this.Count / 2; i++) { ulong s = Unsafe.Add(ref sBase, i); uint lo = (uint)s; diff --git a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_Rgba32_To_Bgra32.cs b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_Rgba32_To_Bgra32.cs index 0da28c897d..499f3483dc 100644 --- a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_Rgba32_To_Bgra32.cs +++ b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_Rgba32_To_Bgra32.cs @@ -52,7 +52,7 @@ public class PixelConversion_Rgba32_To_Bgra32 ref Rgba32 sBase = ref this.source[0]; ref Bgra32 dBase = ref this.dest[0]; - for (nint i = 0; i < (uint)this.Count; i++) + for (nuint i = 0; i < (uint)this.Count; i++) { ref Rgba32 s = ref Unsafe.Add(ref sBase, i); Unsafe.Add(ref dBase, i).FromRgba32(s); @@ -66,7 +66,7 @@ public class PixelConversion_Rgba32_To_Bgra32 ref Rgba32 sBase = ref MemoryMarshal.GetReference(source); ref TPixel dBase = ref MemoryMarshal.GetReference(dest); - for (nint i = 0; i < (uint)source.Length; i++) + for (nuint i = 0; i < (uint)source.Length; i++) { ref Rgba32 s = ref Unsafe.Add(ref sBase, i); Unsafe.Add(ref dBase, i).FromRgba32(s); @@ -85,7 +85,7 @@ public class PixelConversion_Rgba32_To_Bgra32 ref Rgba32 sBase = ref this.source[0]; ref Bgra32 dBase = ref this.dest[0]; - for (nint i = 0; i < (uint)this.Count; i += 2) + for (nuint i = 0; i < (uint)this.Count; i += 2) { ref Rgba32 s0 = ref Unsafe.Add(ref sBase, i); Rgba32 s1 = Unsafe.Add(ref s0, 1); @@ -102,7 +102,7 @@ public class PixelConversion_Rgba32_To_Bgra32 ref Rgba32 sBase = ref this.source[0]; ref Bgra32 dBase = ref this.dest[0]; - for (nint i = 0; i < (uint)this.Count; i += 4) + for (nuint i = 0; i < (uint)this.Count; i += 4) { ref Rgba32 s0 = ref Unsafe.Add(ref sBase, i); ref Rgba32 s1 = ref Unsafe.Add(ref s0, 1); @@ -127,7 +127,7 @@ public class PixelConversion_Rgba32_To_Bgra32 ref Rgba32 sBase = ref MemoryMarshal.GetReference(source); ref TPixel dBase = ref MemoryMarshal.GetReference(dest); - for (nint i = 0; i < (uint)source.Length; i += 4) + for (nuint i = 0; i < (uint)source.Length; i += 4) { ref Rgba32 s0 = ref Unsafe.Add(ref sBase, i); ref Rgba32 s1 = ref Unsafe.Add(ref s0, 1); @@ -157,7 +157,7 @@ public class PixelConversion_Rgba32_To_Bgra32 ref Rgba32 sBase = ref this.source[0]; ref Bgra32 dBase = ref this.dest[0]; - for (nint i = 0; i < (uint)this.Count / 4; i += 4) + for (nuint i = 0; i < (uint)this.Count / 4; i += 4) { ref Rgba32 s0 = ref Unsafe.Add(ref sBase, i); ref Rgba32 s1 = ref Unsafe.Add(ref s0, 1); @@ -196,7 +196,7 @@ public class PixelConversion_Rgba32_To_Bgra32 ref uint sBase = ref Unsafe.As(ref this.source[0]); ref uint dBase = ref Unsafe.As(ref this.dest[0]); - for (nint i = 0; i < (uint)this.Count; i++) + for (nuint i = 0; i < (uint)this.Count; i++) { uint s = Unsafe.Add(ref sBase, i); Unsafe.Add(ref dBase, i) = FromRgba32.ToBgra32(s); @@ -209,7 +209,7 @@ public class PixelConversion_Rgba32_To_Bgra32 ref Tuple4OfUInt32 sBase = ref Unsafe.As(ref this.source[0]); ref Tuple4OfUInt32 dBase = ref Unsafe.As(ref this.dest[0]); - for (nint i = 0; i < (uint)this.Count / 4; i++) + for (nuint i = 0; i < (uint)this.Count / 4; i++) { ref Tuple4OfUInt32 d = ref Unsafe.Add(ref dBase, i); d = Unsafe.Add(ref sBase, i); @@ -222,7 +222,7 @@ public class PixelConversion_Rgba32_To_Bgra32 { ref Tuple4OfUInt32 sBase = ref Unsafe.As(ref this.source[0]); - for (nint i = 0; i < (uint)this.Count / 4; i++) + for (nuint i = 0; i < (uint)this.Count / 4; i++) { Unsafe.Add(ref sBase, i).ConvertMe(); } @@ -234,7 +234,7 @@ public class PixelConversion_Rgba32_To_Bgra32 ref Octet sBase = ref Unsafe.As>(ref this.source[0]); ref Octet dBase = ref Unsafe.As>(ref this.dest[0]); - for (nint i = 0; i < (uint)this.Count / 8; i++) + for (nuint i = 0; i < (uint)this.Count / 8; i++) { BitopsSimdImpl(ref Unsafe.Add(ref sBase, i), ref Unsafe.Add(ref dBase, i)); } @@ -289,7 +289,7 @@ public class PixelConversion_Rgba32_To_Bgra32 ref uint sBase = ref Unsafe.As(ref this.source[0]); ref uint dBase = ref Unsafe.As(ref this.dest[0]); - for (nint i = 0; i < (uint)this.Count; i++) + for (nuint i = 0; i < (uint)this.Count; i++) { ref uint s0 = ref Unsafe.Add(ref sBase, i); uint s1 = Unsafe.Add(ref s0, 1); @@ -306,7 +306,7 @@ public class PixelConversion_Rgba32_To_Bgra32 ref ulong sBase = ref Unsafe.As(ref this.source[0]); ref ulong dBase = ref Unsafe.As(ref this.dest[0]); - for (nint i = 0; i < (uint)this.Count / 2; i++) + for (nuint i = 0; i < (uint)this.Count / 2; i++) { ulong s = Unsafe.Add(ref sBase, i); uint lo = (uint)s; @@ -326,7 +326,7 @@ public class PixelConversion_Rgba32_To_Bgra32 ref ulong sBase = ref Unsafe.As(ref this.source[0]); ref ulong dBase = ref Unsafe.As(ref this.dest[0]); - for (nint i = 0; i < (uint)this.Count / 2; i++) + for (nuint i = 0; i < (uint)this.Count / 2; i++) { ulong s = Unsafe.Add(ref sBase, i); uint lo = (uint)s; diff --git a/tests/ImageSharp.Benchmarks/General/Vectorization/UInt32ToSingle.cs b/tests/ImageSharp.Benchmarks/General/Vectorization/UInt32ToSingle.cs index 57c7b6faf7..010e1f52b3 100644 --- a/tests/ImageSharp.Benchmarks/General/Vectorization/UInt32ToSingle.cs +++ b/tests/ImageSharp.Benchmarks/General/Vectorization/UInt32ToSingle.cs @@ -25,14 +25,14 @@ public class UInt32ToSingle { ref Vector b = ref Unsafe.As>(ref this.data[0]); - nint n = Count / Vector.Count; + nuint n = (uint)(Count / Vector.Count); var bVec = new Vector(256.0f / 255.0f); var magicFloat = new Vector(32768.0f); var magicInt = new Vector(1191182336); // reinterpreted value of 32768.0f var mask = new Vector(255); - for (nint i = 0; i < n; i++) + for (nuint i = 0; i < n; i++) { ref Vector df = ref Unsafe.Add(ref b, i); @@ -50,14 +50,14 @@ public class UInt32ToSingle [Benchmark] public void StandardSimd() { - nint n = Count / Vector.Count; + nuint n = (uint)(Count / Vector.Count); ref Vector bf = ref Unsafe.As>(ref this.data[0]); ref Vector bu = ref Unsafe.As, Vector>(ref bf); var scale = new Vector(1f / 255f); - for (nint i = 0; i < n; i++) + for (nuint i = 0; i < n; i++) { Vector u = Unsafe.Add(ref bu, i); Vector v = Vector.ConvertToSingle(u); @@ -69,14 +69,14 @@ public class UInt32ToSingle [Benchmark] public void StandardSimdFromInt() { - nint n = Count / Vector.Count; + nuint n = (uint)(Count / Vector.Count); ref Vector bf = ref Unsafe.As>(ref this.data[0]); ref Vector bu = ref Unsafe.As, Vector>(ref bf); var scale = new Vector(1f / 255f); - for (nint i = 0; i < n; i++) + for (nuint i = 0; i < n; i++) { Vector u = Unsafe.Add(ref bu, i); Vector v = Vector.ConvertToSingle(u); @@ -88,12 +88,12 @@ public class UInt32ToSingle [Benchmark] public void StandardSimdFromInt_RefCast() { - nint n = Count / Vector.Count; + nuint n = (uint)(Count / Vector.Count); ref Vector bf = ref Unsafe.As>(ref this.data[0]); var scale = new Vector(1f / 255f); - for (nint i = 0; i < n; i++) + for (nuint i = 0; i < n; i++) { ref Vector fRef = ref Unsafe.Add(ref bf, i); diff --git a/tests/ImageSharp.Benchmarks/General/Vectorization/VectorFetching.cs b/tests/ImageSharp.Benchmarks/General/Vectorization/VectorFetching.cs index 7da2626dcc..32027729b2 100644 --- a/tests/ImageSharp.Benchmarks/General/Vectorization/VectorFetching.cs +++ b/tests/ImageSharp.Benchmarks/General/Vectorization/VectorFetching.cs @@ -63,9 +63,9 @@ public class VectorFetching var v = new Vector(this.testValue); ref Vector start = ref Unsafe.As>(ref this.data[0]); - nint n = (nint)(uint)this.InputSize / Vector.Count; + nuint n = (uint)(this.InputSize / Vector.Count); - for (nint i = 0; i < n; i++) + for (nuint i = 0; i < n; i++) { ref Vector p = ref Unsafe.Add(ref start, i); @@ -82,9 +82,9 @@ public class VectorFetching var v = new Vector(this.testValue); ref Vector start = ref Unsafe.As>(ref this.data[0]); - nint n = (nint)(uint)this.InputSize / Vector.Count; + nuint n = (uint)(this.InputSize / Vector.Count); - for (nint i = 0; i < n; i++) + for (nuint i = 0; i < n; i++) { ref Vector a = ref Unsafe.Add(ref start, i); a *= v; @@ -100,9 +100,9 @@ public class VectorFetching ref Vector start = ref Unsafe.As>(ref MemoryMarshal.GetReference(span)); - nint n = (nint)(uint)this.InputSize / Vector.Count; + nuint n = (uint)(this.InputSize / Vector.Count); - for (nint i = 0; i < n; i++) + for (nuint i = 0; i < n; i++) { ref Vector a = ref Unsafe.Add(ref start, i); a *= v; diff --git a/tests/ImageSharp.Benchmarks/General/Vectorization/WidenBytesToUInt32.cs b/tests/ImageSharp.Benchmarks/General/Vectorization/WidenBytesToUInt32.cs index 586618fcb1..6ad7827eb1 100644 --- a/tests/ImageSharp.Benchmarks/General/Vectorization/WidenBytesToUInt32.cs +++ b/tests/ImageSharp.Benchmarks/General/Vectorization/WidenBytesToUInt32.cs @@ -33,7 +33,7 @@ public class WidenBytesToUInt32 ref Octet sBase = ref Unsafe.As>(ref this.source[0]); ref Octet dBase = ref Unsafe.As>(ref this.dest[0]); - for (nint i = 0; i < N; i++) + for (nuint i = 0; i < N; i++) { Unsafe.Add(ref dBase, i).LoadFrom(ref Unsafe.Add(ref sBase, i)); } @@ -42,12 +42,12 @@ public class WidenBytesToUInt32 [Benchmark] public void Simd() { - nint n = Count / Vector.Count; + nuint n = (uint)(Count / Vector.Count); ref Vector sBase = ref Unsafe.As>(ref this.source[0]); ref Vector dBase = ref Unsafe.As>(ref this.dest[0]); - for (nint i = 0; i < n; i++) + for (nuint i = 0; i < n; i++) { Vector b = Unsafe.Add(ref sBase, i); diff --git a/tests/ImageSharp.Benchmarks/PixelBlenders/PorterDuffBulkVsSingleVector.cs b/tests/ImageSharp.Benchmarks/PixelBlenders/PorterDuffBulkVsSingleVector.cs index 33f5720aab..ecf8b125f7 100644 --- a/tests/ImageSharp.Benchmarks/PixelBlenders/PorterDuffBulkVsSingleVector.cs +++ b/tests/ImageSharp.Benchmarks/PixelBlenders/PorterDuffBulkVsSingleVector.cs @@ -58,7 +58,7 @@ public class PorterDuffBulkVsSingleVector Vector256 result = default; Vector256 opacity = Vector256.Create(.5F); int count = this.backdrop.Length / 2; - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { result = PorterDuffFunctions.NormalSrcOver(Unsafe.Add(ref backdrop, i), Unsafe.Add(ref source, i), opacity); } diff --git a/tests/ImageSharp.Tests/Common/SimdUtilsTests.Shuffle.cs b/tests/ImageSharp.Tests/Common/SimdUtilsTests.Shuffle.cs index 960b0613e6..ba37ee1661 100644 --- a/tests/ImageSharp.Tests/Common/SimdUtilsTests.Shuffle.cs +++ b/tests/ImageSharp.Tests/Common/SimdUtilsTests.Shuffle.cs @@ -493,10 +493,10 @@ public partial class SimdUtilsTests SimdUtils.Shuffle.InverseMMShuffle( control, - out int p3, - out int p2, - out int p1, - out int p0); + out uint p3, + out uint p2, + out uint p1, + out uint p0); for (int i = 0; i < expected.Length; i += 4) { @@ -524,10 +524,10 @@ public partial class SimdUtilsTests SimdUtils.Shuffle.InverseMMShuffle( control, - out int p3, - out int p2, - out int p1, - out int p0); + out uint p3, + out uint p2, + out uint p1, + out uint p0); for (int i = 0; i < expected.Length; i += 4) { @@ -555,10 +555,10 @@ public partial class SimdUtilsTests SimdUtils.Shuffle.InverseMMShuffle( control, - out int _, - out int p2, - out int p1, - out int p0); + out uint _, + out uint p2, + out uint p1, + out uint p0); for (int i = 0; i < expected.Length; i += 3) { @@ -586,10 +586,10 @@ public partial class SimdUtilsTests SimdUtils.Shuffle.InverseMMShuffle( control, - out int p3, - out int p2, - out int p1, - out int p0); + out uint p3, + out uint p2, + out uint p1, + out uint p0); for (int i = 0, j = 0; i < expected.Length; i += 4, j += 3) { @@ -607,10 +607,10 @@ public partial class SimdUtilsTests temp[2] = source[j + 2]; temp[3] = byte.MaxValue; - expected[i] = temp[p0]; - expected[i + 1] = temp[p1]; - expected[i + 2] = temp[p2]; - expected[i + 3] = temp[p3]; + expected[i] = temp[(int)p0]; + expected[i + 1] = temp[(int)p1]; + expected[i + 2] = temp[(int)p2]; + expected[i + 3] = temp[(int)p3]; } convert(source, result); @@ -637,10 +637,10 @@ public partial class SimdUtilsTests SimdUtils.Shuffle.InverseMMShuffle( control, - out int _, - out int p2, - out int p1, - out int p0); + out uint _, + out uint p2, + out uint p1, + out uint p0); for (int i = 0, j = 0; i < expected.Length; i += 3, j += 4) { diff --git a/tests/ImageSharp.Tests/Formats/Png/PngEncoderFilterTests.cs b/tests/ImageSharp.Tests/Formats/Png/PngEncoderFilterTests.cs index e50e40bd22..796d35bf72 100644 --- a/tests/ImageSharp.Tests/Formats/Png/PngEncoderFilterTests.cs +++ b/tests/ImageSharp.Tests/Formats/Png/PngEncoderFilterTests.cs @@ -287,7 +287,7 @@ public class PngEncoderFilterTests : MeasureFixture break; case PngFilterMethod.Average: - AverageFilter.Encode(this.previousScanline, this.scanline, this.resultBuffer, this.bpp, out sum); + AverageFilter.Encode(this.previousScanline, this.scanline, this.resultBuffer, (uint)this.bpp, out sum); break; case PngFilterMethod.Paeth: diff --git a/tests/ImageSharp.Tests/Formats/Png/ReferenceImplementations.cs b/tests/ImageSharp.Tests/Formats/Png/ReferenceImplementations.cs index 7610023afc..d57a775876 100644 --- a/tests/ImageSharp.Tests/Formats/Png/ReferenceImplementations.cs +++ b/tests/ImageSharp.Tests/Formats/Png/ReferenceImplementations.cs @@ -34,8 +34,8 @@ internal static partial class ReferenceImplementations // Paeth(x) = Raw(x) - PaethPredictor(Raw(x-bpp), Prior(x), Prior(x - bpp)) resultBaseRef = 4; - nint x = 0; - for (; x < (nint)(uint)bytesPerPixel; /* Note: ++x happens in the body to avoid one add operation */) + int x = 0; + for (; x < bytesPerPixel; /* Note: ++x happens in the body to avoid one add operation */) { byte scan = Unsafe.Add(ref scanBaseRef, x); byte above = Unsafe.Add(ref prevBaseRef, x); @@ -45,7 +45,7 @@ internal static partial class ReferenceImplementations sum += Numerics.Abs(unchecked((sbyte)res)); } - 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 (int xLeft = x - bytesPerPixel; x < scanline.Length; ++xLeft /* Note: ++x happens in the body to avoid one add operation */) { byte scan = Unsafe.Add(ref scanBaseRef, x); byte left = Unsafe.Add(ref scanBaseRef, xLeft); @@ -77,8 +77,8 @@ internal static partial class ReferenceImplementations // Sub(x) = Raw(x) - Raw(x-bpp) resultBaseRef = 1; - nint x = 0; - for (; x < (nint)(uint)bytesPerPixel; /* Note: ++x happens in the body to avoid one add operation */) + int x = 0; + for (; x < bytesPerPixel; /* Note: ++x happens in the body to avoid one add operation */) { byte scan = Unsafe.Add(ref scanBaseRef, x); ++x; @@ -87,7 +87,7 @@ internal static partial class ReferenceImplementations sum += Numerics.Abs(unchecked((sbyte)res)); } - 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 (int xLeft = x - bytesPerPixel; x < scanline.Length; ++xLeft /* Note: ++x happens in the body to avoid one add operation */) { byte scan = Unsafe.Add(ref scanBaseRef, x); byte prev = Unsafe.Add(ref scanBaseRef, xLeft); @@ -119,9 +119,9 @@ internal static partial class ReferenceImplementations // Up(x) = Raw(x) - Prior(x) resultBaseRef = 2; - nint x = 0; + int x = 0; - for (; x < (nint)(uint)scanline.Length; /* Note: ++x happens in the body to avoid one add operation */) + for (; x < scanline.Length; /* Note: ++x happens in the body to avoid one add operation */) { byte scan = Unsafe.Add(ref scanBaseRef, x); byte above = Unsafe.Add(ref prevBaseRef, x); @@ -154,8 +154,8 @@ internal static partial class ReferenceImplementations // Average(x) = Raw(x) - floor((Raw(x-bpp)+Prior(x))/2) resultBaseRef = 3; - nint x = 0; - for (; x < (nint)(uint)bytesPerPixel; /* Note: ++x happens in the body to avoid one add operation */) + int x = 0; + for (; x < bytesPerPixel; /* Note: ++x happens in the body to avoid one add operation */) { byte scan = Unsafe.Add(ref scanBaseRef, x); byte above = Unsafe.Add(ref prevBaseRef, x); @@ -165,7 +165,7 @@ internal static partial class ReferenceImplementations sum += Numerics.Abs(unchecked((sbyte)res)); } - 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 (int xLeft = x - bytesPerPixel; x < scanline.Length; ++xLeft /* Note: ++x happens in the body to avoid one add operation */) { byte scan = Unsafe.Add(ref scanBaseRef, x); byte left = Unsafe.Add(ref scanBaseRef, xLeft); diff --git a/tests/ImageSharp.Tests/PixelFormats/PixelConverterTests.ReferenceImplementations.cs b/tests/ImageSharp.Tests/PixelFormats/PixelConverterTests.ReferenceImplementations.cs index 521270e3be..006cb9eb61 100644 --- a/tests/ImageSharp.Tests/PixelFormats/PixelConverterTests.ReferenceImplementations.cs +++ b/tests/ImageSharp.Tests/PixelFormats/PixelConverterTests.ReferenceImplementations.cs @@ -100,7 +100,7 @@ public abstract partial class PixelConverterTests if (typeof(TDestinationPixel) == typeof(L16)) { ref L16 l16Ref = ref MemoryMarshal.GetReference(MemoryMarshal.Cast(destinationPixels)); - for (nint i = 0; i < (uint)count; i++) + for (int i = 0; i < count; i++) { ref TSourcePixel sp = ref Unsafe.Add(ref sourceRef, i); ref L16 dp = ref Unsafe.Add(ref l16Ref, i); @@ -113,7 +113,7 @@ public abstract partial class PixelConverterTests if (typeof(TDestinationPixel) == typeof(L8)) { ref L8 l8Ref = ref MemoryMarshal.GetReference(MemoryMarshal.Cast(destinationPixels)); - for (nint i = 0; i < (uint)count; i++) + for (int i = 0; i < count; i++) { ref TSourcePixel sp = ref Unsafe.Add(ref sourceRef, i); ref L8 dp = ref Unsafe.Add(ref l8Ref, i); @@ -125,7 +125,7 @@ public abstract partial class PixelConverterTests // Normal conversion ref TDestinationPixel destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)count; i++) + for (int i = 0; i < count; i++) { ref TSourcePixel sp = ref Unsafe.Add(ref sourceRef, i); ref TDestinationPixel dp = ref Unsafe.Add(ref destRef, i); diff --git a/tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.cs b/tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.cs index 73305183f6..a9b3ee9a42 100644 --- a/tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.cs @@ -1184,7 +1184,7 @@ public abstract class PixelOperationsTests : MeasureFixture get { ref byte self = ref Unsafe.As(ref this); - return Unsafe.Add(ref self, (uint)idx); + return Unsafe.Add(ref self, idx); } } } diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeKernelMapTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeKernelMapTests.cs index 3cea431fbb..c6da46ee2f 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeKernelMapTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeKernelMapTests.cs @@ -128,7 +128,7 @@ public partial class ResizeKernelMapTests for (int i = 0; i < kernelMap.DestinationLength; i++) { - ResizeKernel kernel = kernelMap.GetKernel(i); + ResizeKernel kernel = kernelMap.GetKernel((uint)i); ReferenceKernel referenceKernel = referenceMap.GetKernel(i); @@ -153,7 +153,7 @@ public partial class ResizeKernelMapTests } private static string PrintKernelMap(ResizeKernelMap kernelMap) - => PrintKernelMap(kernelMap, km => km.DestinationLength, (km, i) => km.GetKernel(i)); + => PrintKernelMap(kernelMap, km => km.DestinationLength, (km, i) => km.GetKernel((uint)i)); private static string PrintKernelMap(ReferenceKernelMap kernelMap) => PrintKernelMap(kernelMap, km => km.DestinationSize, (km, i) => km.GetKernel(i));