Exemple #1
0
        // Get scaling factor limited to available memory
        private static float GetUpperScalingLimit(SizeF scaledSize, float scalingFactor)
        {
            // estimate required memory and use 60% as threshold value
            var required  = EffectGraph.GetEstimatedRequiredMemory(scaledSize);
            var threshold = (EffectGraph.AvailableMemory * 100) / 60;

            if (required > threshold)
            {
                // limit scaling factor to fit available memory
                var maxPixels      = EffectGraph.GetMaximumPixelCount(threshold);
                var originalPixels = ((double)scaledSize.Width * scaledSize.Height) / scalingFactor;
                return((float)(maxPixels / originalPixels));
            }

            return(scalingFactor);
        }
Exemple #2
0
 /// <summary>
 /// Return the estimated amount of memory required to process the effect
 /// </summary>
 /// <param name="size">Size of the input image</param>
 /// <param name="scalingFactor">Scaling factor</param>
 /// <returns>Estimated number of bytes required to process the effect</returns>
 public static long GetEstimatedRequiredMemory(Size size, float scalingFactor)
 {
     return(EffectGraph.GetEstimatedRequiredMemory(size.ScaleBy(scalingFactor)));
 }