OSDN Git Service

#40869 Surface Proのようなアスペクト比が3:2のモニタだと、選曲画面上部のINFORMATION表示でPadやギターボタンの画像表示が拡大表示されてレイ...
[dtxmania/dtxmania.git] / DTXMania / コード / ステージ / 05.選曲 / CActSelectInformation.cs
1 using System;
2 using System.Collections.Generic;
3 using System.Diagnostics;
4 using System.Globalization;
5 using System.Text;
6 using System.Runtime.InteropServices;
7 using System.Drawing;
8 using System.IO;
9 using System.Text.RegularExpressions;
10 using FDK;
11
12 namespace DTXMania
13 {
14         internal class CActSelectInformation : CActivity
15         {
16                 // コンストラクタ
17
18                 public CActSelectInformation()
19                 {
20                         base.b活性化してない = true;
21                 }
22
23
24                 // CActivity 実装
25
26                 public override void On活性化()
27                 {
28                         this.n画像Index上 = -1;
29                         this.n画像Index下 = 0;
30                         base.On活性化();
31                 }
32                 public override void On非活性化()
33                 {
34                         this.ctスクロール用 = null;
35                         base.On非活性化();
36                 }
37                 public override void OnManagedリソースの作成()
38                 {
39                         if (!base.b活性化してない)
40                         {
41                                 //Trace.TraceInformation("Information用 Pad画像生成 開始。");
42
43                                 int fontsize = 19;
44
45                                 #region [ information画像パーツの作成 ]
46                                 #region [ Informationに表示する文字列の取得 ]
47                                 string[] strInfo = new string[]
48                                 {
49                                         CDTXMania.Instance.Resources.Explanation("strSelectInfo01"),
50                                         CDTXMania.Instance.Resources.Explanation("strSelectInfo02"),
51                                         CDTXMania.Instance.Resources.Explanation("strSelectInfo03"),
52                                         CDTXMania.Instance.Resources.Explanation("strSelectInfo04"),
53                                         CDTXMania.Instance.Resources.Explanation("strSelectInfo05"),
54                                         CDTXMania.Instance.Resources.Explanation("strSelectInfo06"),
55                                         CDTXMania.Instance.Resources.Explanation("strSelectInfo07"),
56                                         CDTXMania.Instance.Resources.Explanation("strSelectInfo08"),
57                                         CDTXMania.Instance.Resources.Explanation("strSelectInfo09"),
58                                         CDTXMania.Instance.Resources.Explanation("strSelectInfo10"),
59                                 };
60                                 #endregion
61                                 #region [パッド画像の準備]
62                                 STPadValue<Rectangle> RectDrPad = new STPadValue<Rectangle>();
63                                 RectDrPad.LC = new Rectangle(  0,   0, 170, 130);
64                                 RectDrPad.HH = new Rectangle(170,   0, 170, 130);
65                                 RectDrPad.SD = new Rectangle(340,   0, 170, 130);
66                                 RectDrPad.BD = new Rectangle(  0, 130, 170, 130);
67                                 RectDrPad.HT = new Rectangle(170, 130, 170, 130);
68                                 RectDrPad.LT = new Rectangle(340, 130, 170, 130);
69                                 RectDrPad.FT = new Rectangle(  0, 260, 170, 130);
70                                 RectDrPad.CY = new Rectangle(170, 260, 170, 130);
71                                 RectDrPad.RD = new Rectangle(340, 260, 170, 130);
72
73                                 STPadValue<Bitmap> ImgDrPad = new STPadValue<Bitmap>();
74                                 STPadValue<Bitmap> ImgGtPad = new STPadValue<Bitmap>();
75                                 Bitmap ImgAllDrPads = new Bitmap(CSkin.Path(@"Graphics\ScreenPlayDrums pads.png"));
76                                 Bitmap ImgAllGtPads = new Bitmap(CSkin.Path(@"Graphics\ScreenPlayGuitar pads.png"));
77                                 Graphics g;
78                                 Rectangle desRect = new Rectangle(0, 0, 170, 130);
79                                 float newHeight, imgScale;
80                                 Bitmap b;
81
82                                 #region [LC]
83                                 b = new Bitmap(170, 130);
84                                 g = Graphics.FromImage(b);
85                                 g.DrawImage(ImgAllDrPads, desRect, RectDrPad.LC, GraphicsUnit.Pixel);
86                                 b = tBmpTrim(b);
87                                 newHeight = fontsize * g.DpiY / 72.0f;  // 1 inch = 72 points
88                                 imgScale = newHeight / 130.0f * 2;
89                                 ImgDrPad.LC = new Bitmap((int)(Math.Ceiling(b.Width * imgScale)), (int)(Math.Ceiling(b.Height * imgScale)));
90                                 g.Dispose();
91                                 g = Graphics.FromImage(ImgDrPad.LC);
92                                 g.DrawImage(b, 0, 0, ImgDrPad.LC.Width, ImgDrPad.LC.Height);
93                                 g.Dispose();
94                                 b.Dispose();
95                                 #endregion
96                                 #region [HH]
97                                 b = new Bitmap(170, 130);
98                                 g = Graphics.FromImage(b);
99                                 g.DrawImage(ImgAllDrPads, desRect, RectDrPad.HH, GraphicsUnit.Pixel);
100                                 b = tBmpTrim(b);
101                                 newHeight = fontsize * g.DpiY / 72.0f;  // 1 inch = 72 points
102                                 imgScale = newHeight / 130.0f * 2;
103                                 ImgDrPad.HH = new Bitmap((int)(Math.Ceiling(b.Width * imgScale)), (int)(Math.Ceiling(b.Height * imgScale)));
104                                 g.Dispose();
105                                 g = Graphics.FromImage(ImgDrPad.HH);
106                                 g.DrawImage(b, 0, 0, ImgDrPad.HH.Width, ImgDrPad.HH.Height);
107                                 g.Dispose();
108                                 b.Dispose();
109                                 #endregion
110                                 #region [SD]
111                                 b = new Bitmap(170, 130);
112                                 g = Graphics.FromImage(b);
113                                 g.DrawImage(ImgAllDrPads, desRect, RectDrPad.SD, GraphicsUnit.Pixel);
114                                 b = tBmpTrim(b);
115                                 newHeight = fontsize * g.DpiY / 72.0f;  // 1 inch = 72 points
116                                 imgScale = newHeight / 130.0f * 2;
117                                 ImgDrPad.SD = new Bitmap((int)(Math.Ceiling(b.Width * imgScale)), (int)(Math.Ceiling(b.Height * imgScale)));
118                                 g.Dispose();
119                                 g = Graphics.FromImage(ImgDrPad.SD);
120                                 g.DrawImage(b, 0, 0, ImgDrPad.SD.Width, ImgDrPad.SD.Height);
121                                 g.Dispose();
122                                 b.Dispose();
123                                 #endregion
124                                 #region [BD]
125                                 b = new Bitmap(170, 130);
126                                 g = Graphics.FromImage(b);
127                                 g.DrawImage(ImgAllDrPads, desRect, RectDrPad.BD, GraphicsUnit.Pixel);
128                                 b = tBmpTrim(b);
129                                 newHeight = fontsize * g.DpiY / 72.0f;  // 1 inch = 72 points
130                                 imgScale = newHeight / 130.0f * 2;
131                                 ImgDrPad.BD = new Bitmap((int)(Math.Ceiling(b.Width * imgScale)), (int)(Math.Ceiling(b.Height * imgScale)));
132                                 g.Dispose();
133                                 g = Graphics.FromImage(ImgDrPad.BD);
134                                 g.DrawImage(b, 0, 0, ImgDrPad.BD.Width, ImgDrPad.BD.Height);
135                                 g.Dispose();
136                                 b.Dispose();
137                                 #endregion
138                                 #region [HT]
139                                 b = new Bitmap(170, 130);
140                                 g = Graphics.FromImage(b);
141                                 g.DrawImage(ImgAllDrPads, desRect, RectDrPad.HT, GraphicsUnit.Pixel);
142                                 b = tBmpTrim(b);
143                                 newHeight = fontsize * g.DpiY / 72.0f;  // 1 inch = 72 points
144                                 imgScale = newHeight / 130.0f * 2;
145                                 ImgDrPad.HT = new Bitmap((int)(Math.Ceiling(b.Width * imgScale)), (int)(Math.Ceiling(b.Height * imgScale)));
146                                 g.Dispose();
147                                 g = Graphics.FromImage(ImgDrPad.HT);
148                                 g.DrawImage(b, 0, 0, ImgDrPad.HT.Width, ImgDrPad.HT.Height);
149                                 g.Dispose();
150                                 b.Dispose();
151                                 #endregion
152                                 #region [LT]
153                                 b = new Bitmap(170, 130);
154                                 g = Graphics.FromImage(b);
155                                 g.DrawImage(ImgAllDrPads, desRect, RectDrPad.LT, GraphicsUnit.Pixel);
156                                 b = tBmpTrim(b);
157                                 newHeight = fontsize * g.DpiY / 72.0f;  // 1 inch = 72 points
158                                 imgScale = newHeight / 130.0f * 2;
159                                 ImgDrPad.LT = new Bitmap((int)(Math.Ceiling(b.Width * imgScale)), (int)(Math.Ceiling(b.Height * imgScale)));
160                                 g.Dispose();
161                                 g = Graphics.FromImage(ImgDrPad.LT);
162                                 g.DrawImage(b, 0, 0, ImgDrPad.LT.Width, ImgDrPad.LT.Height);
163                                 g.Dispose();
164                                 b.Dispose();
165                                 #endregion
166                                 #region [FT]
167                                 b = new Bitmap(170, 130);
168                                 g = Graphics.FromImage(b);
169                                 g.DrawImage(ImgAllDrPads, desRect, RectDrPad.FT, GraphicsUnit.Pixel);
170                                 b = tBmpTrim(b);
171                                 newHeight = fontsize * g.DpiY / 72.0f;  // 1 inch = 72 points
172                                 imgScale = newHeight / 130.0f * 2;
173                                 ImgDrPad.FT = new Bitmap((int)(Math.Ceiling(b.Width * imgScale)), (int)(Math.Ceiling(b.Height * imgScale)));
174                                 g.Dispose();
175                                 g = Graphics.FromImage(ImgDrPad.FT);
176                                 g.DrawImage(b, 0, 0, ImgDrPad.FT.Width, ImgDrPad.FT.Height);
177                                 g.Dispose();
178                                 b.Dispose();
179                                 #endregion
180                                 #region [CY]
181                                 b = new Bitmap(170, 130);
182                                 g = Graphics.FromImage(b);
183                                 g.DrawImage(ImgAllDrPads, desRect, RectDrPad.CY, GraphicsUnit.Pixel);
184                                 b = tBmpTrim(b);
185                                 newHeight = fontsize * g.DpiY / 72.0f;  // 1 inch = 72 points
186                                 imgScale = newHeight / 130.0f * 2;
187                                 ImgDrPad.CY = new Bitmap((int)(Math.Ceiling(b.Width * imgScale)), (int)(Math.Ceiling(b.Height * imgScale)));
188                                 g.Dispose();
189                                 g = Graphics.FromImage(ImgDrPad.CY);
190                                 g.DrawImage(b, 0, 0, ImgDrPad.CY.Width, ImgDrPad.CY.Height);
191                                 g.Dispose();
192                                 b.Dispose();
193                                 #endregion
194                                 #region [RD]
195                                 b = new Bitmap(170, 130);
196                                 g = Graphics.FromImage(b);
197                                 g.DrawImage(ImgAllDrPads, desRect, RectDrPad.RD, GraphicsUnit.Pixel);
198                                 b = tBmpTrim(b);
199                                 newHeight = fontsize * g.DpiY / 72.0f;  // 1 inch = 72 points
200                                 imgScale = newHeight / 130.0f * 2;
201                                 ImgDrPad.RD = new Bitmap((int)(Math.Ceiling(b.Width * imgScale)), (int)(Math.Ceiling(b.Height * imgScale)));
202                                 g.Dispose();
203                                 g = Graphics.FromImage(ImgDrPad.RD);
204                                 g.DrawImage(b, 0, 0, ImgDrPad.RD.Width, ImgDrPad.RD.Height);
205                                 g.Dispose();
206                                 b.Dispose();
207                                 #endregion
208                                 #region [GtR]
209                                 b = new Bitmap(170, 130);
210                                 g = Graphics.FromImage(b);
211                                 g.DrawImage(ImgAllGtPads, desRect, RectDrPad.LC, GraphicsUnit.Pixel);
212                                 b = tBmpTrim(b);
213                                 newHeight = fontsize * g.DpiY / 72.0f;  // 1 inch = 72 points
214                                 imgScale = newHeight / 130.0f * 2;
215                                 ImgGtPad.LC = new Bitmap((int)(Math.Ceiling(b.Width * imgScale)), (int)(Math.Ceiling(b.Height * imgScale)));
216                                 g.Dispose();
217                                 g = Graphics.FromImage(ImgGtPad.LC);
218                                 g.DrawImage(b, 0, 0, ImgGtPad.LC.Width, ImgGtPad.LC.Height);
219                                 g.Dispose();
220                                 b.Dispose();
221                                 #endregion
222                                 #region [GtG]
223                                 b = new Bitmap(170, 130);
224                                 g = Graphics.FromImage(b);
225                                 g.DrawImage(ImgAllGtPads, desRect, RectDrPad.HH, GraphicsUnit.Pixel);
226                                 b = tBmpTrim(b);
227                                 newHeight = fontsize * g.DpiY / 72.0f;  // 1 inch = 72 points
228                                 imgScale = newHeight / 130.0f * 2;
229                                 ImgGtPad.HH = new Bitmap((int)(Math.Ceiling(b.Width * imgScale)), (int)(Math.Ceiling(b.Height * imgScale)));
230                                 g.Dispose();
231                                 g = Graphics.FromImage(ImgGtPad.HH);
232                                 g.DrawImage(b, 0, 0, ImgGtPad.HH.Width, ImgGtPad.HH.Height);
233                                 g.Dispose();
234                                 b.Dispose();
235                                 #endregion
236                                 #region [GtB]
237                                 b = new Bitmap(170, 130);
238                                 g = Graphics.FromImage(b);
239                                 g.DrawImage(ImgAllGtPads, desRect, RectDrPad.SD, GraphicsUnit.Pixel);
240                                 b = tBmpTrim(b);
241                                 newHeight = fontsize * g.DpiY / 72.0f;  // 1 inch = 72 points
242                                 imgScale = newHeight / 130.0f * 2;
243                                 ImgGtPad.SD = new Bitmap((int)(Math.Ceiling(b.Width * imgScale)), (int)(Math.Ceiling(b.Height * imgScale)));
244                                 g.Dispose();
245                                 g = Graphics.FromImage(ImgGtPad.SD);
246                                 g.DrawImage(b, 0, 0, ImgGtPad.SD.Width, ImgGtPad.SD.Height);
247                                 g.Dispose();
248                                 b.Dispose();
249                                 #endregion
250                                 #region [GtPick]
251                                 b = new Bitmap(170, 130);
252                                 g = Graphics.FromImage(b);
253                                 g.DrawImage(ImgAllGtPads, desRect, RectDrPad.LT, GraphicsUnit.Pixel);
254                                 b = tBmpTrim(b);
255                                 newHeight = fontsize * g.DpiY / 72.0f;  // 1 inch = 72 points
256                                 imgScale = newHeight / 130.0f * 2;
257                                 ImgGtPad.LT = new Bitmap((int)(Math.Ceiling(b.Width * imgScale)), (int)(Math.Ceiling(b.Height * imgScale)));
258                                 g.Dispose();
259                                 g = Graphics.FromImage(ImgGtPad.LT);
260                                 g.DrawImage(b, 0, 0, ImgGtPad.LT.Width, ImgGtPad.LT.Height);
261                                 g.Dispose();
262                                 b.Dispose();
263                                 #endregion
264                                 #region [START]
265                                 b = new Bitmap(170, 130);
266                                 g = Graphics.FromImage(b);
267                                 g.DrawImage(ImgAllGtPads, desRect, RectDrPad.FT, GraphicsUnit.Pixel);
268                                 b = tBmpTrim(b);
269                                 newHeight = fontsize * g.DpiY / 72.0f;  // 1 inch = 72 points
270                                 imgScale = newHeight / 130.0f * 2;
271                                 ImgGtPad.FT = new Bitmap((int)(Math.Ceiling(b.Width * imgScale)), (int)(Math.Ceiling(b.Height * imgScale)));
272                                 g.Dispose();
273                                 g = Graphics.FromImage(ImgGtPad.FT);
274                                 g.DrawImage(b, 0, 0, ImgGtPad.FT.Width, ImgGtPad.FT.Height);
275                                 g.Dispose();
276                                 b.Dispose();
277                                 #endregion
278                                 #region [CANCEL]
279                                 b = new Bitmap(170, 130);
280                                 g = Graphics.FromImage(b);
281                                 g.DrawImage(ImgAllGtPads, desRect, RectDrPad.CY, GraphicsUnit.Pixel);
282                                 b = tBmpTrim(b);
283                                 newHeight = fontsize * g.DpiY / 72.0f;  // 1 inch = 72 points
284                                 imgScale = newHeight / 130.0f * 2;
285                                 ImgGtPad.CY = new Bitmap((int)(Math.Ceiling(b.Width * imgScale)), (int)(Math.Ceiling(b.Height * imgScale)));
286                                 g.Dispose();
287                                 g = Graphics.FromImage(ImgGtPad.CY);
288                                 g.DrawImage(b, 0, 0, ImgGtPad.CY.Width, ImgGtPad.CY.Height);
289                                 g.Dispose();
290                                 b.Dispose();
291                                 #endregion
292
293                                 g = null;
294                                 //Trace.TraceInformation("Information用 Pad画像生成 終了。");
295                                 #endregion
296
297                                 string fontPath = CDTXMania.Instance.Resources.Explanation("strCfgSelectMusicInformationFontFileName");
298                                 var prvFont = new CPrivateFastFont(CSkin.Path(Path.Combine(@"Graphics\fonts\", fontPath)), fontsize);
299
300                                 for (int j = 0; j < 2; j++)
301                                 {
302                                         var bmp = new Bitmap(512, 512);
303                                         g = Graphics.FromImage(bmp);
304                                         int y;
305                                         for (int i = 0; i < 5; i++)
306                                         {
307                                                 y = (512 / 5) * i;
308                                                 var strComments = strInfo[i + j * 5].Split(new string[] { "\n" }, StringSplitOptions.None);
309
310                                                 var r = new Regex(@"(?<PAD>\[.+?])", RegexOptions.IgnoreCase);
311
312                                                 foreach (var s in strComments)
313                                                 {
314                                                         int x = 0;
315                                                         List<string> sss = new List<string>();
316                                                         string ss = s.Trim();
317
318                                                         #region [PAD画像部と説明文字列部を分けてListに格納]
319                                                         Match m = r.Match(ss);
320                                                         while (m.Success)
321                                                         {
322                                                                 int padStrPos = m.Groups["PAD"].Index;
323                                                                 string padName = m.Groups["PAD"].Value;
324
325                                                                 if (padStrPos <= 0)
326                                                                 {
327                                                                         sss.Add(padName);
328                                                                         ss = ss.Substring(padStrPos + padName.Length);
329                                                                 }
330                                                                 else
331                                                                 {
332                                                                         sss.Add(ss.Substring(0, padStrPos));
333                                                                         ss = ss.Substring(padStrPos + padName.Length);
334                                                                         sss.Add(padName);
335                                                                 }
336                                                                 m = r.Match(ss);
337                                                         }
338                                                         sss.Add(ss);
339                                                         #endregion
340
341                                                         foreach (string ls in sss)
342                                                         {
343                                                                 string l = ls;      // foreach割り当て変数の書き換えはできないので
344
345                                                                 #region [PAD画像描画]
346                                                                 if ( (l != "" )&& (l[0] == '[') )       // PAD処理
347                                                                 {
348                                                                         switch(ls)
349                                                                         {
350                                                                                 case "[LC]":
351                                                                                         l = ""; g.DrawImage(ImgDrPad.LC, x, y, ImgDrPad.LC.Width, ImgDrPad.LC.Height);  x += ImgDrPad.LC.Width;
352                                                                                         break;
353                                                                                 case "[HH]":
354                                                                                         l = ""; g.DrawImage(ImgDrPad.HH, x, y, ImgDrPad.HH.Width, ImgDrPad.HH.Height);  x += ImgDrPad.HH.Width;
355                                                                                         break;
356                                                                                 case "[SD]":
357                                                                                         l = ""; g.DrawImage(ImgDrPad.SD, x, y, ImgDrPad.SD.Width, ImgDrPad.SD.Height);  x += ImgDrPad.SD.Width;
358                                                                                         break;
359                                                                                 case "[BD]":
360                                                                                         l = ""; g.DrawImage(ImgDrPad.BD, x, y, ImgDrPad.BD.Width, ImgDrPad.BD.Height);  x += ImgDrPad.BD.Width;
361                                                                                         break;
362                                                                                 case "[HT]":
363                                                                                         l = ""; g.DrawImage(ImgDrPad.HT, x, y, ImgDrPad.HT.Width, ImgDrPad.HT.Height); x += ImgDrPad.HT.Width;
364                                                                                         break;
365                                                                                 case "[LT]":
366                                                                                         l = ""; g.DrawImage(ImgDrPad.LT, x, y, ImgDrPad.LT.Width, ImgDrPad.LT.Height); x += ImgDrPad.LT.Width;
367                                                                                         break;
368                                                                                 case "[FT]":
369                                                                                         l = ""; g.DrawImage(ImgDrPad.FT, x, y, ImgDrPad.FT.Width, ImgDrPad.FT.Height); x += ImgDrPad.FT.Width;
370                                                                                         break;
371                                                                                 case "[CY]":
372                                                                                         l = ""; g.DrawImage(ImgDrPad.CY, x, y, ImgDrPad.CY.Width, ImgDrPad.CY.Height); x += ImgDrPad.CY.Width;
373                                                                                         break;
374                                                                                 case "[RD]":
375                                                                                         l = ""; g.DrawImage(ImgDrPad.RD, x, y, ImgDrPad.RD.Width, ImgDrPad.RD.Height); x += ImgDrPad.RD.Width;
376                                                                                         break;
377                                                                                 case "[R]":
378                                                                                         l = ""; g.DrawImage(ImgGtPad.LC, x, y, ImgGtPad.LC.Width, ImgGtPad.LC.Height); x += ImgGtPad.LC.Width;
379                                                                                         break;
380                                                                                 case "[G]":
381                                                                                         l = ""; g.DrawImage(ImgGtPad.HH, x, y, ImgGtPad.LC.Width, ImgGtPad.HH.Height); x += ImgGtPad.HH.Width;
382                                                                                         break;
383                                                                                 case "[B]":
384                                                                                         l = ""; g.DrawImage(ImgGtPad.SD, x, y, ImgGtPad.SD.Width, ImgGtPad.SD.Height); x += ImgGtPad.SD.Width;
385                                                                                         break;
386                                                                                 case "[P]":
387                                                                                         l = ""; g.DrawImage(ImgGtPad.LT, x, y, ImgGtPad.LT.Width, ImgGtPad.LT.Height); x += ImgGtPad.LT.Width;
388                                                                                         break;
389                                                                                 case "[START]":
390                                                                                         l = ""; g.DrawImage(ImgGtPad.FT, x, y, ImgGtPad.FT.Width, ImgGtPad.FT.Height); x += ImgGtPad.FT.Width;
391                                                                                         break;
392                                                                                 case "[CANCEL]":
393                                                                                         l = ""; g.DrawImage(ImgGtPad.CY, x, y, ImgGtPad.CY.Width, ImgGtPad.CY.Height); x += ImgGtPad.CY.Width;
394                                                                                         break;
395                                                                                 default:
396                                                                                         break;
397                                                                         }
398                                                                 }
399                                                                 #endregion
400                                                                 #region [文字列描画]
401                                                                 if (l != "")            // 通常文字列、もしくはパッド名じゃない[...]で囲まれた文字列
402                                                                 {
403                                                                         var bb = prvFont.DrawPrivateFont(ls, Color.White, Color.FromArgb(0, 0, 0));
404                                                                         g.DrawImage(bb, x, y);
405                                                                         x += prvFont.RectStrings.Width;
406                                                                         bb.Dispose();
407                                                                 }
408                                                                 #endregion
409                                                         }
410                                                         y += (int)(prvFont.RectStrings.Height * 1.2f);
411                                                 }
412                                         }
413                                         this.txInfo[j] = TextureFactory.tテクスチャの生成(bmp, false);
414
415                                         //bmp.Save("tmptmp" + j + ".png");
416                                         g.Dispose();
417                                         g = null;
418                                         bmp.Dispose();
419                                         bmp = null;
420                                 }
421                                 prvFont.Dispose();
422                                 prvFont = null;
423
424                                 #region [ImgDrPad開放]
425                                 ImgDrPad.LC.Dispose();  ImgDrPad.LC = null;
426                                 ImgDrPad.HH.Dispose();  ImgDrPad.HH = null;
427                                 ImgDrPad.SD.Dispose();  ImgDrPad.SD = null;
428                                 ImgDrPad.BD.Dispose();  ImgDrPad.BD = null;
429                                 ImgDrPad.HT.Dispose();  ImgDrPad.HT = null;
430                                 ImgDrPad.LT.Dispose();  ImgDrPad.LT = null;
431                                 ImgDrPad.FT.Dispose();  ImgDrPad.FT = null;
432                                 ImgDrPad.CY.Dispose();  ImgDrPad.CY = null;
433                                 ImgDrPad.RD.Dispose();  ImgDrPad.RD = null;
434                                 ImgDrPad = null;
435                                 #endregion
436
437                                 #endregion
438
439                                 base.OnManagedリソースの作成();
440                         }
441                 }
442                 public override void OnManagedリソースの解放()
443                 {
444                         if (!base.b活性化してない)
445                         {
446                                 TextureFactory.tテクスチャの解放(ref this.txInfo[0]);
447                                 TextureFactory.tテクスチャの解放(ref this.txInfo[1]);
448                                 base.OnManagedリソースの解放();
449                         }
450                 }
451                 public override int On進行描画()
452                 {
453                         if (!base.b活性化してない)
454                         {
455                                 if (base.b初めての進行描画)
456                                 {
457                                         this.ctスクロール用 = new CCounter(0, 6000, 1, CDTXMania.Instance.Timer);
458                                         base.b初めての進行描画 = false;
459                                 }
460                                 this.ctスクロール用.t進行();
461                                 if (this.ctスクロール用.b終了値に達した)
462                                 {
463                                         this.n画像Index上 = this.n画像Index下;
464                                         this.n画像Index下 = (this.n画像Index下 + 1) % stInfo.GetLength(0);    //8;
465                                         this.ctスクロール用.n現在の値 = 0;
466                                 }
467                                 int n現在の値 = this.ctスクロール用.n現在の値;
468                                 if (n現在の値 <= 250)
469                                 {
470                                         double n現在の割合 = ((double)n現在の値) / 250.0;
471                                         if (this.n画像Index上 >= 0)
472                                         {
473                                                 STINFO stinfo = this.stInfo[this.n画像Index上];
474                                                 Rectangle rectangle = new Rectangle(
475                                                         stinfo.pt左上座標.X,
476                                                         stinfo.pt左上座標.Y + ((int)((int)(512.0 / 5) * n現在の割合)),
477                                                         512,
478                                                         Convert.ToInt32((int)(512.0 / 5 * (1.0 - n現在の割合)))
479                                                 );
480                                                 if (this.txInfo[stinfo.nTexture番号] != null)
481                                                 {
482                                                         this.txInfo[stinfo.nTexture番号].t2D描画(
483                                                                 CDTXMania.Instance.Device,
484                                                                 115 * Scale.X,
485                                                                 6 * Scale.Y,
486                                                                 rectangle
487                                                         );
488                                                 }
489                                         }
490                                         if (this.n画像Index下 >= 0)
491                                         {
492                                                 STINFO stinfo = this.stInfo[this.n画像Index下];
493                                                 Rectangle rectangle = new Rectangle(
494                                                         stinfo.pt左上座標.X,
495                                                         stinfo.pt左上座標.Y,
496                                                         512,
497                                                         (int)(512.0 / 5 * n現在の割合)
498                                                 );
499                                                 if (this.txInfo[stinfo.nTexture番号] != null)
500                                                 {
501                                                         this.txInfo[stinfo.nTexture番号].t2D描画(
502                                                                 CDTXMania.Instance.Device,
503                                                                 115 * Scale.X,
504                                                                 6 * Scale.Y + ((int)(512.0 / 5 * (1.0 - n現在の割合))),
505                                                                 rectangle
506                                                         );
507                                                 }
508                                         }
509                                 }
510                                 else
511                                 {
512                                         STINFO stinfo = this.stInfo[this.n画像Index下];
513                                         Rectangle rectangle = new Rectangle(
514                                                 stinfo.pt左上座標.X,
515                                                 stinfo.pt左上座標.Y,
516                                                 512,
517                                                 (int)(512.0 / 5)
518                                         );
519                                         if (this.txInfo[stinfo.nTexture番号] != null)
520                                         {
521                                                 this.txInfo[stinfo.nTexture番号].t2D描画(
522                                                         CDTXMania.Instance.Device,
523                                                         115 * Scale.X,
524                                                         6 * Scale.Y,
525                                                         rectangle
526                                                 );
527                                         }
528                                 }
529                         }
530                         return 0;
531                 }
532
533
534                 // その他
535
536                 #region [ private ]
537                 //-----------------
538                 [StructLayout(LayoutKind.Sequential)]
539                 private struct STINFO
540                 {
541                         public int nTexture番号;
542                         public Point pt左上座標;
543                         public STINFO(int nTexture番号, int x, int y)
544                         {
545                                 this.nTexture番号 = nTexture番号;
546                                 this.pt左上座標 = new Point(x, y);
547                         }
548                 }
549
550                 private CCounter ctスクロール用;
551                 private int n画像Index下;
552                 private int n画像Index上;
553                 private readonly STINFO[] stInfo = new STINFO[] {
554                         new STINFO( 0, 0, 0 ),
555                         new STINFO( 0, 0, (int)(512.0 / 5 * 1)),
556                         new STINFO( 0, 0, (int)(512.0 / 5 * 2)),
557                         new STINFO( 0, 0, (int)(512.0 / 5 * 3)),
558                         new STINFO( 0, 0, (int)(512.0 / 5 * 4)),
559                         new STINFO( 1, 0, (int)(512.0 / 5 * 0)),
560                         new STINFO( 1, 0, (int)(512.0 / 5 * 1)),
561                         new STINFO( 1, 0, (int)(512.0 / 5 * 2)),
562                         new STINFO( 1, 0, (int)(512.0 / 5 * 3))
563                 };
564                 private CTexture[] txInfo = new CTexture[2];
565
566
567
568                 /// <summary>
569                 /// 画像の周囲から画素のない部分を削除しトリミングする
570                 /// (とりあえずGetPixelを使った低速バージョン)
571                 /// </summary>
572                 /// <param name="src"></param>
573                 /// <returns></returns>
574                 private Bitmap tBmpTrim(Bitmap src)
575                 {
576                         int x0 = 0, y0 = 0, x1 = src.Width - 1, y1 = src.Height - 1;
577                         int alpha_threshold = 64;
578
579                         #region [ 左辺のトリミング(x0を求める) ]
580                         for (int px = 0; px < src.Width; px++)
581                         {
582                                 for (int py = 0; py < src.Height; py++)
583                                 {
584                                         Color c = src.GetPixel(px, py);
585                                         if (c.A > alpha_threshold)
586                                         {
587                                                 x0 = px;
588                                                 px = src.Width;    // for break;
589                                                 break;
590                                         }
591                                 }
592                         }
593                         #endregion
594                         #region [ 上辺のトリミング(y0を求める) ]
595                         for (int py = 0; py < src.Height; py++)
596                         {
597                                 for (int px = 0; px < src.Width; px++)
598                                 {
599                                         Color c = src.GetPixel(px, py);
600                                         if (c.A > alpha_threshold)
601                                         //if (!c.Equals(Color.FromArgb(0, 0, 0, 0)))
602                                         {
603                                                 y0 = py;
604                                                 py = src.Height;    // for break;
605                                                 break;
606                                         }
607                                 }
608                         }
609                         #endregion
610                         #region [ 右辺のトリミング(x1を求める) ]
611                         for (int px = src.Width - 1; px >= 0; px--)
612                         {
613                                 for (int py = src.Height - 1; py >= 0; py--)
614                                 {
615                                         Color c = src.GetPixel(px, py);
616                                         if (c.A > alpha_threshold)
617                                         {
618                                                 x1 = px;
619                                                 px = -1;    // for break;
620                                                 break;
621                                         }
622                                 }
623                         }
624                         #endregion
625                         #region [ 右辺のトリミング(y1を求める) ]
626                         for (int py = src.Height- 1; py >= 0; py--)
627                         {
628                                 for (int px = src.Width - 1; px >= 0; px--)
629                                 {
630                                         Color c = src.GetPixel(px, py);
631                                         if (c.A > alpha_threshold)
632                                         {
633                                                 y1 = py;
634                                                 py = -1;    // for break;
635                                                 break;
636                                         }
637                                 }
638                         }
639                         #endregion
640
641                         #region [ Trim後のbmpを生成 ]
642                         int w = x1 - x0 + 1;
643                         int h = y1 - y0 + 1;
644                         Bitmap bmp = new Bitmap(w, h);
645                         Graphics g = Graphics.FromImage(bmp);
646                         g.DrawImage(src, 0, 0, new Rectangle(x0, y0, w, h), GraphicsUnit.Pixel);
647                                 //(src, new Rectangle(x0, y0, w, h));
648
649                         g.Dispose();
650                         g = null;
651                         #endregion
652
653                         return bmp;
654                 }
655                 //-----------------
656                 #endregion
657         }
658 }