Skip to content

Commit bff44f9

Browse files
Merge branch 'master' into fix-indexoutofrangeexception-in-fillregionprocessor
2 parents 724c26a + fb033fe commit bff44f9

File tree

51 files changed

+142
-309
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+142
-309
lines changed

src/ImageSharp/Advanced/AdvancedImageExtensions.cs

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) Six Labors and contributors.
1+
// Copyright (c) Six Labors and contributors.
22
// Licensed under the Apache License, Version 2.0.
33

44
using System;
@@ -153,42 +153,6 @@ internal static Memory<TPixel> GetPixelRowMemory<TPixel>(this Image<TPixel> sour
153153
internal static MemoryAllocator GetMemoryAllocator(this IConfigurable source)
154154
=> GetConfiguration(source).MemoryAllocator;
155155

156-
/// <summary>
157-
/// Gets the span to the backing buffer.
158-
/// </summary>
159-
/// <typeparam name="TPixel">The type of the pixel.</typeparam>
160-
/// <param name="source">The source.</param>
161-
/// <returns>The span returned from Pixel source</returns>
162-
private static Span<TPixel> GetSpan<TPixel>(IPixelSource<TPixel> source)
163-
where TPixel : struct, IPixel<TPixel>
164-
=> source.PixelBuffer.GetSpan();
165-
166-
/// <summary>
167-
/// Gets the span to the backing buffer at the given row.
168-
/// </summary>
169-
/// <typeparam name="TPixel">The type of the pixel.</typeparam>
170-
/// <param name="source">The source.</param>
171-
/// <param name="row">The row.</param>
172-
/// <returns>
173-
/// The span returned from Pixel source
174-
/// </returns>
175-
private static Span<TPixel> GetSpan<TPixel>(IPixelSource<TPixel> source, int row)
176-
where TPixel : struct, IPixel<TPixel>
177-
=> GetSpan(source.PixelBuffer, row);
178-
179-
/// <summary>
180-
/// Gets the span to the backing buffer at the given row.
181-
/// </summary>
182-
/// <typeparam name="TPixel">The type of the pixel.</typeparam>
183-
/// <param name="source">The source.</param>
184-
/// <param name="row">The row.</param>
185-
/// <returns>
186-
/// The span returned from Pixel source.
187-
/// </returns>
188-
private static Span<TPixel> GetSpan<TPixel>(Buffer2D<TPixel> source, int row)
189-
where TPixel : struct, IPixel<TPixel>
190-
=> source.GetSpan().Slice(row * source.Width, source.Width);
191-
192156
/// <summary>
193157
/// Gets the configuration.
194158
/// </summary>

src/ImageSharp/Common/Helpers/Guard.cs

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) Six Labors and contributors.
1+
// Copyright (c) Six Labors and contributors.
22
// Licensed under the Apache License, Version 2.0.
33

44
using System;
@@ -51,28 +51,6 @@ public static void NotNullOrWhiteSpace(string value, string parameterName)
5151
}
5252
}
5353

54-
/// <summary>
55-
/// Ensures that the enumeration is not null or empty.
56-
/// </summary>
57-
/// <typeparam name="T">The type of objects in the <paramref name="value"/></typeparam>
58-
/// <param name="value">The target enumeration, which should be checked against being null or empty.</param>
59-
/// <param name="parameterName">Name of the parameter.</param>
60-
/// <exception cref="ArgumentNullException"><paramref name="value"/> is null.</exception>
61-
/// <exception cref="ArgumentException"><paramref name="value"/> is empty.</exception>
62-
[MethodImpl(InliningOptions.ShortMethod)]
63-
public static void NotNullOrEmpty<T>(ICollection<T> value, string parameterName)
64-
{
65-
if (value is null)
66-
{
67-
ThrowArgumentNullException(parameterName);
68-
}
69-
70-
if (value.Count == 0)
71-
{
72-
ThrowArgumentException("Must not be empty.", parameterName);
73-
}
74-
}
75-
7654
/// <summary>
7755
/// Ensures that the specified value is less than a maximum value.
7856
/// </summary>

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

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) Six Labors and contributors.
1+
// Copyright (c) Six Labors and contributors.
22
// Licensed under the Apache License, Version 2.0.
33

44
using System;
@@ -25,12 +25,8 @@ public static void Decode(Span<byte> scanline, int bytesPerPixel)
2525
ref byte scanBaseRef = ref MemoryMarshal.GetReference(scanline);
2626

2727
// Sub(x) + Raw(x-bpp)
28-
int x = 1;
29-
for (; x <= bytesPerPixel /* Note the <= because x starts at 1 */; ++x)
30-
{
31-
ref byte scan = ref Unsafe.Add(ref scanBaseRef, x);
32-
}
33-
28+
int x = bytesPerPixel + 1;
29+
Unsafe.Add(ref scanBaseRef, x);
3430
for (; x < scanline.Length; ++x)
3531
{
3632
ref byte scan = ref Unsafe.Add(ref scanBaseRef, x);

src/ImageSharp/MetaData/Profiles/Exif/ExifReader.cs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) Six Labors and contributors.
1+
// Copyright (c) Six Labors and contributors.
22
// Licensed under the Apache License, Version 2.0.
33

44
using System;
@@ -419,16 +419,6 @@ private ushort ReadUInt16()
419419
: default;
420420
}
421421

422-
private string ReadString(int length)
423-
{
424-
if (this.TryReadSpan(length, out ReadOnlySpan<byte> span) && span.Length != 0)
425-
{
426-
return this.ConvertToString(span);
427-
}
428-
429-
return null;
430-
}
431-
432422
private void GetThumbnail(uint offset)
433423
{
434424
var values = new List<ExifValue>();

src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.TagDataEntry.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) Six Labors and contributors.
1+
// Copyright (c) Six Labors and contributors.
22
// Licensed under the Apache License, Version 2.0.
33

44
using System;
@@ -526,9 +526,8 @@ public IccMultiProcessElementsTagDataEntry ReadMultiProcessElementsTagDataEntry(
526526
{
527527
int start = this.currentIndex - 8;
528528

529-
// TODO: Why are we storing variable
530-
ushort inChannelCount = this.ReadUInt16();
531-
ushort outChannelCount = this.ReadUInt16();
529+
this.ReadUInt16();
530+
this.ReadUInt16();
532531
uint elementCount = this.ReadUInt32();
533532

534533
var positionTable = new IccPositionNumber[elementCount];
@@ -902,4 +901,4 @@ public IccUcrBgTagDataEntry ReadUcrBgTagDataEntry(uint size)
902901
return new IccUcrBgTagDataEntry(ucrCurve, bgCurve, description);
903902
}
904903
}
905-
}
904+
}

src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.cs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) Six Labors and contributors.
1+
// Copyright (c) Six Labors and contributors.
22
// Licensed under the Apache License, Version 2.0.
33

44
using System;
@@ -83,16 +83,5 @@ private bool GetBit(byte value, int position)
8383
{
8484
return ((value >> (7 - position)) & 1) == 1;
8585
}
86-
87-
/// <summary>
88-
/// Gets the bit value at a specified position
89-
/// </summary>
90-
/// <param name="value">The value from where the bit will be extracted</param>
91-
/// <param name="position">Position of the bit. Zero based index from left to right.</param>
92-
/// <returns>The bit value at specified position</returns>
93-
private bool GetBit(ushort value, int position)
94-
{
95-
return ((value >> (15 - position)) & 1) == 1;
96-
}
9786
}
9887
}

src/ImageSharp/MetaData/Profiles/ICC/DataWriter/IccDataWriter.Curves.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ public int WriteOneDimensionalCurve(IccOneDimensionalCurve value)
4141
public int WriteResponseCurve(IccResponseCurve value)
4242
{
4343
int count = this.WriteUInt32((uint)value.CurveType);
44-
int channels = value.XyzValues.Length;
4544

4645
foreach (IccResponseNumber[] responseArray in value.ResponseArrays)
4746
{

src/ImageSharp/MetaData/Profiles/ICC/DataWriter/IccDataWriter.NonPrimitives.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) Six Labors and contributors.
1+
// Copyright (c) Six Labors and contributors.
22
// Licensed under the Apache License, Version 2.0.
33

44
using System;
@@ -37,9 +37,6 @@ public int WriteVersionNumber(in IccVersion value)
3737
int minor = value.Minor.Clamp(0, 15);
3838
int bugfix = value.Patch.Clamp(0, 15);
3939

40-
// TODO: This is not used?
41-
byte mb = (byte)((minor << 4) | bugfix);
42-
4340
int version = (major << 24) | (minor << 20) | (bugfix << 16);
4441
return this.WriteInt32(version);
4542
}

src/ImageSharp/PixelFormats/PixelImplementations/Gray16.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) Six Labors and contributors.
1+
// Copyright (c) Six Labors and contributors.
22
// Licensed under the Apache License, Version 2.0.
33

44
using System.Numerics;
@@ -15,7 +15,6 @@ namespace SixLabors.ImageSharp.PixelFormats
1515
public partial struct Gray16 : IPixel<Gray16>, IPackedVector<ushort>
1616
{
1717
private const float Max = ushort.MaxValue;
18-
private const float Average = 1 / 3F;
1918

2019
/// <summary>
2120
/// Initializes a new instance of the <see cref="Gray16"/> struct.

src/ImageSharp/PixelFormats/PixelImplementations/Gray8.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) Six Labors and contributors.
1+
// Copyright (c) Six Labors and contributors.
22
// Licensed under the Apache License, Version 2.0.
33

44
using System.Numerics;
@@ -16,12 +16,6 @@ public partial struct Gray8 : IPixel<Gray8>, IPackedVector<byte>
1616
{
1717
private static readonly Vector4 MaxBytes = new Vector4(255F);
1818
private static readonly Vector4 Half = new Vector4(0.5F);
19-
private const float Average = 1 / 3F;
20-
21-
private static readonly Vector4 Min = new Vector4(0, 0, 0, 1f);
22-
private static readonly Vector4 Max = Vector4.One;
23-
24-
private static readonly Vector4 Accumulator = new Vector4(255f * Average, 255f * Average, 255f * Average, 0.5f);
2519

2620
/// <summary>
2721
/// Initializes a new instance of the <see cref="Gray8"/> struct.

0 commit comments

Comments
 (0)