コード例 #1
0
        public Resolution CalculateResize(decimal destinationAspectRatio, Resolution maxOutput, int framesizeMultipleOff = 1)
        {
            // get the aspect ratio for the height / width calculation, defaulting to 16:9
            decimal displayAspect = destinationAspectRatio == 0 ? 16 / 9 : destinationAspectRatio;

            // calculate new width
            int width = maxOutput.Width;
            int height = (int)(width * (1 / displayAspect));
            if (height > maxOutput.Height) {
                height = maxOutput.Height;
                width = (int)(height * displayAspect);
            }

            // round
            int newWidth = ((int)Math.Round(width * 1.0 / framesizeMultipleOff)) * framesizeMultipleOff;
            int newHeight = ((int)Math.Round(height * 1.0 / framesizeMultipleOff)) * framesizeMultipleOff;

            return new Resolution(newWidth, newHeight);
        }
コード例 #2
0
 public Resolution CalculateResize(Resolution maxOutputSize, int framesizeMultipleOff = 1)
 {
     return CalculateResize(Width / Height, maxOutputSize, framesizeMultipleOff);
 }
コード例 #3
0
 public static Resolution Calculate(decimal destinationAspectRatio, Resolution maxOutput, int framesizeMultipleOff = 1)
 {
     Resolution res = new Resolution(0, 0);
     return res.CalculateResize(destinationAspectRatio, maxOutput, framesizeMultipleOff);
 }