OSDN Git Service

SVNから移行した
[d2dbench/d2dbench.git] / D2DBench / Method8.cs
1 using System;\r
2 using System.Drawing;\r
3 using System.Diagnostics;\r
4 using System.Windows.Forms;\r
5 using D2DBench.Properties;\r
6 \r
7 namespace D2DBench\r
8 {\r
9     class Method8 : IBench\r
10     {\r
11         public int fillAreaSize { get { return bmpSize.Width * bmpSize.Height * Form1.ExecuteCountPerOneset; } }\r
12         public string methodName { get { return "GDIBitBlt"; } }\r
13 \r
14         GDI gdi;\r
15         ColorTableGDI colors;\r
16         Size ClientSize;\r
17         const string showStr = "D2DBenchMark";\r
18         Font font;\r
19         Size bmpSize;\r
20         GDIBitmap bmp;\r
21 \r
22         public void Init(Control ctrl, bool antialias)\r
23         {\r
24             ClientSize = ctrl.ClientSize;\r
25             gdi = new GDI(ctrl);\r
26             colors = new ColorTableGDI();\r
27             font = ctrl.Font;\r
28             bmpSize = Resources.image.Size;\r
29             bmp = gdi.LoadImage(Resources.image);\r
30             ctrl.Show();\r
31         }\r
32 \r
33         public void Exec()\r
34         {\r
35             Random rnd = new Random();\r
36             gdi.BeginDraw();\r
37             for (int j = 0; j < Form1.ExecuteCountPerOneset; j++)\r
38             {\r
39                 Rectangle rect = new Rectangle();\r
40                 rect.X = rnd.Next(ClientSize.Width);\r
41                 rect.Y = rnd.Next(ClientSize.Height);\r
42                 rect.Width = rect.X + bmpSize.Width;\r
43                 rect.Height = rect.Y + bmpSize.Height;\r
44                 gdi.DrawImage(rect, bmp);\r
45             }\r
46             gdi.EndDraw();\r
47         }\r
48 \r
49         public void Dispose()\r
50         {\r
51             gdi.UnloadImage(bmp);\r
52             gdi.Dispose();\r
53         }\r
54     }\r
55 }\r