public ImageResolution Resolve(ImageResolution inputRes) { float xRatio = MaxResolution.Width / inputRes.Width; float yRatio = MaxResolution.Height / inputRes.Height; float xDiff = MaxResolution.Width - inputRes.Width; float yDiff = MaxResolution.Height - inputRes.Height; if (xDiff <= 0 && yDiff <= 0) { return(inputRes); } if (xDiff > yDiff) { return(new ImageResolution { Width = inputRes.Width * xRatio, Height = inputRes.Height * xRatio }); } else { return(new ImageResolution { Width = inputRes.Width * yRatio, Height = inputRes.Height * yRatio }); } }
public ImageResolution Resolve(ImageResolution inputRes) { return(new ImageResolution { Width = ScaleFactor * inputRes.Width, Height = ScaleFactor * inputRes.Height }); }
public ImageResolution Resolve(ImageResolution inputRes) { float inputMegapixels = inputRes.Width * inputRes.Height; float scale = (float)Math.Sqrt(DesiredPixels / inputMegapixels); return(new ImageResolution { Width = (float)Math.Floor(scale * inputRes.Width), Height = (float)Math.Floor(scale * inputRes.Height) }); }
public MaxSizeResolutionResolver(ImageResolution maxRes) { MaxResolution = maxRes; }
/// <summary> /// Cartesian distance between this resolution and the other /// </summary> public float Distance(ImageResolution other) { return((float)Math.Sqrt(Math.Pow(Width - other.Width, 2) + Math.Pow(Height - other.Height, 2))); }