Not a member of Pastebin yet?
                        Sign Up,
                        it unlocks many cool features!                    
                - public static int NSD(int a, int b)
 - {
 - for (int i = 2; ; i++)
 - {
 - if (a % i == 0 && b % i == 0)
 - {
 - return i;
 - }
 - }
 - return 1;
 - }
 - public static Size CalculateOptimalSize(int width, int height)
 - {
 - Size vr = new Size(width, height);
 - int sirkaSloupce = 480;
 - if (width > sirkaSloupce)
 - {
 - //int gcd = NSD(width, height);
 - //if (gcd != 1)
 - //{
 - // if (sirkaSloupce < width)
 - // {
 - // int i = 1;
 - // while (true)
 - // {
 - // if (gcd * i > width)
 - // {
 - // break;
 - // }
 - // i++;
 - // }
 - // vr.Height = (height / gcd) * i;
 - // vr.Width = (width / gcd) * i;
 - // }
 - // else
 - // {
 - // //W:15 H:55
 - // //W:55 H:15
 - // int w = gcd;
 - // int pric = 1;
 - // while (true)
 - // {
 - // if (w > sirkaSloupce)
 - // {
 - // break;
 - // }
 - // pric++;
 - // }
 - // vr.Height = gcd * pric;
 - // vr.Width = w;
 - // }
 - //}
 - //else
 - //{
 - // //-W:1000 H:500
 - // if (width > height)
 - // {
 - // vr = CalculateOptimalSize2(width, height, sirkaSloupce);
 - // }
 - // else
 - // {
 - // }
 - //}
 - vr.Width = sirkaSloupce;
 - // mohl by ses jeลกtฤ rozhodovat jestli round, nebo floor, nebo ceil
 - vr.Height = sirkaSloupce * height / width;
 - }
 - return vr;
 - }
 
Advertisement
 
                    Add Comment                
                
                        Please, Sign In to add comment