Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ using SixLabors.ImageSharp;
using SixLabors.ImageSharp.PixelFormats;

// Individual pixels
using (Image<Rgba32> image = new Image<Rgba32>(400, 400))
using (var image = new Image<Rgba32>(400, 400))
{
image[200, 200] = Rgba32.White;
}
Expand Down
4 changes: 2 additions & 2 deletions src/ImageSharp.Drawing/Processing/DrawingHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ internal static class DrawingHelpers
public static DenseMatrix<TPixel> ToPixelMatrix<TPixel>(this DenseMatrix<Color> colorMatrix, Configuration configuration)
where TPixel : struct, IPixel<TPixel>
{
DenseMatrix<TPixel> result = new DenseMatrix<TPixel>(colorMatrix.Columns, colorMatrix.Rows);
var result = new DenseMatrix<TPixel>(colorMatrix.Columns, colorMatrix.Rows);
Color.ToPixel(configuration, colorMatrix.Span, result.Span);
return result;
}
}
}
}
4 changes: 2 additions & 2 deletions src/ImageSharp/Common/Extensions/StreamExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.

using System;
Expand Down Expand Up @@ -60,7 +60,7 @@ public static void Skip(this Stream stream, int count)
}
else
{
byte[] foo = new byte[count];
var foo = new byte[count];
while (count > 0)
{
int bytesRead = stream.Read(foo, 0, count);
Expand Down
12 changes: 6 additions & 6 deletions src/ImageSharp/Common/Helpers/SimdUtils.BasicIntrinsics256.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.

using System;
Expand Down Expand Up @@ -138,8 +138,8 @@ internal static void BulkConvertNormalizedFloatToByteClampOverflows(ReadOnlySpan
ref Octet.OfByte destBase = ref Unsafe.As<byte, Octet.OfByte>(ref MemoryMarshal.GetReference(dest));
int n = source.Length / 8;

Vector<float> magick = new Vector<float>(32768.0f);
Vector<float> scale = new Vector<float>(255f) / new Vector<float>(256f);
var magick = new Vector<float>(32768.0f);
var scale = new Vector<float>(255f) / new Vector<float>(256f);

// need to copy to a temporary struct, because
// SimdUtils.Octet.OfUInt32 temp = Unsafe.As<Vector<float>, SimdUtils.Octet.OfUInt32>(ref x)
Expand Down Expand Up @@ -187,8 +187,8 @@ internal static void BulkConvertNormalizedFloatToByte(ReadOnlySpan<float> source
ref Octet.OfByte destBase = ref Unsafe.As<byte, Octet.OfByte>(ref MemoryMarshal.GetReference(dest));
int n = source.Length / 8;

Vector<float> magick = new Vector<float>(32768.0f);
Vector<float> scale = new Vector<float>(255f) / new Vector<float>(256f);
var magick = new Vector<float>(32768.0f);
var scale = new Vector<float>(255f) / new Vector<float>(256f);

// need to copy to a temporary struct, because
// SimdUtils.Octet.OfUInt32 temp = Unsafe.As<Vector<float>, SimdUtils.Octet.OfUInt32>(ref x)
Expand All @@ -211,4 +211,4 @@ internal static void BulkConvertNormalizedFloatToByte(ReadOnlySpan<float> source
}
}
}
}
}
6 changes: 3 additions & 3 deletions src/ImageSharp/Common/Helpers/SimdUtils.ExtendedIntrinsics.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.

using System;
Expand Down Expand Up @@ -172,7 +172,7 @@ internal static void BulkConvertNormalizedFloatToByteClampOverflows(
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static Vector<uint> ConvertToUInt32(Vector<float> vf)
{
Vector<float> maxBytes = new Vector<float>(255f);
var maxBytes = new Vector<float>(255f);
vf *= maxBytes;
vf += new Vector<float>(0.5f);
vf = Vector.Min(Vector.Max(vf, Vector<float>.Zero), maxBytes);
Expand All @@ -190,4 +190,4 @@ private static Vector<float> ConvertToSingle(Vector<uint> u)
}
}
}
}
}
6 changes: 3 additions & 3 deletions src/ImageSharp/Common/Helpers/SimdUtils.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.

using System;
Expand Down Expand Up @@ -43,7 +43,7 @@ internal static Vector4 PseudoRound(this Vector4 v)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static Vector<float> FastRound(this Vector<float> v)
{
Vector<int> magic0 = new Vector<int>(int.MinValue); // 0x80000000
var magic0 = new Vector<int>(int.MinValue); // 0x80000000
Vector<float> sgn0 = Vector.AsVectorSingle(magic0);
Vector<float> and0 = Vector.BitwiseAnd(sgn0, v);
Vector<float> or0 = Vector.BitwiseOr(and0, new Vector<float>(8388608.0f));
Expand Down Expand Up @@ -179,4 +179,4 @@ private static void VerifySpanInput(ReadOnlySpan<float> source, Span<byte> dest,
$"length should be divisible by {shouldBeDivisibleBy}!");
}
}
}
}
20 changes: 10 additions & 10 deletions src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ private void UncompressRle4(int w, Span<byte> buffer, Span<bool> undefinedPixels
#if NETCOREAPP2_1
Span<byte> cmd = stackalloc byte[2];
#else
byte[] cmd = new byte[2];
var cmd = new byte[2];
#endif
int count = 0;

Expand Down Expand Up @@ -485,7 +485,7 @@ private void UncompressRle4(int w, Span<byte> buffer, Span<bool> undefinedPixels
int max = cmd[1];
int bytesToRead = (max + 1) / 2;

byte[] run = new byte[bytesToRead];
var run = new byte[bytesToRead];

this.stream.Read(run, 0, run.Length);

Expand Down Expand Up @@ -557,7 +557,7 @@ private void UncompressRle8(int w, Span<byte> buffer, Span<bool> undefinedPixels
#if NETCOREAPP2_1
Span<byte> cmd = stackalloc byte[2];
#else
byte[] cmd = new byte[2];
var cmd = new byte[2];
#endif
int count = 0;

Expand Down Expand Up @@ -595,7 +595,7 @@ private void UncompressRle8(int w, Span<byte> buffer, Span<bool> undefinedPixels
// Take this number of bytes from the stream as uncompressed data.
int length = cmd[1];

byte[] run = new byte[length];
var run = new byte[length];

this.stream.Read(run, 0, run.Length);

Expand Down Expand Up @@ -640,7 +640,7 @@ private void UncompressRle24(int w, Span<byte> buffer, Span<bool> undefinedPixel
#if NETCOREAPP2_1
Span<byte> cmd = stackalloc byte[2];
#else
byte[] cmd = new byte[2];
var cmd = new byte[2];
#endif
int uncompressedPixels = 0;

Expand Down Expand Up @@ -678,7 +678,7 @@ private void UncompressRle24(int w, Span<byte> buffer, Span<bool> undefinedPixel
// Take this number of bytes from the stream as uncompressed data.
int length = cmd[1];

byte[] run = new byte[length * 3];
var run = new byte[length * 3];

this.stream.Read(run, 0, run.Length);

Expand Down Expand Up @@ -1214,7 +1214,7 @@ private void ReadInfoHeader()
#if NETCOREAPP2_1
Span<byte> buffer = stackalloc byte[BmpInfoHeader.MaxHeaderSize];
#else
byte[] buffer = new byte[BmpInfoHeader.MaxHeaderSize];
var buffer = new byte[BmpInfoHeader.MaxHeaderSize];
#endif

// Read the header size.
Expand Down Expand Up @@ -1252,7 +1252,7 @@ private void ReadInfoHeader()
// color masks for each color channel follow the info header.
if (this.infoHeader.Compression == BmpCompression.BitFields)
{
byte[] bitfieldsBuffer = new byte[12];
var bitfieldsBuffer = new byte[12];
this.stream.Read(bitfieldsBuffer, 0, 12);
Span<byte> data = bitfieldsBuffer.AsSpan();
this.infoHeader.RedMask = BinaryPrimitives.ReadInt32LittleEndian(data.Slice(0, 4));
Expand All @@ -1261,7 +1261,7 @@ private void ReadInfoHeader()
}
else if (this.infoHeader.Compression == BmpCompression.BI_ALPHABITFIELDS)
{
byte[] bitfieldsBuffer = new byte[16];
var bitfieldsBuffer = new byte[16];
this.stream.Read(bitfieldsBuffer, 0, 16);
Span<byte> data = bitfieldsBuffer.AsSpan();
this.infoHeader.RedMask = BinaryPrimitives.ReadInt32LittleEndian(data.Slice(0, 4));
Expand Down Expand Up @@ -1340,7 +1340,7 @@ private void ReadFileHeader()
#if NETCOREAPP2_1
Span<byte> buffer = stackalloc byte[BmpFileHeader.Size];
#else
byte[] buffer = new byte[BmpFileHeader.Size];
var buffer = new byte[BmpFileHeader.Size];
#endif
this.stream.Read(buffer, 0, BmpFileHeader.Size);

Expand Down
4 changes: 2 additions & 2 deletions src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.

using System;
Expand Down Expand Up @@ -176,7 +176,7 @@ public void Encode<TPixel>(Image<TPixel> image, Stream stream)
#if NETCOREAPP2_1
Span<byte> buffer = stackalloc byte[infoHeaderSize];
#else
byte[] buffer = new byte[infoHeaderSize];
var buffer = new byte[infoHeaderSize];
#endif
fileHeader.WriteTo(buffer);

Expand Down
6 changes: 3 additions & 3 deletions src/ImageSharp/Formats/Gif/LzwDecoder.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.

using System;
Expand Down Expand Up @@ -116,7 +116,7 @@ public void DecodePixels(int width, int height, int dataSize, Span<byte> pixels)
#if NETCOREAPP2_1
Span<byte> buffer = stackalloc byte[255];
#else
byte[] buffer = new byte[255];
var buffer = new byte[255];
#endif

while (xyz < length)
Expand Down Expand Up @@ -253,4 +253,4 @@ public void Dispose()
this.pixelStack.Dispose();
}
}
}
}
4 changes: 2 additions & 2 deletions src/ImageSharp/Formats/Jpeg/Components/Block8x8.cs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ public Block8x8F AsFloatBlock()
/// </summary>
public short[] ToArray()
{
short[] result = new short[Size];
var result = new short[Size];
this.CopyTo(result);
return result;
}
Expand Down Expand Up @@ -297,4 +297,4 @@ public static long TotalDifference(ref Block8x8 a, ref Block8x8 b)
return result;
}
}
}
}
12 changes: 6 additions & 6 deletions src/ImageSharp/Formats/Jpeg/Components/Block8x8F.Generated.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.

using System;
Expand Down Expand Up @@ -95,9 +95,9 @@ public void TransposeInto(ref Block8x8F d)
/// </summary>
public void NormalizeColorsInplace(float maximum)
{
Vector4 CMin4 = new Vector4(0F);
Vector4 CMax4 = new Vector4(maximum);
Vector4 COff4 = new Vector4(MathF.Ceiling(maximum / 2));
var CMin4 = new Vector4(0F);
var CMax4 = new Vector4(maximum);
var COff4 = new Vector4(MathF.Ceiling(maximum / 2));

this.V0L = Vector4.Clamp(this.V0L + COff4, CMin4, CMax4);
this.V0R = Vector4.Clamp(this.V0R + COff4, CMin4, CMax4);
Expand All @@ -123,8 +123,8 @@ public void NormalizeColorsInplace(float maximum)
[MethodImpl(InliningOptions.ShortMethod)]
public void NormalizeColorsAndRoundInplaceAvx2(float maximum)
{
Vector<float> off = new Vector<float>(MathF.Ceiling(maximum / 2));
Vector<float> max = new Vector<float>(maximum);
var off = new Vector<float>(MathF.Ceiling(maximum / 2));
var max = new Vector<float>(maximum);

ref Vector<float> row0 = ref Unsafe.As<Vector4, Vector<float>>(ref this.V0L);
row0 = NormalizeAndRound(row0, off, max);
Expand Down
20 changes: 10 additions & 10 deletions src/ImageSharp/Formats/Jpeg/Components/Block8x8F.Generated.tt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<#
<#
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
#>
Expand Down Expand Up @@ -47,7 +47,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components
char srcCoord = coordz[j % 4];
char srcSide = (j / 4) % 2 == 0 ? 'L' : 'R';

string expression = $"d.V{j}{destSide}.{destCoord} = V{i}{srcSide}.{srcCoord};\r\n";
var expression = $"d.V{j}{destSide}.{destCoord} = V{i}{srcSide}.{srcCoord};\r\n";
Write(expression);
}
}
Expand All @@ -60,9 +60,9 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components
/// </summary>
public void NormalizeColorsInplace(float maximum)
{
Vector4 CMin4 = new Vector4(0F);
Vector4 CMax4 = new Vector4(maximum);
Vector4 COff4 = new Vector4(MathF.Ceiling(maximum / 2));
var CMin4 = new Vector4(0F);
var CMax4 = new Vector4(maximum);
var COff4 = new Vector4(MathF.Ceiling(maximum / 2));

<#

Expand All @@ -86,8 +86,8 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components
[MethodImpl(InliningOptions.ShortMethod)]
public void NormalizeColorsAndRoundInplaceAvx2(float maximum)
{
Vector<float> off = new Vector<float>(MathF.Ceiling(maximum / 2));
Vector<float> max = new Vector<float>(maximum);
var off = new Vector<float>(MathF.Ceiling(maximum / 2));
var max = new Vector<float>(maximum);
<#

for (int i = 0; i < 8; i++)
Expand Down Expand Up @@ -117,17 +117,17 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components
{
char destCoord = coordz[i % 4];
char destSide = (i / 4) % 2 == 0 ? 'L' : 'R';

if(j > 0 && i == 0){
WriteLine("");
}

char srcCoord = coordz[j % 4];
char srcSide = (j / 4) % 2 == 0 ? 'L' : 'R';

string expression = $"this.V{j}{destSide}.{destCoord} = Unsafe.Add(ref selfRef, {j*8+i});\r\n";
var expression = $"this.V{j}{destSide}.{destCoord} = Unsafe.Add(ref selfRef, {j*8+i});\r\n";
Write(expression);

}
}
PopIndent();
Expand Down
6 changes: 3 additions & 3 deletions src/ImageSharp/Formats/Jpeg/Components/Block8x8F.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.

using System;
Expand Down Expand Up @@ -257,7 +257,7 @@ public unsafe void CopyTo(Span<int> dest)
{
fixed (Vector4* ptr = &this.V0L)
{
float* fp = (float*)ptr;
var fp = (float*)ptr;
for (int i = 0; i < Size; i++)
{
dest[i] = (int)fp[i];
Expand All @@ -267,7 +267,7 @@ public unsafe void CopyTo(Span<int> dest)

public float[] ToArray()
{
float[] result = new float[Size];
var result = new float[Size];
this.CopyTo(result);
return result;
}
Expand Down
6 changes: 3 additions & 3 deletions src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ private void ProcessApp1Marker(int remaining)
return;
}

byte[] profile = new byte[remaining];
var profile = new byte[remaining];
this.InputStream.Read(profile, 0, remaining);

if (ProfileResolver.IsProfile(profile, ProfileResolver.ExifMarker))
Expand Down Expand Up @@ -571,14 +571,14 @@ private void ProcessApp2Marker(int remaining)
return;
}

byte[] identifier = new byte[Icclength];
var identifier = new byte[Icclength];
this.InputStream.Read(identifier, 0, Icclength);
remaining -= Icclength; // We have read it by this point

if (ProfileResolver.IsProfile(identifier, ProfileResolver.IccMarker))
{
this.isIcc = true;
byte[] profile = new byte[remaining];
var profile = new byte[remaining];
this.InputStream.Read(profile, 0, remaining);

if (this.iccData is null)
Expand Down
Loading