private void Put字幕(Bitmap j1, Consts.LineAlign_e align1, Bitmap j2, Consts.LineAlign_e align2) { int margin = (int)(Img_H * 0.01); using (Graphics g = Graphics.FromImage(Img)) { if (j1 != null) { int x = Img_W - j1.Width; int y = Img_H - j1.Height - margin - j2.Height - margin; switch (align1) { case Consts.LineAlign_e.左寄せ: x = 0; break; case Consts.LineAlign_e.中央: x /= 2; break; case Consts.LineAlign_e.右寄せ: break; default: throw null; } g.DrawImage(j1, x, y); } { int x = Img_W - j2.Width; int y = Img_H - j2.Height - margin; switch (align2) { case Consts.LineAlign_e.左寄せ: x = 0; break; case Consts.LineAlign_e.中央: x /= 2; break; case Consts.LineAlign_e.右寄せ: break; default: throw null; } g.DrawImage(j2, x, y); } } }
private void btnOk_Click(object sender, EventArgs e) { this.Ret_Line1 = this.Line1.Text; this.Ret_Line2 = this.Line2.Text; this.Ret_Align1 = (Consts.LineAlign_e) this.Align1.SelectedIndex; this.Ret_Align2 = (Consts.LineAlign_e) this.Align2.SelectedIndex; if (this.Check_Ret()) { this.OkPressed = true; this.Close(); } }
/// <summary> /// /// </summary> /// <param name="line1">""禁止</param> /// <param name="align1"></param> /// <param name="line2">""==2行目無し</param> /// <param name="align2"></param> public void perform(string line1, Consts.LineAlign_e align1, string line2, Consts.LineAlign_e align2) { if (Gnd.i.md == null) { return; } if (Gnd.i.md.ed.a.selectEnd == -1) // ? ! 時間選択完了 { throw new FailedOperation("時間を選択して下さい。"); } StartIndex = Gnd.i.md.ed.a.selectBegin; // ここから EndIndex = Gnd.i.md.ed.a.selectEnd; // ここまで(これを含む!) Img = Gnd.i.md.ed.v.getImage(StartIndex); Img_W = Img.Width; Img_H = Img.Height; Img.Dispose(); Img = null; GC.Collect(); Bitmap j1; Bitmap j2; if (line2 == "") { j1 = null; j2 = Make字幕(line1); } else { j1 = Make字幕(line1); j2 = Make字幕(line2); } // test { if (j1 != null) { j1.Save(@"C:\temp\j1.png", ImageFormat.Png); } j2.Save(@"C:\temp\j2.png", ImageFormat.Png); } for (int index = StartIndex; index <= EndIndex; index++) { Img = Gnd.i.md.ed.v.getImage(index); Put字幕(j1, align1, j2, align2); Gnd.i.md.ed.v.setImage(index, Img); Img.Dispose(); Img = null; GC.Collect(); } }