@@ -52,7 +52,7 @@ public static void IterateRows<T>(
52
52
int width = rectangle . Width ;
53
53
int height = rectangle . Height ;
54
54
55
- int maxSteps = DivideCeil ( width * height , parallelSettings . MinimumPixelsProcessedPerTask ) ;
55
+ int maxSteps = DivideCeil ( width * ( long ) height , parallelSettings . MinimumPixelsProcessedPerTask ) ;
56
56
int numOfSteps = Math . Min ( parallelSettings . MaxDegreeOfParallelism , maxSteps ) ;
57
57
58
58
// Avoid TPL overhead in this trivial case:
@@ -117,7 +117,7 @@ public static void IterateRows<T, TBuffer>(
117
117
int width = rectangle . Width ;
118
118
int height = rectangle . Height ;
119
119
120
- int maxSteps = DivideCeil ( width * height , parallelSettings . MinimumPixelsProcessedPerTask ) ;
120
+ int maxSteps = DivideCeil ( width * ( long ) height , parallelSettings . MinimumPixelsProcessedPerTask ) ;
121
121
int numOfSteps = Math . Min ( parallelSettings . MaxDegreeOfParallelism , maxSteps ) ;
122
122
MemoryAllocator allocator = parallelSettings . MemoryAllocator ;
123
123
@@ -181,7 +181,7 @@ public static void IterateRowIntervals<T>(
181
181
int width = rectangle . Width ;
182
182
int height = rectangle . Height ;
183
183
184
- int maxSteps = DivideCeil ( width * height , parallelSettings . MinimumPixelsProcessedPerTask ) ;
184
+ int maxSteps = DivideCeil ( width * ( long ) height , parallelSettings . MinimumPixelsProcessedPerTask ) ;
185
185
int numOfSteps = Math . Min ( parallelSettings . MaxDegreeOfParallelism , maxSteps ) ;
186
186
187
187
// Avoid TPL overhead in this trivial case:
@@ -243,7 +243,7 @@ public static void IterateRowIntervals<T, TBuffer>(
243
243
int width = rectangle . Width ;
244
244
int height = rectangle . Height ;
245
245
246
- int maxSteps = DivideCeil ( width * height , parallelSettings . MinimumPixelsProcessedPerTask ) ;
246
+ int maxSteps = DivideCeil ( width * ( long ) height , parallelSettings . MinimumPixelsProcessedPerTask ) ;
247
247
int numOfSteps = Math . Min ( parallelSettings . MaxDegreeOfParallelism , maxSteps ) ;
248
248
MemoryAllocator allocator = parallelSettings . MemoryAllocator ;
249
249
@@ -270,7 +270,7 @@ public static void IterateRowIntervals<T, TBuffer>(
270
270
}
271
271
272
272
[ 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 ) ;
274
274
275
275
private static void ValidateRectangle ( Rectangle rectangle )
276
276
{
0 commit comments