ff2
Public Class Form02_GaussianBlur
Dim bbb As Bitmap = New Bitmap("./test1.bmp")
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
init_label()
PictureBox1.Image = bbb
End Sub
' ラベル初期値設定
Private Sub init_label()
Label5.Text = "原画像"
Label6.Text = "パラメータ=2"
Label7.Text = "パラメータ=4"
Label8.Text = "パラメータ=8"
Label10.Text = "所要時間(ms)"
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
' Bitmapオブジェクト生成
Dim bmp As Bitmap
If PictureBox1.Image Is Nothing = True Then
' Bitmapを新規生成
bmp = New Bitmap(512, 512)
Else
' BitmapをpictureBoxから取得
bmp = New Bitmap(PictureBox1.Image)
End If
' Bitmap処理の高速化開始
Dim bmpP As Module01_BitmapPlus = New Module01_BitmapPlus(bmp)
bmpP.BeginAccess()
For i As Integer = 0 To bmp.Width - 1
For j As Integer = 0 To bmp.Height - 1
' Bitmapの色取得
'Dim bmpCol As Color = bmp.GetPixel(i, j)
Dim bmpCol As Color = bmpP.GetPixel(i, j)
If bmpCol.R = 0 Then
' Bitmapの色設定
'bmp.SetPixel(i, j, Color.FromArgb(255, 255, 0, 0))
bmpP.SetPixel(i, j, Color.FromArgb(255, 255, 0, 0))
Else
'bmp.SetPixel(i, j, Color.FromArgb(255, 0, 0, 0))
bmpP.SetPixel(i, j, Color.FromArgb(255, 0, 0, 0))
End If
Next
Next
' Bitmap処理の高速化終了
bmpP.EndAccess()
PictureBox1.Image = bmp
End Sub
' 原画像表示、ガウスぼかし画像(パラメータ2,4,8)を表示
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles btn_GaussianBlur.Click
Dim start_ As Integer = System.Environment.TickCount
'If TextBox1.Text = "" Then Return
Dim fname As String = TextBox1.Text
Dim bmp As Image = Nothing
Dim tmp As Bitmap = Nothing
bmp = bbb
' パラメータ2のガウスぼかし画像を表示
If Not PictureBox2.Image Is Nothing Then
PictureBox2.Image.Dispose()
PictureBox2.Image = Nothing
End If
tmp = GaussianBlurXY(bmp, 2)
If tmp Is Nothing Then
Return
End If
PictureBox2.Image = tmp
PictureBox2.Refresh()
' パラメータ4のガウスぼかし画像を表示
If Not PictureBox3.Image Is Nothing Then
PictureBox3.Image.Dispose()
PictureBox3.Image = Nothing
End If
tmp = GaussianBlurXY(bmp, 4)
If tmp Is Nothing Then
Return
End If
PictureBox3.Image = tmp
PictureBox3.Refresh()
' パラメータ8のガウスぼかし画像を表示
If Not PictureBox4.Image Is Nothing Then
PictureBox4.Image.Dispose()
PictureBox4.Image = Nothing
End If
tmp = GaussianBlurXY(bmp, 8)
If tmp Is Nothing Then
Return
End If
PictureBox4.Image = tmp
PictureBox4.Refresh()
Dim end_ As Integer = System.Environment.TickCount
Label10.Text = "所要時間:" & (end_ - start_) & "(ms)"
End Sub
End Class