Option Explicit On Option Strict On Public Class Form1 Dim Title As String Dim ICT As Integer '計算ケ−ス設定 Dim AFCA As Double 'AFC片側振幅流量(m3/s) Dim AFCT As Double 'AFC周期(s) '計算時間設定 Dim TMAX As Double '計算打切時間 Dim dt As Double '計算時間間隔 Dim DTWR As Double '打出時間間隔 '制水口設定 Dim PAA As Double '制水口断面積 Dim PCI As Double '制水口流入時流量係数 Dim PCO As Double '制水口流出時流量係数 'トンネル等設定 Dim RWL As Double '貯水池水位標高 Dim TNL As Double 'トンネル延長 Dim TNA As Double 'トンネル断面積 Dim TNC As Double 'トンネル損失水頭係数 '立坑断面 Dim NST As Integer '入力断面数 Dim SAA() As Double '断面積 Dim SEL() As Double '下端標高 Dim SLB() As String '立坑断面ラベル Dim ELU As Double '水槽上端標高 Dim ELB As Double '水槽下端標高 '流量設定 Dim NQT As Integer '入力点数 Dim QTQ() As Double '入力点流量 Dim QTI() As Double '入力点時刻 'その他 Dim AFCS As Double Dim QI As Double '定数 Dim g As Double = 9.80665 '重力加速度 Dim pi As Double = Math.PI '円周率 '最高・最低水位記憶 Dim WLmax As Double Dim TTmax As Double Dim WLmin As Double Dim TTmin As Double '作図範囲指定 Dim draw_xmin As Double Dim draw_xmax As Double Dim draw_dx As Double Dim draw_ymin As Double Dim draw_ymax As Double Dim draw_dy As Double Private Sub ToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click Call main_part() End Sub Private Sub main_part() Dim sr As System.IO.StreamReader Dim swlog As System.IO.StreamWriter Dim fnameR As String = "" Dim fnameW As String = "" Dim fnameF As String = "" Dim fnameZ As String = "" Dim fnameL As String = "" Dim dat As String Dim sbuf() As String Dim delim As Char = ","c Dim i As Integer Dim nfile As Integer Dim iret As Integer Dim flistR(50) As String Dim flistW(50) As String Dim flistF(50) As String Dim work(50) As String Dim bboxv(3) As Integer OpenFileDialog1.InitialDirectory = System.IO.Directory.GetCurrentDirectory() If OpenFileDialog1.ShowDialog() = DialogResult.OK Then fnameR = OpenFileDialog1.FileName sr = New System.IO.StreamReader(fnameR, System.Text.Encoding.Default) dat = sr.ReadLine() sbuf = dat.Split(delim) nfile = Integer.Parse(sbuf(0)) - 1 For i = 0 To nfile dat = sr.ReadLine() sbuf = dat.Split(delim) flistR(i) = System.IO.Path.GetDirectoryName(fnameR) & "\" & sbuf(0) flistW(i) = System.IO.Path.GetDirectoryName(fnameR) & "\" & sbuf(1) flistF(i) = System.IO.Path.GetDirectoryName(fnameR) & "\" & sbuf(2) work(i) = sbuf(3) & "," & sbuf(4) & "," & sbuf(5) & "," & sbuf(6) Next i sr.Close() fnameL = System.IO.Path.GetDirectoryName(fnameR) & "\temp.log" swlog = New System.IO.StreamWriter(fnameL, False, System.Text.Encoding.Default) For i = 0 To nfile fnameR = flistR(i) fnameW = flistW(i) fnameF = flistF(i) sbuf = work(i).Split(delim) bboxv(0) = Integer.Parse(sbuf(0)) bboxv(1) = Integer.Parse(sbuf(1)) bboxv(2) = Integer.Parse(sbuf(2)) bboxv(3) = Integer.Parse(sbuf(3)) DINP(fnameR) 'データ入力 PRE() '計算前処理 iret = CALC(fnameW) '計算実行 dat = iret.ToString("0") dat = dat + " : " + System.IO.Path.GetFileName(fnameR) Select Case iret Case 0 : dat = dat & " : Normal end" Case 1 : dat = dat & " : USWL is NG." Case 2 : dat = dat & " : DSWL is NG." End Select swlog.WriteLine(dat) draw_xmin = 0.0 draw_xmax = TMAX draw_dx = 60.0 draw_ymin = CDbl(CInt(0.1 * ELB) - 1) * 10.0 draw_ymax = CDbl(CInt(0.1 * ELU) + 2) * 10.0 draw_dy = 10.0 fnameR = fnameW fnameW = System.IO.Path.GetDirectoryName(fnameR) + "\\gpl_temp.txt" WLSARCH(fnameR) GPLOT_surge(fnameR, fnameW, fnameF) '/************************************************************* 'gnuplot 起動+epsファイル作成 (fnameW: コマンド記述ファイル名) '/************************************************************* GPL(fnameW) System.Threading.Thread.Sleep(1000) '1秒待つ '/************************************************************* 'eps の BoundingBox 修正 (fnameF: eps画像ファイル名) '/************************************************************* fnameZ = fnameF.Replace("_eps_", "_eps_z_") BBOX(fnameF, fnameZ, bboxv) '/************************************************************* 'ImageMagick による png 画像作成 (fnameZ: eps画像ファイル名) '/************************************************************* IMCVT(fnameZ) '/************************************************************* 'ImageMagick による 白背景合成 (fnameZ: png画像ファイル名) '/************************************************************* fnameZ = fnameZ.Replace("eps", "png") IMCMP(fnameZ) System.Threading.Thread.Sleep(1000) '1秒待つ '/************************************************************* 'png 画像画面表示 (fnameZ: png画像ファイル名) '/************************************************************* fnameZ = fnameZ.Replace("_png_z_", "_png_zw_") VIEWPNG(fnameZ) Next i swlog.Close() MessageBox.Show("計算完了", "完了通知") End Sub Private Sub DINP(ByVal fnameR As String) Dim i As Integer Dim sr As System.IO.StreamReader Dim dat As String Dim sbuf() As String Dim delim As Char = ","c sr = New System.IO.StreamReader(fnameR, System.Text.Encoding.Default) dat = sr.ReadLine() : sbuf = dat.Split(delim) Title = sbuf(0) '計算ケースタイトル dat = sr.ReadLine() : sbuf = dat.Split(delim) ICT = Integer.Parse(sbuf(0)) '計算ケース設定(1:通常,2:AFC) AFCA = Double.Parse(sbuf(1)) 'AFC片側振幅流量(m3/s) AFCT = Double.Parse(sbuf(2)) 'AFC周期(s) dat = sr.ReadLine() : sbuf = dat.Split(delim) TMAX = Double.Parse(sbuf(0)) '計算打切時間 dt = Double.Parse(sbuf(1)) '計算時間間隔 DTWR = Double.Parse(sbuf(2)) '打出時間間隔 dat = sr.ReadLine() : sbuf = dat.Split(delim) PAA = Double.Parse(sbuf(0)) '制水口断面積 PCI = Double.Parse(sbuf(1)) '制水口流入時流量係数 PCO = Double.Parse(sbuf(2)) '制水口流出時流量係数 dat = sr.ReadLine() : sbuf = dat.Split(delim) RWL = Double.Parse(sbuf(0)) '貯水池水位標高 TNL = Double.Parse(sbuf(1)) 'トンネル延長 TNA = Double.Parse(sbuf(2)) 'トンネル断面積 TNC = Double.Parse(sbuf(3)) 'トンネル損失水頭係数 dat = sr.ReadLine() : sbuf = dat.Split(delim) NST = Integer.Parse(sbuf(0)) '立坑入力断面数 ReDim SAA(NST + 1) ReDim SEL(NST + 1) ReDim SLB(NST) For i = 1 To NST dat = sr.ReadLine() : sbuf = dat.Split(delim) SAA(i) = Double.Parse(sbuf(0)) '断面積 SEL(i) = Double.Parse(sbuf(1)) '指定断面下端標高 SLB(i) = sbuf(2) '立坑断面ラベル Next i dat = sr.ReadLine() : sbuf = dat.Split(delim) NQT = Integer.Parse(sbuf(0)) '流量設定点数 ReDim QTQ(NQT) ReDim QTI(NQT) For i = 1 To NQT dat = sr.ReadLine() : sbuf = dat.Split(delim) QTQ(i) = Double.Parse(sbuf(0)) '入力点流量 QTI(i) = Double.Parse(sbuf(1)) '入力点時刻 Next i sr.Close() End Sub Private Sub PRE() Dim i As Integer Dim j As Integer Dim wa As Double Dim wb As Double Dim wc As String QI = QTQ(1) Select Case ICT Case 1 : AFCS = -1.0 '通常 Case 2 : AFCS = QTI(2) 'AFC End Select '立坑断面順番の確認(低標高順) For i = 1 To NST - 1 For j = i + 1 To NST If SEL(i) >= SEL(j) Then '標高の小さい順に並び替え wa = SEL(j) wb = SAA(j) wc = SLB(j) SEL(j) = SEL(i) SAA(j) = SAA(i) SLB(j) = SLB(i) SEL(i) = wa SAA(i) = wb SLB(i) = wc End If Next j Next i ELB = SEL(1) '水槽下端標高 ELU = SEL(NST) '水槽上端標高 SAA(NST + 1) = SAA(NST) SEL(NST + 1) = SEL(NST) End Sub Private Function CALC(ByVal fnameW As String) As Integer Dim sw As System.IO.StreamWriter Dim dat As String Dim j As Integer Dim ic As Integer Dim np As Integer Dim npe As Integer Dim npw As Integer Dim iw As Integer Dim dto As Double Dim qn As Double Dim vi As Double Dim zi As Double Dim zo As Double Dim dts As Double Dim fa As Double Dim dv As Double Dim dz As Double Dim zw As Double Dim vw As Double Dim dti As Double Dim dtw As Double sw = New System.IO.StreamWriter(fnameW, False, System.Text.Encoding.Default) dat = "#" & Title : sw.WriteLine(dat) dat = "#経過時間,水槽水位,水路流速,水位変化,流量" : sw.WriteLine(dat) dat = "#(s),EL(m),(m/s),(m),(m3/s)" : sw.WriteLine(dat) np = CInt(DTWR / dt + 0.00001) '打出時間間隔内の計算step数*/ dto = dt '計算時間間隔*/ qn = QI '初期流量*/ vi = qn / TNA '初期トンネル流速*/ zi = TNC * vi * vi '初期損失水頭*/ If vi < 0.0 Then zi = -TNC * vi * vi '初期損失水頭符号確定*/ zo = RWL - zi '水槽内初期水位*/ '初期値出力(経過時間:0)*/ dts = 0.0 : zw = zo : vw = vi WOUT(sw, dts, zw, vw, zi, qn) '計算開始断面検索*/ For j = NST To 1 Step -1 If SEL(j) < zo Then Exit For Next j npe = j '計算開始断面番号*/ npw = 0 '打出時間間隔カウンタ初期化*/ dts = 0.0 '経過時間初期化*/ Do dts = dts + dto npw = npw + 1 fa = SAA(npe) RUNGE(qn, vi, zi, fa, dto, dv, dz, dts) zw = RWL - zi - dz iw = npe + 1 If iw > NST Then iw = NST If zw < SEL(npe) Or SEL(iw) < zw Then dti = 0.1 * dto For ic = 1 To 10 dtw = dti * CDbl(ic) + dts - dto zw = RWL - zi If SEL(npe + 1) < zw Then npe = npe + 1 If zw < SEL(npe) Then npe = npe - 1 If NST <= npe Then 'USWL超過のため計算打ち切り*/ dat = "#***** USWL is NG. *****" sw.WriteLine(dat) sw.Close() Return 1 End If If npe <= 0 Then 'DSWL未満のため計算打ち切り*/ dat = "#***** DSWL is NG. *****" sw.WriteLine(dat) sw.Close() Return 2 End If fa = SAA(npe) RUNGE(qn, vi, zi, fa, dti, dv, dz, dtw) vi = vi + dv zi = zi + dz Next ic Else vi = vi + dv zi = zi + dz End If '打出時間間隔到達による出力*/ If npw >= np Then npw = 0 zw = RWL - zi vw = vi WOUT(sw, dts, zw, vw, zi, qn) End If Loop While dts < TMAX sw.Close() Return 0 End Function Private Sub WOUT(ByVal sw As System.IO.StreamWriter, ByVal dts As Double, ByVal zw As Double, ByVal vw As Double, ByVal zi As Double, ByVal qn As Double) Dim dat As String '計算結果書込 dat = dts.ToString("e") dat = dat & "," & zw.ToString("e") dat = dat & "," & vw.ToString("e") dat = dat & "," & zi.ToString("e") dat = dat & "," & qn.ToString("e") sw.WriteLine(dat) End Sub Private Sub RUNGE(ByRef qo As Double, ByVal vo As Double, ByVal zo As Double, _ ByVal fa As Double, ByVal dtt As Double, _ ByRef dv As Double, ByRef dz As Double, ByVal dts As Double) Dim wrk As Double Dim dz0 As Double Dim dv0 As Double Dim cf As Double Dim dtw As Double Dim v1 As Double Dim z1 As Double Dim dv1 As Double Dim dz1 As Double Dim dv2 As Double Dim dz2 As Double Dim dv3 As Double Dim dz3 As Double wrk = 0.0 dz0 = dtt * FZ(vo, qo, fa) cf = PCI * PAA If dz0 > 0.0 Then cf = PCO * PAA wrk = FK(vo, qo, cf) dv0 = dtt * FV(zo, vo, wrk) v1 = vo + 0.5 * dv0 z1 = zo + 0.5 * dz0 dtw = dts - dtt * 0.5 qo = QNCAL(dtw) wrk = FK(v1, qo, cf) dv1 = dtt * FV(z1, v1, wrk) dz1 = dtt * FZ(v1, qo, fa) v1 = vo + 0.5 * dv1 z1 = zo + 0.5 * dz1 wrk = FK(v1, qo, cf) dv2 = dtt * FV(z1, v1, wrk) dz2 = dtt * FZ(v1, qo, fa) v1 = vo + dv2 z1 = zo + dz2 dtw = dts qo = QNCAL(dtw) wrk = FK(v1, qo, cf) dv3 = dtt * FV(z1, v1, wrk) dz3 = dtt * FZ(v1, qo, fa) dv = (dv0 + 2.0 * dv1 + 2.0 * dv2 + dv3) / 6.0 dz = (dz0 + 2.0 * dz1 + 2.0 * dz2 + dz3) / 6.0 End Sub Private Function FZ(ByVal v As Double, ByVal q As Double, ByVal fa As Double) As Double ' Calculation of dz */ Return (q - TNA * v) / fa End Function Private Function FK(ByVal v As Double, ByVal q As Double, ByVal cf As Double) As Double ' Calculation of k */ Return Math.Abs((TNA * v - q) / cf) * (TNA * v - q) / cf / 2.0 / g End Function Private Function FV(ByVal z As Double, ByVal v As Double, ByVal wrk As Double) As Double ' Calculation of dv */ Return (z - TNC * Math.Abs(v) * v - wrk) / TNL * g End Function Private Function QNCAL(ByVal tt As Double) As Double Dim i As Integer Dim qn As Double qn = 0.0 If tt >= AFCS Then For i = 2 To NQT If QTI(i - 1) < tt And tt <= QTI(i) Then qn = QTQ(i - 1) + (QTQ(i) - QTQ(i - 1)) / (QTI(i) - QTI(i - 1)) * (tt - QTI(i - 1)) Exit For End If Next i Else qn = QI + AFCA * Math.Sin(2.0 * pi * tt / AFCT) End If Return (qn) End Function Private Sub WLSARCH(ByVal fnameR As String) Dim sr As System.IO.StreamReader Dim dat As String Dim sbuf() As String Dim delim As Char = ","c Dim wa As Double Dim wb As Double WLmax = ELB : TTmax = 0.0 WLmin = ELU : TTmin = 0.0 sr = New System.IO.StreamReader(fnameR, System.Text.Encoding.Default) Do Until sr.EndOfStream dat = sr.ReadLine() If dat.Substring(0, 1) <> "#" Then sbuf = dat.Split(delim) wa = Double.Parse(sbuf(0)) wb = Double.Parse(sbuf(1)) If WLmax < wb Then WLmax = wb : TTmax = wa End If If wb < WLmin Then WLmin = wb : TTmin = wa End If End If Loop sr.Close() End Sub Private Sub GPLOT_surge(ByVal fnameR As String, ByVal fnameW As String, ByVal fnameF As String) Dim sw As System.IO.StreamWriter Dim dat As String Dim i As Integer Dim xx As Double Dim yy As Double Dim strdx As Double strdx = 0.2 * (draw_xmax - draw_xmin) '***************************/ 'gnuplot制御用ファイル作成*/ '***************************/ sw = New System.IO.StreamWriter(fnameW, False, System.Text.Encoding.Default) '出力ファイル定義*/ dat = "set terminal postscript eps" : sw.WriteLine(dat) dat = String.Format("set output ""{0:s}""", System.IO.Path.GetFileName(fnameF)) : sw.WriteLine(dat) dat = "set size ratio 0.6" : sw.WriteLine(dat) 'データファイル区切り文字定義*/ dat = "set datafile separator "",""" : sw.WriteLine(dat) '水槽断面ラベル・セット*/ For i = 1 To NST xx = 1.0 yy = (SEL(i) - draw_ymin) / (draw_ymax - draw_ymin) + 0.02 dat = String.Format("set label {0:d} ""{1:s} EL.{2:F3} "" at graph {3:F3},graph {4:F3} right", i, SLB(i), SEL(i), xx, yy) : sw.WriteLine(dat) Next i '貯水池水位表示・セット*/ xx = 1.0 yy = (RWL - draw_ymin) / (draw_ymax - draw_ymin) + 0.02 dat = String.Format("set label {0:d} ""{1:s} EL.{2:F3} "" at graph {3:F3},graph {4:F3} right", i, "RWL", RWL, xx, yy) : sw.WriteLine(dat) '最高水位表示・セット*/ i = i + 1 xx = (TTmax - draw_xmin) / (draw_xmax - draw_xmin) yy = (WLmax - draw_ymin) / (draw_ymax - draw_ymin) + 0.02 dat = String.Format("set label {0:d} "" {1:F3} ({2:F1}s)"" at graph {3:F3},graph {4:F3} left", i, WLmax, TTmax, xx, yy) : sw.WriteLine(dat) '最低水位表示・セット*/ i = i + 1 xx = (TTmin - draw_xmin) / (draw_xmax - draw_xmin) yy = (WLmin - draw_ymin) / (draw_ymax - draw_ymin) + 0.02 dat = String.Format("set label {0:d} "" {1:F3} ({2:F1}s)"" at graph {3:F3},graph {4:F3} left", i, WLmin, TTmin, xx, yy) : sw.WriteLine(dat) 'タイトル・セット*/ i = i + 1 dat = "set tmargin 2" : sw.WriteLine(dat) dat = String.Format("set label {0:d} "" {1:s}"" at graph 0.0,graph 1.03 left", i, Title) : sw.WriteLine(dat) '2本の直線(nohead矢印)による実線の表示*/ dat = "set style arrow 2 size graph 0.05,20 filled nohead linewidth 3 linetype 2" : sw.WriteLine(dat) dat = "set style arrow 3 size graph 0.05,20 filled nohead linewidth 3 linetype 5" : sw.WriteLine(dat) dat = "set style arrow 4 size graph 0.05,20 filled nohead linewidth 1 linetype 1" : sw.WriteLine(dat) For i = 1 To NST yy = SEL(i) dat = String.Format("set arrow as 2 from {0:F3},{1:F3} to {2:F3},{3:F3}", draw_xmin, yy, draw_xmax, yy) : sw.WriteLine(dat) Next i yy = RWL dat = String.Format("set arrow as 3 from {0:F3},{1:F3} to {2:F3},{3:F3}", draw_xmin, yy, draw_xmax, yy) : sw.WriteLine(dat) xx = TTmax yy = WLmax dat = String.Format("set arrow as 4 from {0:F3},{1:F3} to {2:F3},{3:F3}", xx, yy, xx + strdx, yy) : sw.WriteLine(dat) xx = TTmin yy = WLmin dat = String.Format("set arrow as 4 from {0:F3},{1:F3} to {2:F3},{3:F3}", xx, yy, xx + strdx, yy) : sw.WriteLine(dat) '軸ラベル定義*/ dat = String.Format("set xlabel ""{0:s}""", "Time (sec)") : sw.WriteLine(dat) dat = String.Format("set ylabel ""{0:s}""", "Elevation (m)") : sw.WriteLine(dat) 'x軸定義*/ dat = String.Format("set xtics {0:F3}", draw_dx) : sw.WriteLine(dat) dat = String.Format("set format x ""{0:s}""", "%.0f") : sw.WriteLine(dat) 'y軸定義*/ dat = String.Format("set ytics {0:F3}", draw_dy) : sw.WriteLine(dat) dat = String.Format("set format y ""{0:s}""", "%.0f") : sw.WriteLine(dat) '軸範囲定義*/ dat = String.Format("set xrange [{0:F3}:{1:F3}]", draw_xmin, draw_xmax) : sw.WriteLine(dat) dat = String.Format("set yrange [{0:F3}:{1:F3}]", draw_ymin, draw_ymax) : sw.WriteLine(dat) '軸グリッド描画設定*/ dat = "set grid xtics ytics mxtics mytics" : sw.WriteLine(dat) 'プロット実行(プロットは各種定義が終わって最後に実行)*/ dat = String.Format("plot ""{0:s}"" using 1:2 with lines linewidth 3 linetype 1 notitle", System.IO.Path.GetFileName(fnameR)) : sw.WriteLine(dat) 'GNUPLOT 終了*/ dat = "quit" : sw.WriteLine(dat) sw.Close() End Sub Private Sub GPL(ByVal fnameR As String) '***************************************************** 'gnuplot 起動+epsファイル作成 '***************************************************** Dim pr As System.Diagnostics.Process Dim sw As System.IO.StreamWriter Dim dir As String = "" Dim fname As String = "" Dim dat As String = "" dir = System.IO.Path.GetDirectoryName(fnameR) System.IO.Directory.SetCurrentDirectory(dir) fname = System.IO.Path.GetFileName(fnameR) pr = New System.Diagnostics.Process() pr.StartInfo.FileName = "gnuplot.exe" pr.StartInfo.RedirectStandardInput = True pr.StartInfo.RedirectStandardOutput = True pr.StartInfo.UseShellExecute = False pr.StartInfo.CreateNoWindow = True pr.Start() sw = pr.StandardInput dat = String.Format("load ""{0:s}""", fname) sw.WriteLine(dat) sw.Close() pr.WaitForExit() pr.Close() End Sub '-------------------------------------------------------------------------------------------- Private Sub BBOX(ByVal fnameR As String, ByVal fnameW As String, ByRef bboxv() As Integer) Dim sr As System.IO.StreamReader Dim sw As System.IO.StreamWriter Dim dat As String Dim i As Integer 'データ入力 sr = New System.IO.StreamReader(fnameR, System.Text.Encoding.Default) sw = New System.IO.StreamWriter(fnameW, False, System.Text.Encoding.Default) i = 0 Do Until sr.EndOfStream i = i + 1 dat = sr.ReadLine() If i = 6 Then dat = String.Format("%%BoundingBox: {0:D} {1:D} {2:D} {3:D}", bboxv(0), bboxv(1), bboxv(2), bboxv(3)) sw.WriteLine(dat) Loop sr.Close() sw.Close() End Sub '-------------------------------------------------------------------------------------------- Private Sub IMCVT(ByVal fnameF As String) '***************************************************** 'ImageMagick convert で png 画像作成 '***************************************************** Dim fnameP As String Dim pr As System.Diagnostics.Process Dim sw As System.IO.StreamWriter Dim dat As String = "" fnameP = fnameF.Replace("eps", "png") pr = New System.Diagnostics.Process() pr.StartInfo.FileName = "cmd.exe" pr.StartInfo.RedirectStandardInput = True pr.StartInfo.RedirectStandardOutput = True pr.StartInfo.UseShellExecute = False pr.StartInfo.CreateNoWindow = True pr.Start() sw = pr.StandardInput dat = String.Format("convert -density 300 {0:s} {1:s}", fnameF, fnameP) sw.WriteLine(dat) sw.Close() pr.WaitForExit() pr.Close() End Sub '-------------------------------------------------------------------------------------------- Private Sub IMCMP(ByVal fnameZ As String) '***************************************************** 'ImageMagick convert で 白背景合成画像作成 '***************************************************** Dim fnameP As String Dim fnameB As String Dim pr As System.Diagnostics.Process Dim sw As System.IO.StreamWriter Dim dat As String = "" Dim img As Image Dim ww As Integer Dim hh As Integer img = Image.FromFile(fnameZ) ww = img.Width hh = img.Height img.Dispose() fnameP = fnameZ.Replace("_z_", "_zw_") fnameB = System.IO.Path.GetDirectoryName(fnameP) & "\base.png" pr = New System.Diagnostics.Process() pr.StartInfo.FileName = "cmd.exe" pr.StartInfo.RedirectStandardInput = True pr.StartInfo.RedirectStandardOutput = True pr.StartInfo.UseShellExecute = False pr.StartInfo.CreateNoWindow = True pr.Start() sw = pr.StandardInput dat = String.Format("convert -size {0:D}x{1:D} xc:""#FFFFFF"" {2:s}", ww, hh, fnameB) sw.WriteLine(dat) dat = String.Format("convert {0:s} {1:s} -composite {2:s}", fnameB, fnameZ, fnameP) sw.WriteLine(dat) sw.Close() pr.WaitForExit() pr.Close() End Sub '-------------------------------------------------------------------------------------------- Private Sub VIEWPNG(ByVal fnameZ As String) '***************************************************** 'png 画像画面表示 (50%縮尺) '***************************************************** Dim img As Image Dim bmp As Bitmap Dim g As Graphics Dim ratio As Single = 0.5 Dim ww As Integer Dim hh As Integer Dim w_org As Integer Dim h_org As Integer img = Image.FromFile(fnameZ) w_org = img.Width h_org = img.Height ww = CInt(ratio * w_org) hh = CInt(ratio * h_org) PictureBox1.Size = New Size(ww, hh) bmp = New Bitmap(ww, hh) PictureBox1.Image = bmp g = Graphics.FromImage(PictureBox1.Image) g.DrawImage(img, 0, 0, ww, hh) g.Dispose() img.Dispose() PictureBox1.Left = 0 PictureBox1.Top = ToolStrip1.Height Me.ClientSize = New Size(PictureBox1.Width, PictureBox1.Height + ToolStrip1.Height + StatusStrip1.Height) ToolStripStatusLabel1.Text = String.Format("{0:D} x {1:D} : {2:s}", w_org, h_org, fnameZ) End Sub End Class