コード例 #1
0
        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
                });
            }
        }
コード例 #2
0
 public ImageResolution Resolve(ImageResolution inputRes)
 {
     return(new ImageResolution
     {
         Width = ScaleFactor * inputRes.Width,
         Height = ScaleFactor * inputRes.Height
     });
 }
コード例 #3
0
        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)
            });
        }
コード例 #4
0
 public MaxSizeResolutionResolver(ImageResolution maxRes)
 {
     MaxResolution = maxRes;
 }
コード例 #5
0
 /// <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)));
 }