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
|
public Bitmap Generate75x75Pixel(Bitmap image) {
if(image == null)
throw new ArgumentNullException("image");
Bitmap bmp = null;
Bitmap crapped = null;
int x = 0, y = 0;
double prop = 0;
if(image.Width > 75) {
// compute proportation
prop = (double)image.Width / (double)image.Height;
f(image.Width > image.Height) {
x = (int)Math.Round(75 * prop, 0);
y = 75;
}
else {
x = 75;
y = (int)Math.Round(75 / prop, 0);
}
bmp = new Bitmap((Image)image, new Size(x, y));
crapped = new Bitmap(75, 75);
Graphics g = Graphics.FromImage(crapped);
g.DrawImage(bmp,
new Rectangle(0, 0, 75, 75),
new Rectangle(0, 0, 75, 75),
GraphicsUnit.Pixel);
bmp = crapped;
}
else {
crapped = image;
}
return bmp;
}
|