@@ -148,11 +148,12 @@ public static (bool Difference, Rectangle Bounds) DeDuplicatePixels<TPixel>(
148148 PixelOperations < TPixel > . Instance . FromVector4Destructive ( configuration , result , resultFrame . DangerousGetPixelRowMemory ( y ) . Span , PixelConversionModifiers . Scale ) ;
149149 }
150150
151- Rectangle bounds = Rectangle . FromLTRB (
152- left = Numerics . Clamp ( left , 0 , resultFrame . Width - 1 ) ,
153- top = Numerics . Clamp ( top , 0 , resultFrame . Height - 1 ) ,
154- Numerics . Clamp ( right , left + 1 , resultFrame . Width ) ,
155- Numerics . Clamp ( bottom , top + 1 , resultFrame . Height ) ) ;
151+ left = Math . Max ( 0 , Math . Min ( left , resultFrame . Width - 1 ) ) ;
152+ top = Math . Max ( 0 , Math . Min ( top , resultFrame . Height - 1 ) ) ;
153+ right = Math . Max ( left + 1 , Math . Min ( right , resultFrame . Width ) ) ;
154+ bottom = Math . Max ( top + 1 , Math . Min ( bottom , resultFrame . Height ) ) ;
155+
156+ Rectangle bounds = Rectangle . FromLTRB ( left , top , right , bottom ) ;
156157
157158 // Webp requires even bounds
158159 if ( clampingMode == ClampingMode . Even )
0 commit comments