/// <summary>
 /// Checks whether the producer may be able to produce images of
 /// the specified size. This makes no promise about being able to
 /// produce images for a particular source, only generally being
 /// able to produce output of the desired resolution.
 ///
 /// <para />In this case, assumptions are made about the common
 /// size of EXIF thumbnails which is that they may be up to 512
 /// pixels in each dimension.
 /// </summary>
 /// <param name="resizeOptions">
 /// The resize options from the current request.
 /// </param>
 /// <returns>
 /// true if the producer can meet these needs.
 /// </returns>
 public bool CanProvideImageForSize(ResizeOptions resizeOptions)
 {
     return(ThumbnailSizeChecker.IsImageBigEnough(
                COMMON_EXIF_THUMBNAIL_MAX_DIMENSION,
                COMMON_EXIF_THUMBNAIL_MAX_DIMENSION,
                resizeOptions));
 }
Exemplo n.º 2
0
            protected override void OnNewResultImpl(EncodedImage newResult, bool isLast)
            {
                ImageRequest request      = _producerContext.ImageRequest;
                bool         isGoodEnough =
                    ThumbnailSizeChecker.IsImageBigEnough(newResult, request.ResizeOptions);

                if (newResult != null && (isGoodEnough || request.IsLocalThumbnailPreviewsEnabled))
                {
                    Consumer.OnNewResult(newResult, isLast && isGoodEnough);
                }

                if (isLast && !isGoodEnough)
                {
                    EncodedImage.CloseSafely(newResult);

                    _inputProducer2.ProduceResults(Consumer, _producerContext);
                }
            }
            protected override void OnNewResultImpl(EncodedImage newResult, bool isLast)
            {
                if (newResult != null &&
                    (!isLast || ThumbnailSizeChecker.IsImageBigEnough(newResult, _resizeOptions)))
                {
                    Consumer.OnNewResult(newResult, isLast);
                }
                else if (isLast)
                {
                    EncodedImage.CloseSafely(newResult);

                    bool fallback = _parent.ProduceResultsFromThumbnailProducer(
                        _producerIndex + 1,
                        Consumer,
                        _producerContext);

                    if (!fallback)
                    {
                        Consumer.OnNewResult(null, true);
                    }
                }
            }