public LocalImagesProgressiveDecoder(
     DecodeProducer parent,
     IConsumer <CloseableReference <CloseableImage> > consumer,
     IProducerContext producerContext) : base(
         parent,
         consumer,
         producerContext)
 {
 }
 public NetworkImagesProgressiveDecoder(
     DecodeProducer parent,
     IConsumer <CloseableReference <CloseableImage> > consumer,
     IProducerContext producerContext,
     ProgressiveJpegParser progressiveJpegParser,
     IProgressiveJpegConfig progressiveJpegConfig) : base(
         parent,
         consumer,
         producerContext)
 {
     _progressiveJpegParser   = Preconditions.CheckNotNull(progressiveJpegParser);
     _progressiveJpegConfig   = Preconditions.CheckNotNull(progressiveJpegConfig);
     _lastScheduledScanNumber = 0;
 }
            /// <summary>
            /// Instantiates the <see cref="ProgressiveDecoder"/>.
            /// </summary>
            public ProgressiveDecoder(
                DecodeProducer parent,
                IConsumer <CloseableReference <CloseableImage> > consumer,
                IProducerContext producerContext) :
                base(consumer)
            {
                _parent             = parent;
                _producerContext    = producerContext;
                _producerListener   = producerContext.Listener;
                _imageDecodeOptions = producerContext.ImageRequest.ImageDecodeOptions;
                _isFinished         = false;
                Func <EncodedImage, bool, Task> job = (encodedImage, isLast) =>
                {
                    if (encodedImage != null)
                    {
                        if (_parent._downsampleEnabled)
                        {
                            ImageRequest request = producerContext.ImageRequest;
                            if (_parent._downsampleEnabledForNetwork ||
                                !UriUtil.IsNetworkUri(request.SourceUri))
                            {
                                encodedImage.SampleSize = DownsampleUtil.DetermineSampleSize(
                                    request, encodedImage);
                            }
                        }

                        return(DoDecode(encodedImage, isLast));
                    }

                    return(Task.CompletedTask);
                };

                _jobScheduler = new JobScheduler(
                    _parent._executor, job, _imageDecodeOptions.MinDecodeIntervalMs);

                _producerContext.AddCallbacks(
                    new BaseProducerContextCallbacks(
                        () => { },
                        () => { },
                        () =>
                {
                    if (_producerContext.IsIntermediateResultExpected)
                    {
                        _jobScheduler.ScheduleJob();
                    }
                },
                        () => { }));
            }