diff --git a/src/ImageSharp/Common/Helpers/ImageMaths.cs b/src/ImageSharp/Common/Helpers/ImageMaths.cs index 8a2ece4be..b4e5c094c 100644 --- a/src/ImageSharp/Common/Helpers/ImageMaths.cs +++ b/src/ImageSharp/Common/Helpers/ImageMaths.cs @@ -153,8 +153,8 @@ namespace SixLabors.ImageSharp { int width = bitmap.Width; int height = bitmap.Height; - var topLeft = default(Point); - var bottomRight = default(Point); + Point topLeft = default; + Point bottomRight = default; Func, int, int, float, bool> delegateFunc; diff --git a/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs b/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs index 2ddf4ace4..20175613e 100644 --- a/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs +++ b/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs @@ -217,7 +217,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp private void ReadRle8(Buffer2D pixels, byte[] colors, int width, int height, bool inverted) where TPixel : struct, IPixel { - var color = default(TPixel); + TPixel color = default; var rgba = new Rgba32(0, 0, 0, 255); using (Buffer2D buffer = this.memoryAllocator.AllocateClean2D(width, height)) @@ -397,7 +397,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp { int padding = CalculatePadding(width, 2); int stride = (width * 2) + padding; - var color = default(TPixel); + TPixel color = default; var rgba = new Rgba32(0, 0, 0, 255); using (IManagedByteBuffer buffer = this.memoryAllocator.AllocateManagedByteBuffer(stride)) diff --git a/src/ImageSharp/Formats/Jpeg/Components/Block8x8.cs b/src/ImageSharp/Formats/Jpeg/Components/Block8x8.cs index cb73ee947..5601a9436 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Block8x8.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Block8x8.cs @@ -184,7 +184,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components /// public Block8x8F AsFloatBlock() { - var result = default(Block8x8F); + Block8x8F result = default; result.LoadFrom(ref this); return result; } diff --git a/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.cs b/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.cs index 38974cc76..59fc234c4 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.cs @@ -134,14 +134,14 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components public static Block8x8F Load(Span data) { - var result = default(Block8x8F); + Block8x8F result = default; result.LoadFrom(data); return result; } public static Block8x8F Load(Span data) { - var result = default(Block8x8F); + Block8x8F result = default; result.LoadFrom(data); return result; } @@ -461,7 +461,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components public Block8x8 RoundAsInt16Block() { - var result = default(Block8x8); + Block8x8 result = default; this.RoundInto(ref result); return result; } diff --git a/src/ImageSharp/Formats/Jpeg/Components/Decoder/ColorConverters/JpegColorConverter.FromYCbCrSimdAvx2.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/ColorConverters/JpegColorConverter.FromYCbCrSimdAvx2.cs index c43713bf4..25342f4d6 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Decoder/ColorConverters/JpegColorConverter.FromYCbCrSimdAvx2.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Decoder/ColorConverters/JpegColorConverter.FromYCbCrSimdAvx2.cs @@ -62,9 +62,9 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder.ColorConverters // Walking 8 elements at one step: int n = result.Length / 8; - var rr = default(Vector4Pair); - var gg = default(Vector4Pair); - var bb = default(Vector4Pair); + Vector4Pair rr = default; + Vector4Pair gg = default; + Vector4Pair bb = default; ref Vector rrRefAsVector = ref Unsafe.As>(ref rr); ref Vector ggRefAsVector = ref Unsafe.As>(ref gg); diff --git a/src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/GolangJpegScanDecoder.ComputationData.cs b/src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/GolangJpegScanDecoder.ComputationData.cs index f1dd2526a..f3c8aa91b 100644 --- a/src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/GolangJpegScanDecoder.ComputationData.cs +++ b/src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/GolangJpegScanDecoder.ComputationData.cs @@ -44,7 +44,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder /// The public static ComputationData Create() { - var data = default(ComputationData); + ComputationData data = default; data.Unzig = ZigZag.CreateUnzigTable(); return data; } diff --git a/src/ImageSharp/Formats/Jpeg/GolangPort/GolangJpegDecoderCore.cs b/src/ImageSharp/Formats/Jpeg/GolangPort/GolangJpegDecoderCore.cs index 61ab47bdf..46cdcddb4 100644 --- a/src/ImageSharp/Formats/Jpeg/GolangPort/GolangJpegDecoderCore.cs +++ b/src/ImageSharp/Formats/Jpeg/GolangPort/GolangJpegDecoderCore.cs @@ -773,7 +773,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort /// private void ProcessStartOfScanMarker(int remaining) { - var scan = default(GolangJpegScanDecoder); + GolangJpegScanDecoder scan = default; GolangJpegScanDecoder.InitStreamReading(&scan, this, remaining); this.InputProcessor.Bits = default; scan.DecodeBlocks(this); diff --git a/src/ImageSharp/Formats/Jpeg/PdfJsPort/PdfJsJpegDecoderCore.cs b/src/ImageSharp/Formats/Jpeg/PdfJsPort/PdfJsJpegDecoderCore.cs index 55435e3be..bd1d84ecc 100644 --- a/src/ImageSharp/Formats/Jpeg/PdfJsPort/PdfJsJpegDecoderCore.cs +++ b/src/ImageSharp/Formats/Jpeg/PdfJsPort/PdfJsJpegDecoderCore.cs @@ -786,7 +786,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.PdfJsPort int spectralStart = this.temp[0]; int spectralEnd = this.temp[1]; int successiveApproximation = this.temp[2]; - var scanDecoder = default(PdfJsScanDecoder); + PdfJsScanDecoder scanDecoder = default; scanDecoder.DecodeScan( this.Frame, diff --git a/src/ImageSharp/Formats/Png/PngDecoderCore.cs b/src/ImageSharp/Formats/Png/PngDecoderCore.cs index 67e32f212..363d51ef9 100644 --- a/src/ImageSharp/Formats/Png/PngDecoderCore.cs +++ b/src/ImageSharp/Formats/Png/PngDecoderCore.cs @@ -670,7 +670,7 @@ namespace SixLabors.ImageSharp.Formats.Png private void ProcessDefilteredScanline(ReadOnlySpan defilteredScanline, ImageFrame pixels) where TPixel : struct, IPixel { - var color = default(TPixel); + TPixel color = default; Span rowSpan = pixels.GetPixelRowSpan(this.currentRow); // Trim the first marker byte from the buffer @@ -753,7 +753,7 @@ namespace SixLabors.ImageSharp.Formats.Png for (int x = 0; x < this.header.Width; x++) { ref Rgb24 rgb24 = ref rgb24Span[x]; - var rgba32 = default(Rgba32); + Rgba32 rgba32 = default; rgba32.Rgb = rgb24; rgba32.A = (byte)(rgb24.Equals(this.rgb24Trans) ? 0 : 255); @@ -768,7 +768,7 @@ namespace SixLabors.ImageSharp.Formats.Png for (int x = 0; x < this.header.Width; x++) { ref readonly Rgb24 rgb24 = ref rgb24Span[x]; - var rgba32 = default(Rgba32); + Rgba32 rgba32 = default; rgba32.Rgb = rgb24; rgba32.A = (byte)(rgb24.Equals(this.rgb24Trans) ? 0 : 255); @@ -854,9 +854,8 @@ namespace SixLabors.ImageSharp.Formats.Png { ReadOnlySpan newScanline = ToArrayByBitsLength(defilteredScanline, this.bytesPerScanline, this.header.BitDepth); ReadOnlySpan pal = MemoryMarshal.Cast(this.palette); - var color = default(TPixel); - - var rgba = default(Rgba32); + TPixel color = default; + Rgba32 rgba = default; if (this.paletteAlpha != null && this.paletteAlpha.Length > 0) { @@ -900,7 +899,7 @@ namespace SixLabors.ImageSharp.Formats.Png private void ProcessInterlacedDefilteredScanline(ReadOnlySpan defilteredScanline, Span rowSpan, int pixelOffset = 0, int increment = 1) where TPixel : struct, IPixel { - var color = default(TPixel); + TPixel color = default; // Trim the first marker byte from the buffer ReadOnlySpan scanlineBuffer = defilteredScanline.Slice(1, defilteredScanline.Length - 1); @@ -943,7 +942,7 @@ namespace SixLabors.ImageSharp.Formats.Png case PngColorType.Palette: ReadOnlySpan newScanline = ToArrayByBitsLength(scanlineBuffer, this.bytesPerScanline, this.header.BitDepth); - var rgba = default(Rgba32); + Rgba32 rgba = default; Span pal = MemoryMarshal.Cast(this.palette); if (this.paletteAlpha != null && this.paletteAlpha.Length > 0) diff --git a/src/ImageSharp/PixelFormats/Bgr24.cs b/src/ImageSharp/PixelFormats/Bgr24.cs index b099bab1c..ff913923e 100644 --- a/src/ImageSharp/PixelFormats/Bgr24.cs +++ b/src/ImageSharp/PixelFormats/Bgr24.cs @@ -121,7 +121,7 @@ namespace SixLabors.ImageSharp.PixelFormats [MethodImpl(MethodImplOptions.AggressiveInlining)] public void PackFromVector4(Vector4 vector) { - var rgba = default(Rgba32); + Rgba32 rgba = default; rgba.PackFromVector4(vector); this.PackFromRgba32(rgba); } diff --git a/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.cs b/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.cs index e948c05ca..66cc427de 100644 --- a/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.cs +++ b/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.cs @@ -261,7 +261,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel Normal(TPixel backdrop, TPixel source, float amount) where TPixel : struct, IPixel { - TPixel dest = default(TPixel); + TPixel dest = default; dest.PackFromVector4(Normal(backdrop.ToVector4(), source.ToVector4(), amount)); return dest; } @@ -270,7 +270,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel Multiply(TPixel backdrop, TPixel source, float amount) where TPixel : struct, IPixel { - TPixel dest = default(TPixel); + TPixel dest = default; dest.PackFromVector4(Multiply(backdrop.ToVector4(), source.ToVector4(), amount)); return dest; } @@ -279,7 +279,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel Add(TPixel backdrop, TPixel source, float amount) where TPixel : struct, IPixel { - TPixel dest = default(TPixel); + TPixel dest = default; dest.PackFromVector4(Add(backdrop.ToVector4(), source.ToVector4(), amount)); return dest; } @@ -288,7 +288,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel Subtract(TPixel backdrop, TPixel source, float amount) where TPixel : struct, IPixel { - TPixel dest = default(TPixel); + TPixel dest = default; dest.PackFromVector4(Subtract(backdrop.ToVector4(), source.ToVector4(), amount)); return dest; } @@ -297,7 +297,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel Screen(TPixel backdrop, TPixel source, float amount) where TPixel : struct, IPixel { - TPixel dest = default(TPixel); + TPixel dest = default; dest.PackFromVector4(Screen(backdrop.ToVector4(), source.ToVector4(), amount)); return dest; } @@ -306,7 +306,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel Darken(TPixel backdrop, TPixel source, float amount) where TPixel : struct, IPixel { - TPixel dest = default(TPixel); + TPixel dest = default; dest.PackFromVector4(Darken(backdrop.ToVector4(), source.ToVector4(), amount)); return dest; } @@ -315,7 +315,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel Lighten(TPixel backdrop, TPixel source, float amount) where TPixel : struct, IPixel { - TPixel dest = default(TPixel); + TPixel dest = default; dest.PackFromVector4(Lighten(backdrop.ToVector4(), source.ToVector4(), amount)); return dest; } @@ -324,7 +324,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel Overlay(TPixel backdrop, TPixel source, float amount) where TPixel : struct, IPixel { - TPixel dest = default(TPixel); + TPixel dest = default; dest.PackFromVector4(Overlay(backdrop.ToVector4(), source.ToVector4(), amount)); return dest; } @@ -333,7 +333,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel HardLight(TPixel backdrop, TPixel source, float amount) where TPixel : struct, IPixel { - TPixel dest = default(TPixel); + TPixel dest = default; dest.PackFromVector4(HardLight(backdrop.ToVector4(), source.ToVector4(), amount)); return dest; } @@ -342,7 +342,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel Src(TPixel backdrop, TPixel source, float amount) where TPixel : struct, IPixel { - TPixel dest = default(TPixel); + TPixel dest = default; dest.PackFromVector4(Src(backdrop.ToVector4(), source.ToVector4(), amount)); return dest; } @@ -351,7 +351,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel Atop(TPixel backdrop, TPixel source, float amount) where TPixel : struct, IPixel { - TPixel dest = default(TPixel); + TPixel dest = default; dest.PackFromVector4(Atop(backdrop.ToVector4(), source.ToVector4(), amount)); return dest; } @@ -360,7 +360,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel Over(TPixel backdrop, TPixel source, float amount) where TPixel : struct, IPixel { - TPixel dest = default(TPixel); + TPixel dest = default; dest.PackFromVector4(Over(backdrop.ToVector4(), source.ToVector4(), amount)); return dest; } @@ -369,7 +369,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel In(TPixel backdrop, TPixel source, float amount) where TPixel : struct, IPixel { - TPixel dest = default(TPixel); + TPixel dest = default; dest.PackFromVector4(In(backdrop.ToVector4(), source.ToVector4(), amount)); return dest; } @@ -378,7 +378,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel Out(TPixel backdrop, TPixel source, float amount) where TPixel : struct, IPixel { - TPixel dest = default(TPixel); + TPixel dest = default; dest.PackFromVector4(Out(backdrop.ToVector4(), source.ToVector4(), amount)); return dest; } @@ -387,7 +387,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel Dest(TPixel backdrop, TPixel source, float amount) where TPixel : struct, IPixel { - TPixel dest = default(TPixel); + TPixel dest = default; dest.PackFromVector4(Dest(backdrop.ToVector4(), source.ToVector4(), amount)); return dest; } @@ -396,7 +396,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel DestAtop(TPixel backdrop, TPixel source, float amount) where TPixel : struct, IPixel { - TPixel dest = default(TPixel); + TPixel dest = default; dest.PackFromVector4(DestAtop(backdrop.ToVector4(), source.ToVector4(), amount)); return dest; } @@ -405,7 +405,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel DestOver(TPixel backdrop, TPixel source, float amount) where TPixel : struct, IPixel { - TPixel dest = default(TPixel); + TPixel dest = default; dest.PackFromVector4(DestOver(backdrop.ToVector4(), source.ToVector4(), amount)); return dest; } @@ -414,7 +414,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel DestIn(TPixel backdrop, TPixel source, float amount) where TPixel : struct, IPixel { - TPixel dest = default(TPixel); + TPixel dest = default; dest.PackFromVector4(DestIn(backdrop.ToVector4(), source.ToVector4(), amount)); return dest; } @@ -423,7 +423,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel DestOut(TPixel backdrop, TPixel source, float amount) where TPixel : struct, IPixel { - TPixel dest = default(TPixel); + TPixel dest = default; dest.PackFromVector4(DestOut(backdrop.ToVector4(), source.ToVector4(), amount)); return dest; } @@ -432,7 +432,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel Clear(TPixel backdrop, TPixel source, float amount) where TPixel : struct, IPixel { - TPixel dest = default(TPixel); + TPixel dest = default; dest.PackFromVector4(Clear(backdrop.ToVector4(), source.ToVector4(), amount)); return dest; } @@ -441,7 +441,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel Xor(TPixel backdrop, TPixel source, float amount) where TPixel : struct, IPixel { - TPixel dest = default(TPixel); + TPixel dest = default; dest.PackFromVector4(Xor(backdrop.ToVector4(), source.ToVector4(), amount)); return dest; } diff --git a/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.tt b/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.tt index 940b585aa..4cbc06861 100644 --- a/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.tt +++ b/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.tt @@ -30,7 +30,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel <#=blender#>(TPixel backdrop, TPixel source, float amount) where TPixel : struct, IPixel { - TPixel dest = default(TPixel); + TPixel dest = default; dest.PackFromVector4(<#=blender#>(backdrop.ToVector4(), source.ToVector4(), amount)); return dest; } diff --git a/src/ImageSharp/PixelFormats/Rgb24.cs b/src/ImageSharp/PixelFormats/Rgb24.cs index c540a7d12..faee3bbbd 100644 --- a/src/ImageSharp/PixelFormats/Rgb24.cs +++ b/src/ImageSharp/PixelFormats/Rgb24.cs @@ -122,7 +122,7 @@ namespace SixLabors.ImageSharp.PixelFormats [MethodImpl(MethodImplOptions.AggressiveInlining)] public void PackFromVector4(Vector4 vector) { - var rgba = default(Rgba32); + Rgba32 rgba = default; rgba.PackFromVector4(vector); this.PackFromRgba32(rgba); } diff --git a/src/ImageSharp/Processing/Binarization/Processors/BinaryErrorDiffusionProcessor.cs b/src/ImageSharp/Processing/Binarization/Processors/BinaryErrorDiffusionProcessor.cs index 6588bbe5b..64763b657 100644 --- a/src/ImageSharp/Processing/Binarization/Processors/BinaryErrorDiffusionProcessor.cs +++ b/src/ImageSharp/Processing/Binarization/Processors/BinaryErrorDiffusionProcessor.cs @@ -78,7 +78,7 @@ namespace SixLabors.ImageSharp.Processing.Binarization.Processors protected override void OnFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) { float threshold = this.Threshold * 255F; - var rgba = default(Rgba32); + Rgba32 rgba = default; bool isAlphaOnly = typeof(TPixel) == typeof(Alpha8); var interest = Rectangle.Intersect(sourceRectangle, source.Bounds()); diff --git a/src/ImageSharp/Processing/Binarization/Processors/BinaryOrderedDitherProcessor.cs b/src/ImageSharp/Processing/Binarization/Processors/BinaryOrderedDitherProcessor.cs index bd4b3660a..3fe56ff44 100644 --- a/src/ImageSharp/Processing/Binarization/Processors/BinaryOrderedDitherProcessor.cs +++ b/src/ImageSharp/Processing/Binarization/Processors/BinaryOrderedDitherProcessor.cs @@ -59,7 +59,7 @@ namespace SixLabors.ImageSharp.Processing.Binarization.Processors /// protected override void OnFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) { - var rgba = default(Rgba32); + Rgba32 rgba = default; bool isAlphaOnly = typeof(TPixel) == typeof(Alpha8); var interest = Rectangle.Intersect(sourceRectangle, source.Bounds()); diff --git a/src/ImageSharp/Processing/Binarization/Processors/BinaryThresholdProcessor.cs b/src/ImageSharp/Processing/Binarization/Processors/BinaryThresholdProcessor.cs index 455c6ad8c..dc1297d6f 100644 --- a/src/ImageSharp/Processing/Binarization/Processors/BinaryThresholdProcessor.cs +++ b/src/ImageSharp/Processing/Binarization/Processors/BinaryThresholdProcessor.cs @@ -77,7 +77,7 @@ namespace SixLabors.ImageSharp.Processing.Binarization.Processors y => { Span row = source.GetPixelRowSpan(y); - var rgba = default(Rgba32); + Rgba32 rgba = default; for (int x = startX; x < endX; x++) { diff --git a/src/ImageSharp/Processing/Convolution/Processors/Convolution2PassProcessor.cs b/src/ImageSharp/Processing/Convolution/Processors/Convolution2PassProcessor.cs index a080beb88..4e14882ff 100644 --- a/src/ImageSharp/Processing/Convolution/Processors/Convolution2PassProcessor.cs +++ b/src/ImageSharp/Processing/Convolution/Processors/Convolution2PassProcessor.cs @@ -92,7 +92,7 @@ namespace SixLabors.ImageSharp.Processing.Convolution.Processors for (int x = startX; x < endX; x++) { - var destination = default(Vector4); + Vector4 destination = default; // Apply each matrix multiplier to the color components for each pixel. for (int fy = 0; fy < kernelHeight; fy++) diff --git a/src/ImageSharp/Processing/Dithering/Processors/ErrorDiffusionPaletteProcessor.cs b/src/ImageSharp/Processing/Dithering/Processors/ErrorDiffusionPaletteProcessor.cs index c90e91a6b..0f9e2d397 100644 --- a/src/ImageSharp/Processing/Dithering/Processors/ErrorDiffusionPaletteProcessor.cs +++ b/src/ImageSharp/Processing/Dithering/Processors/ErrorDiffusionPaletteProcessor.cs @@ -66,7 +66,7 @@ namespace SixLabors.ImageSharp.Processing.Dithering.Processors protected override void OnFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) { float threshold = this.Threshold * 255F; - var rgba = default(Rgba32); + Rgba32 rgba = default; bool isAlphaOnly = typeof(TPixel) == typeof(Alpha8); var interest = Rectangle.Intersect(sourceRectangle, source.Bounds()); diff --git a/src/ImageSharp/Processing/Dithering/Processors/OrderedDitherPaletteProcessor.cs b/src/ImageSharp/Processing/Dithering/Processors/OrderedDitherPaletteProcessor.cs index ce9b7fb3e..a59826e23 100644 --- a/src/ImageSharp/Processing/Dithering/Processors/OrderedDitherPaletteProcessor.cs +++ b/src/ImageSharp/Processing/Dithering/Processors/OrderedDitherPaletteProcessor.cs @@ -47,7 +47,7 @@ namespace SixLabors.ImageSharp.Processing.Dithering.Processors /// protected override void OnFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) { - var rgba = default(Rgba32); + Rgba32 rgba = default; bool isAlphaOnly = typeof(TPixel) == typeof(Alpha8); var interest = Rectangle.Intersect(sourceRectangle, source.Bounds()); diff --git a/src/ImageSharp/Processing/Dithering/Processors/PaletteDitherProcessorBase.cs b/src/ImageSharp/Processing/Dithering/Processors/PaletteDitherProcessorBase.cs index 89cc7cfb6..683ef7044 100644 --- a/src/ImageSharp/Processing/Dithering/Processors/PaletteDitherProcessorBase.cs +++ b/src/ImageSharp/Processing/Dithering/Processors/PaletteDitherProcessorBase.cs @@ -46,8 +46,8 @@ namespace SixLabors.ImageSharp.Processing.Dithering.Processors float secondLeastDistance = int.MaxValue; var vector = pixel.ToVector4(); - var closest = default(TPixel); - var secondClosest = default(TPixel); + TPixel closest = default; + TPixel secondClosest = default; for (int index = 0; index < colorPalette.Length; index++) { TPixel temp = colorPalette[index]; diff --git a/src/ImageSharp/Processing/Quantization/FrameQuantizers/OctreeFrameQuantizer{TPixel}.cs b/src/ImageSharp/Processing/Quantization/FrameQuantizers/OctreeFrameQuantizer{TPixel}.cs index 431064f22..e32022254 100644 --- a/src/ImageSharp/Processing/Quantization/FrameQuantizers/OctreeFrameQuantizer{TPixel}.cs +++ b/src/ImageSharp/Processing/Quantization/FrameQuantizers/OctreeFrameQuantizer{TPixel}.cs @@ -68,7 +68,7 @@ namespace SixLabors.ImageSharp.Processing.Quantization.FrameQuantizers ref TPixel scanBaseRef = ref MemoryMarshal.GetReference(row); // And loop through each column - var rgba = default(Rgba32); + Rgba32 rgba = default; for (int x = 0; x < width; x++) { ref TPixel pixel = ref Unsafe.Add(ref scanBaseRef, x); @@ -87,7 +87,7 @@ namespace SixLabors.ImageSharp.Processing.Quantization.FrameQuantizers // pass of the algorithm by avoiding transforming rows of identical color. TPixel sourcePixel = source[0, 0]; TPixel previousPixel = sourcePixel; - var rgba = default(Rgba32); + Rgba32 rgba = default; byte pixelValue = this.QuantizePixel(sourcePixel, ref rgba); TPixel[] colorPalette = this.GetPalette(); TPixel transformedPixel = colorPalette[pixelValue]; @@ -152,7 +152,7 @@ namespace SixLabors.ImageSharp.Processing.Quantization.FrameQuantizers { // Transparent pixels are much more likely to be found at the end of a palette int index = this.colors; - var trans = default(Rgba32); + Rgba32 trans = default; for (int i = this.palette.Length - 1; i >= 0; i--) { this.palette[i].ToRgba32(ref trans); @@ -539,7 +539,7 @@ namespace SixLabors.ImageSharp.Processing.Quantization.FrameQuantizers byte b = (this.blue / this.pixelCount).ToByte(); // And set the color of the palette entry - var pixel = default(TPixel); + TPixel pixel = default; pixel.PackFromRgba32(new Rgba32(r, g, b, 255)); palette[index] = pixel; diff --git a/src/ImageSharp/Processing/Quantization/FrameQuantizers/WuFrameQuantizer{TPixel}.cs b/src/ImageSharp/Processing/Quantization/FrameQuantizers/WuFrameQuantizer{TPixel}.cs index 4887519e3..78c4bfbf8 100644 --- a/src/ImageSharp/Processing/Quantization/FrameQuantizers/WuFrameQuantizer{TPixel}.cs +++ b/src/ImageSharp/Processing/Quantization/FrameQuantizers/WuFrameQuantizer{TPixel}.cs @@ -237,7 +237,7 @@ namespace SixLabors.ImageSharp.Processing.Quantization.FrameQuantizers ref TPixel scanBaseRef = ref MemoryMarshal.GetReference(row); // And loop through each column - var rgba = default(Rgba32); + Rgba32 rgba = default; for (int x = 0; x < width; x++) { ref TPixel pixel = ref Unsafe.Add(ref scanBaseRef, x); @@ -858,7 +858,7 @@ namespace SixLabors.ImageSharp.Processing.Quantization.FrameQuantizers } // Expected order r->g->b->a - var rgba = default(Rgba32); + Rgba32 rgba = default; pixel.ToRgba32(ref rgba); int r = rgba.R >> (8 - IndexBits);