Skip to content

Commit 2ec7768

Browse files
Add argument docs and negative tests
1 parent 28f3938 commit 2ec7768

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

src/ImageSharp/ImageFrame{TPixel}.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ internal ImageFrame(Configuration configuration, ImageFrame<TPixel> source)
173173
/// </summary>
174174
/// <param name="rowIndex">The row.</param>
175175
/// <returns>The <see cref="Span{TPixel}"/></returns>
176+
/// <exception cref="ArgumentOutOfRangeException">Thrown when row index is out of range.</exception>
176177
public Span<TPixel> GetPixelRowSpan(int rowIndex)
177178
{
178179
Guard.MustBeGreaterThanOrEqualTo(rowIndex, 0, nameof(rowIndex));

src/ImageSharp/Image{TPixel}.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ internal Image(Configuration configuration, ImageMetadata metadata, IEnumerable<
169169
/// </summary>
170170
/// <param name="rowIndex">The row.</param>
171171
/// <returns>The <see cref="Span{TPixel}"/></returns>
172+
/// <exception cref="ArgumentOutOfRangeException">Thrown when row index is out of range.</exception>
172173
public Span<TPixel> GetPixelRowSpan(int rowIndex)
173174
{
174175
Guard.MustBeGreaterThanOrEqualTo(rowIndex, 0, nameof(rowIndex));

tests/ImageSharp.Tests/Image/LargeImageIntegrationTests.cs

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

4+
using System;
45
using SixLabors.ImageSharp.PixelFormats;
56
using SixLabors.ImageSharp.Processing;
67
using Xunit;
@@ -17,5 +18,15 @@ public void CreateAndResize(TestImageProvider<Rgba32> provider)
1718
image.Mutate(c => c.Resize(1000, 1000));
1819
image.DebugSave(provider);
1920
}
21+
22+
[Theory]
23+
[WithBasicTestPatternImages(width: 10, height: 10, PixelTypes.Rgba32)]
24+
public void GetSingleSpan(TestImageProvider<Rgba32> provider)
25+
{
26+
provider.LimitAllocatorBufferCapacity().InPixels(10);
27+
using Image<Rgba32> image = provider.GetImage();
28+
Assert.False(image.TryGetSinglePixelSpan(out Span<Rgba32> imageSpan));
29+
Assert.False(image.Frames.RootFrame.TryGetSinglePixelSpan(out Span<Rgba32> imageFrameSpan));
30+
}
2031
}
2132
}

0 commit comments

Comments
 (0)