@@ -159,7 +159,7 @@ public void Encode<TPixel>(Image<TPixel> image, Stream stream, CancellationToken
159
159
160
160
WriteBitmapFileHeader ( stream , infoHeaderSize , colorPaletteSize , iccProfileSize , infoHeader , buffer ) ;
161
161
this . WriteBitmapInfoHeader ( stream , infoHeader , buffer , infoHeaderSize ) ;
162
- this . WriteImage ( stream , image , configuration ) ;
162
+ this . WriteImage ( configuration , stream , image ) ;
163
163
WriteColorProfile ( stream , iccProfileData , buffer ) ;
164
164
165
165
stream . Flush ( ) ;
@@ -307,43 +307,43 @@ private void WriteBitmapInfoHeader(Stream stream, BmpInfoHeader infoHeader, Span
307
307
/// Writes the pixel data to the binary stream.
308
308
/// </summary>
309
309
/// <typeparam name="TPixel">The pixel format.</typeparam>
310
+ /// <param name="configuration">The global configuration.</param>
310
311
/// <param name="stream">The <see cref="Stream"/> to write to.</param>
311
312
/// <param name="image">
312
313
/// The <see cref="ImageFrame{TPixel}"/> containing pixel data.
313
314
/// </param>
314
- /// <param name="configuration">The global configuration.</param>
315
- private void WriteImage < TPixel > ( Stream stream , Image < TPixel > image , Configuration configuration )
315
+ private void WriteImage < TPixel > ( Configuration configuration , Stream stream , Image < TPixel > image )
316
316
where TPixel : unmanaged, IPixel < TPixel >
317
317
{
318
318
Buffer2D < TPixel > pixels = image . Frames . RootFrame . PixelBuffer ;
319
319
switch ( this . bitsPerPixel )
320
320
{
321
321
case BmpBitsPerPixel . Pixel32 :
322
- this . Write32BitPixelData ( stream , pixels , configuration ) ;
322
+ this . Write32BitPixelData ( configuration , stream , pixels ) ;
323
323
break ;
324
324
325
325
case BmpBitsPerPixel . Pixel24 :
326
- this . Write24BitPixelData ( stream , pixels , configuration ) ;
326
+ this . Write24BitPixelData ( configuration , stream , pixels ) ;
327
327
break ;
328
328
329
329
case BmpBitsPerPixel . Pixel16 :
330
- this . Write16BitPixelData ( stream , pixels , configuration ) ;
330
+ this . Write16BitPixelData ( configuration , stream , pixels ) ;
331
331
break ;
332
332
333
333
case BmpBitsPerPixel . Pixel8 :
334
- this . Write8BitPixelData ( stream , image , configuration ) ;
334
+ this . Write8BitPixelData ( configuration , stream , image ) ;
335
335
break ;
336
336
337
337
case BmpBitsPerPixel . Pixel4 :
338
- this . Write4BitPixelData ( stream , image , configuration ) ;
338
+ this . Write4BitPixelData ( configuration , stream , image ) ;
339
339
break ;
340
340
341
341
case BmpBitsPerPixel . Pixel2 :
342
- this . Write2BitPixelData ( stream , image , configuration ) ;
342
+ this . Write2BitPixelData ( configuration , stream , image ) ;
343
343
break ;
344
344
345
345
case BmpBitsPerPixel . Pixel1 :
346
- this . Write1BitPixelData ( stream , image , configuration ) ;
346
+ this . Write1BitPixelData ( configuration , stream , image ) ;
347
347
break ;
348
348
}
349
349
}
@@ -355,10 +355,10 @@ private IMemoryOwner<byte> AllocateRow(int width, int bytesPerPixel)
355
355
/// Writes 32-bit data with a color palette to the stream.
356
356
/// </summary>
357
357
/// <typeparam name="TPixel">The pixel format.</typeparam>
358
+ /// <param name="configuration">The global configuration.</param>
358
359
/// <param name="stream">The <see cref="Stream"/> to write to.</param>
359
360
/// <param name="pixels">The <see cref="Buffer2D{TPixel}"/> containing pixel data.</param>
360
- /// <param name="configuration">The global configuration.</param>
361
- private void Write32BitPixelData < TPixel > ( Stream stream , Buffer2D < TPixel > pixels , Configuration configuration )
361
+ private void Write32BitPixelData < TPixel > ( Configuration configuration , Stream stream , Buffer2D < TPixel > pixels )
362
362
where TPixel : unmanaged, IPixel < TPixel >
363
363
{
364
364
using IMemoryOwner < byte > row = this . AllocateRow ( pixels . Width , 4 ) ;
@@ -380,10 +380,10 @@ private void Write32BitPixelData<TPixel>(Stream stream, Buffer2D<TPixel> pixels,
380
380
/// Writes 24-bit pixel data with a color palette to the stream.
381
381
/// </summary>
382
382
/// <typeparam name="TPixel">The pixel format.</typeparam>
383
+ /// <param name="configuration">The global configuration.</param>
383
384
/// <param name="stream">The <see cref="Stream"/> to write to.</param>
384
385
/// <param name="pixels">The <see cref="Buffer2D{TPixel}"/> containing pixel data.</param>
385
- /// <param name="configuration">The global configuration.</param>
386
- private void Write24BitPixelData < TPixel > ( Stream stream , Buffer2D < TPixel > pixels , Configuration configuration )
386
+ private void Write24BitPixelData < TPixel > ( Configuration configuration , Stream stream , Buffer2D < TPixel > pixels )
387
387
where TPixel : unmanaged, IPixel < TPixel >
388
388
{
389
389
int width = pixels . Width ;
@@ -407,11 +407,11 @@ private void Write24BitPixelData<TPixel>(Stream stream, Buffer2D<TPixel> pixels,
407
407
/// Writes 16-bit pixel data with a color palette to the stream.
408
408
/// </summary>
409
409
/// <typeparam name="TPixel">The type of the pixel.</typeparam>
410
+ /// <param name="configuration">The global configuration.</param>
410
411
/// <param name="stream">The <see cref="Stream"/> to write to.</param>
411
412
/// <param name="pixels">The <see cref="Buffer2D{TPixel}"/> containing pixel data.</param>
412
- /// <param name="configuration">The global configuration.</param>
413
- private void Write16BitPixelData < TPixel > ( Stream stream , Buffer2D < TPixel > pixels , Configuration configuration )
414
- where TPixel : unmanaged, IPixel < TPixel >
413
+ private void Write16BitPixelData < TPixel > ( Configuration configuration , Stream stream , Buffer2D < TPixel > pixels )
414
+ where TPixel : unmanaged, IPixel < TPixel >
415
415
{
416
416
int width = pixels . Width ;
417
417
int rowBytesWithoutPadding = width * 2 ;
@@ -436,10 +436,10 @@ private void Write16BitPixelData<TPixel>(Stream stream, Buffer2D<TPixel> pixels,
436
436
/// Writes 8 bit pixel data with a color palette. The color palette has 256 entry's with 4 bytes for each entry.
437
437
/// </summary>
438
438
/// <typeparam name="TPixel">The type of the pixel.</typeparam>
439
+ /// <param name="configuration">The global configuration.</param>
439
440
/// <param name="stream">The <see cref="Stream"/> to write to.</param>
440
441
/// <param name="image"> The <see cref="Image{TPixel}"/> containing pixel data.</param>
441
- /// <param name="configuration">The global configuration.</param>
442
- private void Write8BitPixelData < TPixel > ( Stream stream , Image < TPixel > image , Configuration configuration )
442
+ private void Write8BitPixelData < TPixel > ( Configuration configuration , Stream stream , Image < TPixel > image )
443
443
where TPixel : unmanaged, IPixel < TPixel >
444
444
{
445
445
bool isL8 = typeof ( TPixel ) == typeof ( L8 ) ;
@@ -452,19 +452,19 @@ private void Write8BitPixelData<TPixel>(Stream stream, Image<TPixel> image, Conf
452
452
}
453
453
else
454
454
{
455
- this . Write8BitColor ( stream , image , colorPalette , configuration ) ;
455
+ this . Write8BitColor ( configuration , stream , image , colorPalette ) ;
456
456
}
457
457
}
458
458
459
459
/// <summary>
460
460
/// Writes an 8 bit color image with a color palette. The color palette has 256 entry's with 4 bytes for each entry.
461
461
/// </summary>
462
462
/// <typeparam name="TPixel">The type of the pixel.</typeparam>
463
+ /// <param name="configuration">The global configuration.</param>
463
464
/// <param name="stream">The <see cref="Stream"/> to write to.</param>
464
465
/// <param name="image"> The <see cref="Image{TPixel}"/> containing pixel data.</param>
465
466
/// <param name="colorPalette">A byte span of size 1024 for the color palette.</param>
466
- /// <param name="configuration">The global configuration</param>
467
- private void Write8BitColor < TPixel > ( Stream stream , Image < TPixel > image , Span < byte > colorPalette , Configuration configuration )
467
+ private void Write8BitColor < TPixel > ( Configuration configuration , Stream stream , Image < TPixel > image , Span < byte > colorPalette )
468
468
where TPixel : unmanaged, IPixel < TPixel >
469
469
{
470
470
using IQuantizer < TPixel > frameQuantizer = this . quantizer . CreatePixelSpecificQuantizer < TPixel > ( configuration ) ;
@@ -473,7 +473,7 @@ private void Write8BitColor<TPixel>(Stream stream, Image<TPixel> image, Span<byt
473
473
using IndexedImageFrame < TPixel > quantized = frameQuantizer . QuantizeFrame ( image . Frames . RootFrame , image . Bounds ) ;
474
474
475
475
ReadOnlySpan < TPixel > quantizedColorPalette = quantized . Palette . Span ;
476
- WriteColorPalette ( stream , quantizedColorPalette , colorPalette , configuration ) ;
476
+ WriteColorPalette ( configuration , stream , quantizedColorPalette , colorPalette ) ;
477
477
478
478
for ( int y = image . Height - 1 ; y >= 0 ; y -- )
479
479
{
@@ -529,10 +529,10 @@ private void Write8BitPixelData<TPixel>(Stream stream, Image<TPixel> image, Span
529
529
/// Writes 4 bit pixel data with a color palette. The color palette has 16 entry's with 4 bytes for each entry.
530
530
/// </summary>
531
531
/// <typeparam name="TPixel">The type of the pixel.</typeparam>
532
+ /// <param name="configuration">The global configuration.</param>
532
533
/// <param name="stream">The <see cref="Stream"/> to write to.</param>
533
534
/// <param name="image"> The <see cref="ImageFrame{TPixel}"/> containing pixel data.</param>
534
- /// <param name="configuration">The global configuration.</param>
535
- private void Write4BitPixelData < TPixel > ( Stream stream , Image < TPixel > image , Configuration configuration )
535
+ private void Write4BitPixelData < TPixel > ( Configuration configuration , Stream stream , Image < TPixel > image )
536
536
where TPixel : unmanaged, IPixel < TPixel >
537
537
{
538
538
using IQuantizer < TPixel > frameQuantizer = this . quantizer . CreatePixelSpecificQuantizer < TPixel > ( configuration , new QuantizerOptions ( )
@@ -547,7 +547,7 @@ private void Write4BitPixelData<TPixel>(Stream stream, Image<TPixel> image, Conf
547
547
548
548
Span < byte > colorPalette = colorPaletteBuffer . GetSpan ( ) ;
549
549
ReadOnlySpan < TPixel > quantizedColorPalette = quantized . Palette . Span ;
550
- WriteColorPalette ( stream , quantizedColorPalette , colorPalette , configuration ) ;
550
+ WriteColorPalette ( configuration , stream , quantizedColorPalette , colorPalette ) ;
551
551
552
552
ReadOnlySpan < byte > pixelRowSpan = quantized . DangerousGetRowSpan ( 0 ) ;
553
553
int rowPadding = pixelRowSpan . Length % 2 != 0 ? this . padding - 1 : this . padding ;
@@ -577,10 +577,10 @@ private void Write4BitPixelData<TPixel>(Stream stream, Image<TPixel> image, Conf
577
577
/// Writes 2 bit pixel data with a color palette. The color palette has 4 entry's with 4 bytes for each entry.
578
578
/// </summary>
579
579
/// <typeparam name="TPixel">The type of the pixel.</typeparam>
580
+ /// <param name="configuration">The global configuration.</param>
580
581
/// <param name="stream">The <see cref="Stream"/> to write to.</param>
581
582
/// <param name="image"> The <see cref="ImageFrame{TPixel}"/> containing pixel data.</param>
582
- /// <param name="configuration">The global configuration</param>
583
- private void Write2BitPixelData < TPixel > ( Stream stream , Image < TPixel > image , Configuration configuration )
583
+ private void Write2BitPixelData < TPixel > ( Configuration configuration , Stream stream , Image < TPixel > image )
584
584
where TPixel : unmanaged, IPixel < TPixel >
585
585
{
586
586
using IQuantizer < TPixel > frameQuantizer = this . quantizer . CreatePixelSpecificQuantizer < TPixel > ( configuration , new QuantizerOptions ( )
@@ -595,7 +595,7 @@ private void Write2BitPixelData<TPixel>(Stream stream, Image<TPixel> image, Conf
595
595
596
596
Span < byte > colorPalette = colorPaletteBuffer . GetSpan ( ) ;
597
597
ReadOnlySpan < TPixel > quantizedColorPalette = quantized . Palette . Span ;
598
- WriteColorPalette ( stream , quantizedColorPalette , colorPalette , configuration ) ;
598
+ WriteColorPalette ( configuration , stream , quantizedColorPalette , colorPalette ) ;
599
599
600
600
ReadOnlySpan < byte > pixelRowSpan = quantized . DangerousGetRowSpan ( 0 ) ;
601
601
int rowPadding = pixelRowSpan . Length % 4 != 0 ? this . padding - 1 : this . padding ;
@@ -634,10 +634,10 @@ private void Write2BitPixelData<TPixel>(Stream stream, Image<TPixel> image, Conf
634
634
/// Writes 1 bit pixel data with a color palette. The color palette has 2 entry's with 4 bytes for each entry.
635
635
/// </summary>
636
636
/// <typeparam name="TPixel">The type of the pixel.</typeparam>
637
+ /// <param name="configuration">The global configuration.</param>
637
638
/// <param name="stream">The <see cref="Stream"/> to write to.</param>
638
639
/// <param name="image"> The <see cref="ImageFrame{TPixel}"/> containing pixel data.</param>
639
- /// <param name="configuration">The global configuration</param>
640
- private void Write1BitPixelData < TPixel > ( Stream stream , Image < TPixel > image , Configuration configuration )
640
+ private void Write1BitPixelData < TPixel > ( Configuration configuration , Stream stream , Image < TPixel > image )
641
641
where TPixel : unmanaged, IPixel < TPixel >
642
642
{
643
643
using IQuantizer < TPixel > frameQuantizer = this . quantizer . CreatePixelSpecificQuantizer < TPixel > ( configuration , new QuantizerOptions ( )
@@ -652,7 +652,7 @@ private void Write1BitPixelData<TPixel>(Stream stream, Image<TPixel> image, Conf
652
652
653
653
Span < byte > colorPalette = colorPaletteBuffer . GetSpan ( ) ;
654
654
ReadOnlySpan < TPixel > quantizedColorPalette = quantized . Palette . Span ;
655
- WriteColorPalette ( stream , quantizedColorPalette , colorPalette , configuration ) ;
655
+ WriteColorPalette ( configuration , stream , quantizedColorPalette , colorPalette ) ;
656
656
657
657
ReadOnlySpan < byte > quantizedPixelRow = quantized . DangerousGetRowSpan ( 0 ) ;
658
658
int rowPadding = quantizedPixelRow . Length % 8 != 0 ? this . padding - 1 : this . padding ;
@@ -684,11 +684,11 @@ private void Write1BitPixelData<TPixel>(Stream stream, Image<TPixel> image, Conf
684
684
/// Writes the color palette to the stream. The color palette has 4 bytes for each entry.
685
685
/// </summary>
686
686
/// <typeparam name="TPixel">The type of the pixel.</typeparam>
687
+ /// <param name="configuration">The global configuration.</param>
687
688
/// <param name="stream">The <see cref="Stream"/> to write to.</param>
688
689
/// <param name="quantizedColorPalette">The color palette from the quantized image.</param>
689
690
/// <param name="colorPalette">A temporary byte span to write the color palette to.</param>
690
- /// <param name="configuration">The global configuration</param>
691
- private static void WriteColorPalette < TPixel > ( Stream stream , ReadOnlySpan < TPixel > quantizedColorPalette , Span < byte > colorPalette , Configuration configuration )
691
+ private static void WriteColorPalette < TPixel > ( Configuration configuration , Stream stream , ReadOnlySpan < TPixel > quantizedColorPalette , Span < byte > colorPalette )
692
692
where TPixel : unmanaged, IPixel < TPixel >
693
693
{
694
694
int quantizedColorBytes = quantizedColorPalette . Length * 4 ;
0 commit comments