@@ -53,11 +53,12 @@ internal sealed class GifEncoderCore
5353 /// <summary>
5454 /// Initializes a new instance of the <see cref="GifEncoderCore"/> class.
5555 /// </summary>
56- /// <param name="memoryAllocator ">The <see cref="MemoryAllocator"/> to use for buffer allocations .</param>
56+ /// <param name="configuration ">The configuration which allows altering default behaviour or extending the library .</param>
5757 /// <param name="options">The options for the encoder.</param>
58- public GifEncoderCore ( MemoryAllocator memoryAllocator , IGifEncoderOptions options )
58+ public GifEncoderCore ( Configuration configuration , IGifEncoderOptions options )
5959 {
60- this . memoryAllocator = memoryAllocator ;
60+ this . configuration = configuration ;
61+ this . memoryAllocator = configuration . MemoryAllocator ;
6162 this . quantizer = options . Quantizer ;
6263 this . colorTableMode = options . ColorTableMode ;
6364 }
@@ -74,16 +75,14 @@ public void Encode<TPixel>(Image<TPixel> image, Stream stream)
7475 Guard . NotNull ( image , nameof ( image ) ) ;
7576 Guard . NotNull ( stream , nameof ( stream ) ) ;
7677
77- this . configuration = image . GetConfiguration ( ) ;
78-
7978 ImageMetadata metadata = image . Metadata ;
8079 GifMetadata gifMetadata = metadata . GetGifMetadata ( ) ;
81- this . colorTableMode = this . colorTableMode ?? gifMetadata . ColorTableMode ;
80+ this . colorTableMode ??= gifMetadata . ColorTableMode ;
8281 bool useGlobalTable = this . colorTableMode == GifColorTableMode . Global ;
8382
8483 // Quantize the image returning a palette.
8584 IQuantizedFrame < TPixel > quantized ;
86- using ( IFrameQuantizer < TPixel > frameQuantizer = this . quantizer . CreateFrameQuantizer < TPixel > ( image . GetConfiguration ( ) ) )
85+ using ( IFrameQuantizer < TPixel > frameQuantizer = this . quantizer . CreateFrameQuantizer < TPixel > ( this . configuration ) )
8786 {
8887 quantized = frameQuantizer . QuantizeFrame ( image . Frames . RootFrame ) ;
8988 }
@@ -146,7 +145,7 @@ private void EncodeGlobal<TPixel>(Image<TPixel> image, IQuantizedFrame<TPixel> q
146145 else
147146 {
148147 using ( IFrameQuantizer < TPixel > paletteFrameQuantizer =
149- new PaletteFrameQuantizer < TPixel > ( this . quantizer . Diffuser , quantized . Palette ) )
148+ new PaletteFrameQuantizer < TPixel > ( this . configuration , this . quantizer . Diffuser , quantized . Palette ) )
150149 {
151150 using ( IQuantizedFrame < TPixel > paletteQuantized = paletteFrameQuantizer . QuantizeFrame ( frame ) )
152151 {
@@ -172,14 +171,14 @@ private void EncodeLocal<TPixel>(Image<TPixel> image, IQuantizedFrame<TPixel> qu
172171 if ( previousFrame != null && previousMeta . ColorTableLength != frameMetadata . ColorTableLength
173172 && frameMetadata . ColorTableLength > 0 )
174173 {
175- using ( IFrameQuantizer < TPixel > frameQuantizer = this . quantizer . CreateFrameQuantizer < TPixel > ( image . GetConfiguration ( ) , frameMetadata . ColorTableLength ) )
174+ using ( IFrameQuantizer < TPixel > frameQuantizer = this . quantizer . CreateFrameQuantizer < TPixel > ( this . configuration , frameMetadata . ColorTableLength ) )
176175 {
177176 quantized = frameQuantizer . QuantizeFrame ( frame ) ;
178177 }
179178 }
180179 else
181180 {
182- using ( IFrameQuantizer < TPixel > frameQuantizer = this . quantizer . CreateFrameQuantizer < TPixel > ( image . GetConfiguration ( ) ) )
181+ using ( IFrameQuantizer < TPixel > frameQuantizer = this . quantizer . CreateFrameQuantizer < TPixel > ( this . configuration ) )
183182 {
184183 quantized = frameQuantizer . QuantizeFrame ( frame ) ;
185184 }
@@ -202,9 +201,7 @@ private void EncodeLocal<TPixel>(Image<TPixel> image, IQuantizedFrame<TPixel> qu
202201 /// <summary>
203202 /// Returns the index of the most transparent color in the palette.
204203 /// </summary>
205- /// <param name="quantized">
206- /// The quantized.
207- /// </param>
204+ /// <param name="quantized">The quantized frame.</param>
208205 /// <typeparam name="TPixel">The pixel format.</typeparam>
209206 /// <returns>
210207 /// The <see cref="int"/>.
0 commit comments