@@ -50,7 +50,7 @@ public static void IterateRows<T>(
5050 int width = rectangle . Width ;
5151 int height = rectangle . Height ;
5252
53- int maxSteps = DivideCeil ( width * height , parallelSettings . MinimumPixelsProcessedPerTask ) ;
53+ int maxSteps = DivideCeil ( width * ( long ) height , parallelSettings . MinimumPixelsProcessedPerTask ) ;
5454 int numOfSteps = Math . Min ( parallelSettings . MaxDegreeOfParallelism , maxSteps ) ;
5555
5656 // Avoid TPL overhead in this trivial case:
@@ -115,7 +115,7 @@ public static void IterateRows<T, TBuffer>(
115115 int width = rectangle . Width ;
116116 int height = rectangle . Height ;
117117
118- int maxSteps = DivideCeil ( width * height , parallelSettings . MinimumPixelsProcessedPerTask ) ;
118+ int maxSteps = DivideCeil ( width * ( long ) height , parallelSettings . MinimumPixelsProcessedPerTask ) ;
119119 int numOfSteps = Math . Min ( parallelSettings . MaxDegreeOfParallelism , maxSteps ) ;
120120 MemoryAllocator allocator = parallelSettings . MemoryAllocator ;
121121 int bufferLength = Unsafe . AsRef ( operation ) . GetRequiredBufferLength ( rectangle ) ;
@@ -180,7 +180,7 @@ public static void IterateRowIntervals<T>(
180180 int width = rectangle . Width ;
181181 int height = rectangle . Height ;
182182
183- int maxSteps = DivideCeil ( width * height , parallelSettings . MinimumPixelsProcessedPerTask ) ;
183+ int maxSteps = DivideCeil ( width * ( long ) height , parallelSettings . MinimumPixelsProcessedPerTask ) ;
184184 int numOfSteps = Math . Min ( parallelSettings . MaxDegreeOfParallelism , maxSteps ) ;
185185
186186 // Avoid TPL overhead in this trivial case:
@@ -242,7 +242,7 @@ public static void IterateRowIntervals<T, TBuffer>(
242242 int width = rectangle . Width ;
243243 int height = rectangle . Height ;
244244
245- int maxSteps = DivideCeil ( width * height , parallelSettings . MinimumPixelsProcessedPerTask ) ;
245+ int maxSteps = DivideCeil ( width * ( long ) height , parallelSettings . MinimumPixelsProcessedPerTask ) ;
246246 int numOfSteps = Math . Min ( parallelSettings . MaxDegreeOfParallelism , maxSteps ) ;
247247 MemoryAllocator allocator = parallelSettings . MemoryAllocator ;
248248 int bufferLength = Unsafe . AsRef ( operation ) . GetRequiredBufferLength ( rectangle ) ;
@@ -270,7 +270,7 @@ public static void IterateRowIntervals<T, TBuffer>(
270270 }
271271
272272 [ MethodImpl ( InliningOptions . ShortMethod ) ]
273- private static int DivideCeil ( int dividend , int divisor ) => 1 + ( ( dividend - 1 ) / divisor ) ;
273+ private static int DivideCeil ( long dividend , int divisor ) => ( int ) Math . Min ( 1 + ( ( dividend - 1 ) / divisor ) , int . MaxValue ) ;
274274
275275 private static void ValidateRectangle ( Rectangle rectangle )
276276 {
0 commit comments