public static Image ResizeImage(Image img, ImageScaleType scaleType) { float width = 0, height = 0; switch (scaleType) { case ImageScaleType.Percentage: width = img.Width * (Program.Settings.ImageScalePercentageWidth / 100f); height = img.Height * (Program.Settings.ImageScalePercentageHeight / 100f); break; case ImageScaleType.Width: width = Program.Settings.ImageScaleToWidth; height = Program.Settings.ImageKeepAspectRatio ? img.Height * (width / img.Width) : img.Height; break; case ImageScaleType.Height: height = Program.Settings.ImageScaleToHeight; width = Program.Settings.ImageKeepAspectRatio ? img.Width * (height / img.Height) : img.Width; break; case ImageScaleType.Specific: width = Program.Settings.ImageScaleSpecificWidth; height = Program.Settings.ImageScaleSpecificHeight; break; } if (width > 0 && height > 0) { return(CaptureHelpers.ResizeImage(img, (int)width, (int)height, Program.Settings.ImageUseSmoothScaling)); } return(img); }