-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPhotoTrimmer.cs
55 lines (54 loc) · 1.7 KB
/
PhotoTrimmer.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
namespace PersonalRU
{
public class PhotoTrimmer
{
public int X = 0;
public int Y = 0;
private int Width = 1;
private int Height = 1;
public double ratio;
public Bitmap img;
public PhotoTrimmer(int width, int height)
{
this.Width = width;
this.Height = height;
this.ratio = (double)this.Width / (double)this.Height;
img = new Bitmap(Width, Height);
}
public PhotoTrimmer(int x, int y, int width, int height)
{
this.X = x; this.Y = y;
this.Width = width;
this.Height = height;
this.ratio = (double)this.Width / (double)this.Height;
}
public PhotoTrimmer(int x, int y, Size size)
{
this.X = x; this.Y = y;
this.Width = size.Width;
this.Height = size.Height;
this.ratio = (double)this.Width / (double)this.Height;
}
public void setWidth(int width){
this.Width = width;
this.Height =(int)(this.Width / this.ratio);
}
public void setHeight(int height)
{
this.Height = height;
this.Width = (int)(this.Height * this.ratio);
}
public int getWidth() { return this.Width; }
public int getHeight() { return this.Height; }
public Rectangle GetRectangle()
{
Rectangle rect = new Rectangle(this.X, this.Y, this.Width, this.Height);
return rect;
}
}
}