@@ -52,7 +52,7 @@ public static void IterateRows<T>(
5252 int width = rectangle . Width ;
5353 int height = rectangle . Height ;
5454
55- int maxSteps = DivideCeil ( width * height , parallelSettings . MinimumPixelsProcessedPerTask ) ;
55+ int maxSteps = DivideCeil ( width * ( long ) height , parallelSettings . MinimumPixelsProcessedPerTask ) ;
5656 int numOfSteps = Math . Min ( parallelSettings . MaxDegreeOfParallelism , maxSteps ) ;
5757
5858 // Avoid TPL overhead in this trivial case:
@@ -117,7 +117,7 @@ public static void IterateRows<T, TBuffer>(
117117 int width = rectangle . Width ;
118118 int height = rectangle . Height ;
119119
120- int maxSteps = DivideCeil ( width * height , parallelSettings . MinimumPixelsProcessedPerTask ) ;
120+ int maxSteps = DivideCeil ( width * ( long ) height , parallelSettings . MinimumPixelsProcessedPerTask ) ;
121121 int numOfSteps = Math . Min ( parallelSettings . MaxDegreeOfParallelism , maxSteps ) ;
122122 MemoryAllocator allocator = parallelSettings . MemoryAllocator ;
123123
@@ -181,7 +181,7 @@ public static void IterateRowIntervals<T>(
181181 int width = rectangle . Width ;
182182 int height = rectangle . Height ;
183183
184- int maxSteps = DivideCeil ( width * height , parallelSettings . MinimumPixelsProcessedPerTask ) ;
184+ int maxSteps = DivideCeil ( width * ( long ) height , parallelSettings . MinimumPixelsProcessedPerTask ) ;
185185 int numOfSteps = Math . Min ( parallelSettings . MaxDegreeOfParallelism , maxSteps ) ;
186186
187187 // Avoid TPL overhead in this trivial case:
@@ -243,7 +243,7 @@ public static void IterateRowIntervals<T, TBuffer>(
243243 int width = rectangle . Width ;
244244 int height = rectangle . Height ;
245245
246- int maxSteps = DivideCeil ( width * height , parallelSettings . MinimumPixelsProcessedPerTask ) ;
246+ int maxSteps = DivideCeil ( width * ( long ) height , parallelSettings . MinimumPixelsProcessedPerTask ) ;
247247 int numOfSteps = Math . Min ( parallelSettings . MaxDegreeOfParallelism , maxSteps ) ;
248248 MemoryAllocator allocator = parallelSettings . MemoryAllocator ;
249249
@@ -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