Skip to content

Commit a04526f

Browse files
Minor cleanup
1 parent f95d4d1 commit a04526f

File tree

4 files changed

+15
-14
lines changed

4 files changed

+15
-14
lines changed

src/ImageSharp/ImageFrame{TPixel}.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ internal ImageFrame(Configuration configuration, ImageFrame<TPixel> source)
144144
}
145145

146146
/// <inheritdoc/>
147-
public Buffer2D<TPixel> PixelBuffer { get; private set; }
147+
public Buffer2D<TPixel> PixelBuffer { get; }
148148

149149
/// <summary>
150150
/// Gets or sets the pixel at the specified position.
@@ -309,6 +309,7 @@ public bool DangerousTryGetSinglePixelMemory(out Memory<TPixel> memory)
309309
/// Copies the pixels to a <see cref="Buffer2D{TPixel}"/> of the same size.
310310
/// </summary>
311311
/// <param name="target">The target pixel buffer accessor.</param>
312+
/// <exception cref="ArgumentException">ImageFrame{TPixel}.CopyTo(): target must be of the same size!</exception>
312313
internal void CopyTo(Buffer2D<TPixel> target)
313314
{
314315
if (this.Size() != target.Size())
@@ -445,14 +446,12 @@ private void VerifyCoords(int x, int y)
445446
}
446447

447448
[MethodImpl(InliningOptions.ColdPath)]
448-
private static void ThrowArgumentOutOfRangeException(string paramName)
449-
{
450-
throw new ArgumentOutOfRangeException(paramName);
451-
}
449+
private static void ThrowArgumentOutOfRangeException(string paramName) => throw new ArgumentOutOfRangeException(paramName);
452450

453451
/// <summary>
454452
/// A <see langword="struct"/> implementing the clone logic for <see cref="ImageFrame{TPixel}"/>.
455453
/// </summary>
454+
/// <typeparam name="TPixel2">The type of the target pixel format.</typeparam>
456455
private readonly struct RowIntervalOperation<TPixel2> : IRowIntervalOperation
457456
where TPixel2 : unmanaged, IPixel<TPixel2>
458457
{

src/ImageSharp/IndexedImageFrame{TPixel}.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ namespace SixLabors.ImageSharp;
1717
public sealed class IndexedImageFrame<TPixel> : IPixelSource, IDisposable
1818
where TPixel : unmanaged, IPixel<TPixel>
1919
{
20-
private Buffer2D<byte> pixelBuffer;
21-
private IMemoryOwner<TPixel> paletteOwner;
20+
private readonly Buffer2D<byte> pixelBuffer;
21+
private readonly IMemoryOwner<TPixel> paletteOwner;
2222
private bool isDisposed;
2323

2424
/// <summary>

src/ImageSharp/Processing/Extensions/ProcessingExtensions.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ IInternalImageProcessingContext<TPixel> operationsRunner
134134
/// <exception cref="ArgumentNullException">The operation is null.</exception>
135135
/// <exception cref="ObjectDisposedException">The source has been disposed.</exception>
136136
/// <exception cref="ImageProcessingException">The processing operation failed.</exception>
137-
public static Image? Clone(this Image source, Action<IImageProcessingContext> operation)
137+
public static Image Clone(this Image source, Action<IImageProcessingContext> operation)
138138
=> Clone(source, source.GetConfiguration(), operation);
139139

140140
/// <summary>
@@ -149,7 +149,7 @@ IInternalImageProcessingContext<TPixel> operationsRunner
149149
/// <exception cref="ObjectDisposedException">The source has been disposed.</exception>
150150
/// <exception cref="ImageProcessingException">The processing operation failed.</exception>
151151
/// <returns>The new <see cref="Image"/>.</returns>
152-
public static Image? Clone(this Image source, Configuration configuration, Action<IImageProcessingContext> operation)
152+
public static Image Clone(this Image source, Configuration configuration, Action<IImageProcessingContext> operation)
153153
{
154154
Guard.NotNull(configuration, nameof(configuration));
155155
Guard.NotNull(source, nameof(source));
@@ -158,7 +158,7 @@ IInternalImageProcessingContext<TPixel> operationsRunner
158158

159159
ProcessingVisitor visitor = new(configuration, operation, false);
160160
source.AcceptVisitor(visitor);
161-
return visitor.ResultImage;
161+
return visitor.GetResultImage();
162162
}
163163

164164
/// <summary>
@@ -274,14 +274,16 @@ private class ProcessingVisitor : IImageVisitor
274274

275275
private readonly bool mutate;
276276

277+
private Image? resultImage;
278+
277279
public ProcessingVisitor(Configuration configuration, Action<IImageProcessingContext> operation, bool mutate)
278280
{
279281
this.configuration = configuration;
280282
this.operation = operation;
281283
this.mutate = mutate;
282284
}
283285

284-
public Image? ResultImage { get; private set; }
286+
public Image GetResultImage() => this.resultImage!;
285287

286288
public void Visit<TPixel>(Image<TPixel> image)
287289
where TPixel : unmanaged, IPixel<TPixel>
@@ -290,7 +292,7 @@ public void Visit<TPixel>(Image<TPixel> image)
290292
this.configuration.ImageOperationsProvider.CreateImageProcessingContext(this.configuration, image, this.mutate);
291293

292294
this.operation(operationsRunner);
293-
this.ResultImage = operationsRunner.GetResultImage();
295+
this.resultImage = operationsRunner.GetResultImage();
294296
}
295297
}
296298
}

src/ImageSharp/Processing/ProjectiveTransformBuilder.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace SixLabors.ImageSharp.Processing;
1111
/// </summary>
1212
public class ProjectiveTransformBuilder
1313
{
14-
private readonly List<Func<Size, Matrix4x4>> matrixFactories = new List<Func<Size, Matrix4x4>>();
14+
private readonly List<Func<Size, Matrix4x4>> matrixFactories = new();
1515

1616
/// <summary>
1717
/// Prepends a matrix that performs a tapering projective transform.
@@ -313,7 +313,7 @@ public Matrix4x4 BuildMatrix(Rectangle sourceRectangle)
313313
Guard.MustBeGreaterThan(sourceRectangle.Height, 0, nameof(sourceRectangle));
314314

315315
// Translate the origin matrix to cater for source rectangle offsets.
316-
var matrix = Matrix4x4.CreateTranslation(new Vector3(-sourceRectangle.Location, 0));
316+
Matrix4x4 matrix = Matrix4x4.CreateTranslation(new Vector3(-sourceRectangle.Location, 0));
317317

318318
Size size = sourceRectangle.Size;
319319

0 commit comments

Comments
 (0)