@@ -108,14 +108,7 @@ public void Encode<TPixel>(Image<TPixel> image, Stream stream, CancellationToken
108
108
109
109
// Write scans with actual pixel data
110
110
using SpectralConverter < TPixel > spectralConverter = new ( frame , image , this . QuantizationTables ) ;
111
- if ( this . encoder . Progressive )
112
- {
113
- this . WriteProgressiveScans ( frame , frameConfig , spectralConverter , scanEncoder , buffer , cancellationToken ) ;
114
- }
115
- else
116
- {
117
- this . WriteHuffmanScans ( frame , frameConfig , spectralConverter , scanEncoder , buffer , cancellationToken ) ;
118
- }
111
+ this . WriteHuffmanScans ( frame , frameConfig , spectralConverter , scanEncoder , buffer , cancellationToken ) ;
119
112
120
113
// Write the End Of Image marker.
121
114
this . WriteEndOfImageMarker ( buffer ) ;
@@ -690,7 +683,14 @@ private void WriteHuffmanScans<TPixel>(
690
683
CancellationToken cancellationToken )
691
684
where TPixel : unmanaged, IPixel < TPixel >
692
685
{
693
- if ( frame . Components . Length == 1 )
686
+ if ( this . encoder . Progressive )
687
+ {
688
+ frame . AllocateComponents ( fullScan : true ) ;
689
+ spectralConverter . ConvertFull ( ) ;
690
+
691
+ this . WriteProgressiveScans < TPixel > ( frame , frameConfig , encoder , buffer , cancellationToken ) ;
692
+ }
693
+ else if ( frame . Components . Length == 1 )
694
694
{
695
695
frame . AllocateComponents ( fullScan : false ) ;
696
696
@@ -724,22 +724,17 @@ private void WriteHuffmanScans<TPixel>(
724
724
/// <typeparam name="TPixel">The type of pixel format.</typeparam>
725
725
/// <param name="frame">The current frame.</param>
726
726
/// <param name="frameConfig">The frame configuration.</param>
727
- /// <param name="spectralConverter">The spectral converter.</param>
728
727
/// <param name="encoder">The scan encoder.</param>
729
728
/// <param name="buffer">Temporary buffer.</param>
730
729
/// <param name="cancellationToken">The cancellation token.</param>
731
730
private void WriteProgressiveScans < TPixel > (
732
731
JpegFrame frame ,
733
732
JpegFrameConfig frameConfig ,
734
- SpectralConverter < TPixel > spectralConverter ,
735
733
HuffmanScanEncoder encoder ,
736
734
Span < byte > buffer ,
737
735
CancellationToken cancellationToken )
738
736
where TPixel : unmanaged, IPixel < TPixel >
739
737
{
740
- frame . AllocateComponents ( fullScan : true ) ;
741
- spectralConverter . ConvertFull ( ) ;
742
-
743
738
Span < JpegComponentConfig > components = frameConfig . Components ;
744
739
745
740
// Phase 1: DC scan
0 commit comments