forked from Ken98045/On-Guard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBitmapResolution.cs
37 lines (31 loc) · 1.09 KB
/
BitmapResolution.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
namespace SAAI
{
/// <summary>
/// Just a class to hold a global that has the resolution of the source bitmap
/// We need to access it from multiple files.
/// </summary>
public static class BitmapResolution
{
static public int XResolution { get; set; } = 1024;
static public int YResolution { get; set; } = 768;
static public double XScale { get; set; } = 1.0;
static public double YScale { get; set; } = 1.0;
public static Rectangle ScaleScreenToData(Rectangle rect)
{
Rectangle result = new Rectangle((int)Math.Round(rect.X * XScale), (int)Math.Round(rect.Y * YScale), (int)Math.Round(rect.Width * XScale), (int)Math.Round(rect.Height * YScale));
return result;
}
public static Point ScaleScreenToData(Point point)
{
Point result = new Point((int)Math.Round(point.X * XScale), (int)Math.Round(point.Y * YScale));
return result;
}
}
}