コード例 #1
0
ファイル: Form1.cs プロジェクト: shoorik/desktop-switcher
 /// <summary>
 /// determines if ratio of bitmap is close enough to dimensions given
 /// </summary>
 /// <param name="b">bitmap to test</param>
 /// <param name="x">width dimension</param>
 /// <param name="y">height dimension</param>
 /// <returns></returns>
 private bool sameratio(picture b, double x, double y, double value)
 {
     double screenRatio = x / y;
     double imgRatio = (double)b.getwidth() / (double)b.getheight();
     if (screenRatio < imgRatio)
         return ((screenRatio / imgRatio) + (value / 100) >= 1);
     else
         return ((imgRatio / screenRatio) + (value / 100) >= 1);
     //return (getratio(ref b) >= x/y - (value / 100 * x/y) && getratio(ref b) <= x/y + (value / 100 * x/y));
 }
コード例 #2
0
ファイル: Form1.cs プロジェクト: shoorik/desktop-switcher
 /// <summary>
 /// determines whether or not the ratio of the picture is close enough to the ratio of the screen
 /// </summary>
 /// <param name="b">bitmap to test</param>
 /// <param name="screen">index of the screen in the desktop array</param>
 /// <returns></returns>
 private bool sameratio(picture b, int screen, double value)
 {
     double screenRatio = getratio(screen);
     double imgRatio = (double)b.getwidth()/(double)b.getheight();
     if (screenRatio < imgRatio)
         return ((screenRatio / imgRatio) + (value / 100) >= 1);
     else
         return ((imgRatio / screenRatio) + (value / 100) >= 1);
     //return (getratio(ref b) >= getratio(screen) - (value / 100 * getratio(screen)) && getratio(ref b) <= getratio(screen) + (value / 100 * getratio(screen)));
 }