@@ -83,6 +83,18 @@ public static void UndoRow(Span<byte> pixelBytes, int width, int y, TiffColorTyp
83
83
UndoGray16BitLittleEndianRow ( pixelBytes , width , y ) ;
84
84
}
85
85
86
+ break ;
87
+ case TiffColorType . BlackIsZero32 :
88
+ case TiffColorType . WhiteIsZero32 :
89
+ if ( isBigEndian )
90
+ {
91
+ UndoGray32BitBigEndianRow ( pixelBytes , width , y ) ;
92
+ }
93
+ else
94
+ {
95
+ UndoGray32BitLittleEndianRow ( pixelBytes , width , y ) ;
96
+ }
97
+
86
98
break ;
87
99
case TiffColorType . Rgb888 :
88
100
case TiffColorType . CieLab :
@@ -266,6 +278,46 @@ private static void UndoGray16Bit(Span<byte> pixelBytes, int width, bool isBigEn
266
278
}
267
279
}
268
280
281
+ private static void UndoGray32BitBigEndianRow ( Span < byte > pixelBytes , int width , int y )
282
+ {
283
+ int rowBytesCount = width * 4 ;
284
+ int height = pixelBytes . Length / rowBytesCount ;
285
+
286
+ int offset = 0 ;
287
+ Span < byte > rowBytes = pixelBytes . Slice ( y * rowBytesCount , rowBytesCount ) ;
288
+ uint pixelValue = TiffUtilities . ConvertToUIntBigEndian ( rowBytes . Slice ( offset , 4 ) ) ;
289
+ offset += 4 ;
290
+
291
+ for ( int x = 1 ; x < width ; x ++ )
292
+ {
293
+ Span < byte > rowSpan = rowBytes . Slice ( offset , 4 ) ;
294
+ uint diff = TiffUtilities . ConvertToUIntBigEndian ( rowSpan ) ;
295
+ pixelValue += diff ;
296
+ BinaryPrimitives . WriteUInt32BigEndian ( rowSpan , pixelValue ) ;
297
+ offset += 4 ;
298
+ }
299
+ }
300
+
301
+ private static void UndoGray32BitLittleEndianRow ( Span < byte > pixelBytes , int width , int y )
302
+ {
303
+ int rowBytesCount = width * 4 ;
304
+ int height = pixelBytes . Length / rowBytesCount ;
305
+
306
+ int offset = 0 ;
307
+ Span < byte > rowBytes = pixelBytes . Slice ( y * rowBytesCount , rowBytesCount ) ;
308
+ uint pixelValue = TiffUtilities . ConvertToUIntLittleEndian ( rowBytes . Slice ( offset , 4 ) ) ;
309
+ offset += 4 ;
310
+
311
+ for ( int x = 1 ; x < width ; x ++ )
312
+ {
313
+ Span < byte > rowSpan = rowBytes . Slice ( offset , 4 ) ;
314
+ uint diff = TiffUtilities . ConvertToUIntLittleEndian ( rowSpan ) ;
315
+ pixelValue += diff ;
316
+ BinaryPrimitives . WriteUInt32LittleEndian ( rowSpan , pixelValue ) ;
317
+ offset += 4 ;
318
+ }
319
+ }
320
+
269
321
private static void UndoGray32Bit ( Span < byte > pixelBytes , int width , bool isBigEndian )
270
322
{
271
323
int rowBytesCount = width * 4 ;
@@ -274,38 +326,14 @@ private static void UndoGray32Bit(Span<byte> pixelBytes, int width, bool isBigEn
274
326
{
275
327
for ( int y = 0 ; y < height ; y ++ )
276
328
{
277
- int offset = 0 ;
278
- Span < byte > rowBytes = pixelBytes . Slice ( y * rowBytesCount , rowBytesCount ) ;
279
- uint pixelValue = TiffUtilities . ConvertToUIntBigEndian ( rowBytes . Slice ( offset , 4 ) ) ;
280
- offset += 4 ;
281
-
282
- for ( int x = 1 ; x < width ; x ++ )
283
- {
284
- Span < byte > rowSpan = rowBytes . Slice ( offset , 4 ) ;
285
- uint diff = TiffUtilities . ConvertToUIntBigEndian ( rowSpan ) ;
286
- pixelValue += diff ;
287
- BinaryPrimitives . WriteUInt32BigEndian ( rowSpan , pixelValue ) ;
288
- offset += 4 ;
289
- }
329
+ UndoGray32BitBigEndianRow ( pixelBytes , width , y ) ;
290
330
}
291
331
}
292
332
else
293
333
{
294
334
for ( int y = 0 ; y < height ; y ++ )
295
335
{
296
- int offset = 0 ;
297
- Span < byte > rowBytes = pixelBytes . Slice ( y * rowBytesCount , rowBytesCount ) ;
298
- uint pixelValue = TiffUtilities . ConvertToUIntLittleEndian ( rowBytes . Slice ( offset , 4 ) ) ;
299
- offset += 4 ;
300
-
301
- for ( int x = 1 ; x < width ; x ++ )
302
- {
303
- Span < byte > rowSpan = rowBytes . Slice ( offset , 4 ) ;
304
- uint diff = TiffUtilities . ConvertToUIntLittleEndian ( rowSpan ) ;
305
- pixelValue += diff ;
306
- BinaryPrimitives . WriteUInt32LittleEndian ( rowSpan , pixelValue ) ;
307
- offset += 4 ;
308
- }
336
+ UndoGray32BitLittleEndianRow ( pixelBytes , width , y ) ;
309
337
}
310
338
}
311
339
}
0 commit comments