File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -609,14 +609,14 @@ public static unsafe Image<TPixel> WrapMemory<TPixel>(
609609 ImageMetadata metadata )
610610 where TPixel : unmanaged, IPixel < TPixel >
611611 {
612- Guard . IsFalse ( pointer == null , nameof ( pointer ) , "Pointer must be not null" ) ;
612+ Guard . IsFalse ( pointer == null , nameof ( pointer ) , "Pointer must not be null" ) ;
613613 Guard . NotNull ( configuration , nameof ( configuration ) ) ;
614614 Guard . NotNull ( metadata , nameof ( metadata ) ) ;
615615
616616 int rowStride = GetPixelRowStrideFromByteStride < TPixel > ( width , rowStrideInBytes , nameof ( rowStrideInBytes ) ) ;
617617 long requiredLength = GetRequiredLength ( width , height , rowStride ) ;
618618
619- Guard . MustBeLessThanOrEqualTo ( requiredLength , int . MaxValue , nameof ( height ) ) ;
619+ Guard . MustBeLessThanOrEqualTo ( requiredLength , int . MaxValue , nameof ( requiredLength ) ) ;
620620 Guard . MustBeGreaterThanOrEqualTo ( bufferSizeInBytes / Unsafe . SizeOf < TPixel > ( ) , requiredLength , nameof ( bufferSizeInBytes ) ) ;
621621
622622 UnmanagedMemoryManager < TPixel > memoryManager = new ( pointer , ( int ) requiredLength ) ;
Original file line number Diff line number Diff line change @@ -356,7 +356,7 @@ internal Memory<T> GetSafeRowMemory(int y)
356356 /// Thrown when the backing group is discontiguous.
357357 /// </exception>
358358 [ MethodImpl ( InliningOptions . ShortMethod ) ]
359- internal Span < T > DangerousGetSingleSpan ( ) => this . FastMemoryGroup [ 0 ] . Span ;
359+ internal Span < T > DangerousGetSingleSpan ( ) => this . FastMemoryGroup . Single ( ) . Span ;
360360
361361 /// <summary>
362362 /// Gets a <see cref="Memory{T}"/> to the backing data of if the backing group consists of a single contiguous memory buffer.
@@ -367,7 +367,7 @@ internal Memory<T> GetSafeRowMemory(int y)
367367 /// Thrown when the backing group is discontiguous.
368368 /// </exception>
369369 [ MethodImpl ( InliningOptions . ShortMethod ) ]
370- internal Memory < T > DangerousGetSingleMemory ( ) => this . FastMemoryGroup [ 0 ] ;
370+ internal Memory < T > DangerousGetSingleMemory ( ) => this . FastMemoryGroup . Single ( ) ;
371371
372372 /// <summary>
373373 /// Swaps the contents of 'destination' with 'source' if the buffers are owned (1),
@@ -414,5 +414,5 @@ private void ThrowYOutOfRangeException(int y)
414414
415415 [ MethodImpl ( InliningOptions . ShortMethod ) ]
416416 private static long GetRequiredLength ( int width , int height , int stride )
417- => ( ( long ) ( height - 1 ) * stride ) + width ;
417+ => checked ( ( ( long ) ( height - 1 ) * stride ) + width ) ;
418418}
You can’t perform that action at this time.
0 commit comments