Exemplo n.º 1
0
        internal virtual void Put(FilteredImagesCache.FilteredImageKey imageKey, PdfImageXObject filteredImage)
        {
            if (imageKey.GetCleanedAreas() == null || imageKey.GetCleanedAreas().IsEmpty())
            {
                return;
            }
            IList <FilteredImagesCache.FilteredImageKey> filteredImageKeys = cache.Get(imageKey.GetImageIndRef());

            if (filteredImageKeys == null)
            {
                cache.Put(imageKey.GetImageIndRef(), filteredImageKeys = new List <FilteredImagesCache.FilteredImageKey>());
            }
            filteredImageKeys.Add(imageKey);
            imageKey.SetFilteredImage(filteredImage);
        }
Exemplo n.º 2
0
        /// <summary>Retrieves saved result of image filtering based on given set of cleaning areas.</summary>
        /// <remarks>
        /// Retrieves saved result of image filtering based on given set of cleaning areas.
        /// This won't handle the case when same filtering result is produced by different sets of areas,
        /// e.g. if one set is { (0, 0, 50, 100), (50, 0, 50, 100)} and another one is {(0, 0, 100, 100)},
        /// even though filtering results are essentially the same, current
        /// <see cref="FilteredImagesCache"/>
        /// will treat this two cases as different filtering results.
        /// </remarks>
        /// <param name="imageKey">the defining filtering case</param>
        /// <returns>
        /// result of image filtering based on given set of cleaning areas if such was already processed and saved,
        /// null otherwise.
        /// </returns>
        internal virtual PdfImageXObject Get(FilteredImagesCache.FilteredImageKey imageKey)
        {
            IList <FilteredImagesCache.FilteredImageKey> cachedFilteredImageKeys = cache.Get(imageKey.GetImageIndRef());

            if (cachedFilteredImageKeys != null)
            {
                foreach (FilteredImagesCache.FilteredImageKey cacheKey in cachedFilteredImageKeys)
                {
                    if (RectanglesEqualWithEps(cacheKey.GetCleanedAreas(), imageKey.GetCleanedAreas()))
                    {
                        return(cacheKey.GetFilteredImage());
                    }
                }
            }
            return(null);
        }
Exemplo n.º 3
0
 internal virtual PdfCleanUpFilter.FilterResult <ImageData> FilterImage(FilteredImagesCache.FilteredImageKey
                                                                        imageKey)
 {
     return(FilterImage(imageKey.GetImageRenderInfo(), imageKey.GetCleanedAreas()));
 }