@@ -41,7 +41,7 @@ public static void ProcessInterlacedGrayscaleScanline<TPixel>(
41
41
Color ? transparentColor )
42
42
where TPixel : unmanaged, IPixel < TPixel >
43
43
{
44
- uint offset = pixelOffset + ( uint ) frameControl . XOffset ;
44
+ uint offset = pixelOffset + frameControl . XOffset ;
45
45
TPixel pixel = default ;
46
46
ref byte scanlineSpanRef = ref MemoryMarshal . GetReference ( scanlineSpan ) ;
47
47
ref TPixel rowSpanRef = ref MemoryMarshal . GetReference ( rowSpan ) ;
@@ -132,7 +132,7 @@ public static void ProcessInterlacedGrayscaleWithAlphaScanline<TPixel>(
132
132
uint bytesPerSample )
133
133
where TPixel : unmanaged, IPixel < TPixel >
134
134
{
135
- uint offset = pixelOffset + ( uint ) frameControl . XOffset ;
135
+ uint offset = pixelOffset + frameControl . XOffset ;
136
136
TPixel pixel = default ;
137
137
ref byte scanlineSpanRef = ref MemoryMarshal . GetReference ( scanlineSpan ) ;
138
138
ref TPixel rowSpanRef = ref MemoryMarshal . GetReference ( rowSpan ) ;
@@ -242,7 +242,7 @@ public static void ProcessInterlacedRgbScanline<TPixel>(
242
242
Color ? transparentColor )
243
243
where TPixel : unmanaged, IPixel < TPixel >
244
244
{
245
- uint offset = pixelOffset + ( uint ) frameControl . XOffset ;
245
+ uint offset = pixelOffset + frameControl . XOffset ;
246
246
247
247
TPixel pixel = default ;
248
248
ref byte scanlineSpanRef = ref MemoryMarshal . GetReference ( scanlineSpan ) ;
@@ -266,20 +266,18 @@ public static void ProcessInterlacedRgbScanline<TPixel>(
266
266
}
267
267
else
268
268
{
269
- // Rgb24 rgb = default;
270
- // int o = 0;
271
- // for (nuint x = offset; x < frameControl.XLimit; x += increment, o += bytesPerPixel)
272
- // {
273
- // rgb.R = Unsafe.Add(ref scanlineSpanRef, (uint)o);
274
- // rgb.G = Unsafe.Add(ref scanlineSpanRef, (uint)(o + bytesPerSample));
275
- // rgb.B = Unsafe.Add(ref scanlineSpanRef, (uint)(o + (2 * bytesPerSample)));
276
-
277
- // pixel.FromRgb24(rgb);
278
- // Unsafe.Add(ref rowSpanRef, x) = pixel;
279
- // }
280
-
281
- // PixelOperations<TPixel>.Instance.FromRgb24Bytes(configuration, scanlineSpan, rowSpan, header.Width);
282
- PixelOperations < TPixel > . Instance . FromRgb24Bytes ( configuration , scanlineSpan , rowSpan [ ( int ) offset ..] , ( int ) frameControl . XMax ) ;
269
+ // TODO: Investigate reintroducing bulk operations optimization here.
270
+ Rgb24 rgb = default ;
271
+ int o = 0 ;
272
+ for ( nuint x = offset ; x < frameControl . XMax ; x += increment , o += bytesPerPixel )
273
+ {
274
+ rgb . R = Unsafe . Add ( ref scanlineSpanRef , ( uint ) o ) ;
275
+ rgb . G = Unsafe . Add ( ref scanlineSpanRef , ( uint ) ( o + bytesPerSample ) ) ;
276
+ rgb . B = Unsafe . Add ( ref scanlineSpanRef , ( uint ) ( o + ( 2 * bytesPerSample ) ) ) ;
277
+
278
+ pixel . FromRgb24 ( rgb ) ;
279
+ Unsafe . Add ( ref rowSpanRef , x ) = pixel;
280
+ }
283
281
}
284
282
285
283
return ;
@@ -325,7 +323,6 @@ public static void ProcessInterlacedRgbScanline<TPixel>(
325
323
}
326
324
327
325
public static void ProcessRgbaScanline < TPixel > (
328
- Configuration configuration ,
329
326
int bitDepth ,
330
327
in FrameControl frameControl ,
331
328
ReadOnlySpan < byte > scanlineSpan ,
@@ -334,7 +331,6 @@ public static void ProcessRgbaScanline<TPixel>(
334
331
int bytesPerSample )
335
332
where TPixel : unmanaged, IPixel < TPixel > =>
336
333
ProcessInterlacedRgbaScanline (
337
- configuration ,
338
334
bitDepth ,
339
335
frameControl ,
340
336
scanlineSpan ,
@@ -345,7 +341,6 @@ public static void ProcessRgbaScanline<TPixel>(
345
341
bytesPerSample ) ;
346
342
347
343
public static void ProcessInterlacedRgbaScanline < TPixel > (
348
- Configuration configuration ,
349
344
int bitDepth ,
350
345
in FrameControl frameControl ,
351
346
ReadOnlySpan < byte > scanlineSpan ,
@@ -356,7 +351,7 @@ public static void ProcessInterlacedRgbaScanline<TPixel>(
356
351
int bytesPerSample )
357
352
where TPixel : unmanaged, IPixel < TPixel >
358
353
{
359
- uint offset = pixelOffset + ( uint ) frameControl . XOffset ;
354
+ uint offset = pixelOffset + frameControl . XOffset ;
360
355
TPixel pixel = default ;
361
356
ref TPixel rowSpanRef = ref MemoryMarshal . GetReference ( rowSpan ) ;
362
357
@@ -377,22 +372,20 @@ public static void ProcessInterlacedRgbaScanline<TPixel>(
377
372
}
378
373
else
379
374
{
380
- // ref byte scanlineSpanRef = ref MemoryMarshal.GetReference(scanlineSpan);
381
- // Rgba32 rgba = default;
382
- // int o = 0;
383
- // for (nuint x = offset; x < frameControl.XLimit; x += increment, o += bytesPerPixel)
384
- // {
385
- // rgba.R = Unsafe.Add(ref scanlineSpanRef, (uint)o);
386
- // rgba.G = Unsafe.Add(ref scanlineSpanRef, (uint)(o + bytesPerSample));
387
- // rgba.B = Unsafe.Add(ref scanlineSpanRef, (uint)(o + (2 * bytesPerSample)));
388
- // rgba.A = Unsafe.Add(ref scanlineSpanRef, (uint)(o + (3 * bytesPerSample)));
389
-
390
- // pixel.FromRgba32(rgba);
391
- // Unsafe.Add(ref rowSpanRef, x) = pixel;
392
- // }
393
-
394
- // PixelOperations<TPixel>.Instance.FromRgba32Bytes(configuration, scanlineSpan, rowSpan, header.Width);
395
- PixelOperations < TPixel > . Instance . FromRgba32Bytes ( configuration , scanlineSpan , rowSpan [ ( int ) offset ..] , ( int ) frameControl . XMax ) ;
375
+ // TODO: Investigate reintroducing bulk operations optimization here.
376
+ ref byte scanlineSpanRef = ref MemoryMarshal . GetReference ( scanlineSpan ) ;
377
+ Rgba32 rgba = default ;
378
+ int o = 0 ;
379
+ for ( nuint x = offset ; x < frameControl . XMax ; x += increment , o += bytesPerPixel )
380
+ {
381
+ rgba . R = Unsafe . Add ( ref scanlineSpanRef , ( uint ) o ) ;
382
+ rgba . G = Unsafe . Add ( ref scanlineSpanRef , ( uint ) ( o + bytesPerSample ) ) ;
383
+ rgba . B = Unsafe . Add ( ref scanlineSpanRef , ( uint ) ( o + ( 2 * bytesPerSample ) ) ) ;
384
+ rgba . A = Unsafe . Add ( ref scanlineSpanRef , ( uint ) ( o + ( 3 * bytesPerSample ) ) ) ;
385
+
386
+ pixel . FromRgba32 ( rgba ) ;
387
+ Unsafe . Add ( ref rowSpanRef , x ) = pixel;
388
+ }
396
389
}
397
390
}
398
391
}
0 commit comments