Option Strict On Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim dialog As New OpenFileDialog dialog.Filter = "画像ファイル(*.jpg *.gif *.bmp)|*.jpg;*.gif;*.bmp" If dialog.ShowDialog() = Windows.Forms.DialogResult.OK Then PictureBox1.Image = Image.FromFile(dialog.FileName) End If End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click 'PictureBox1の画像にモザイクをかけた画像を生成します。 'この段階では画像はメモリ上にあり、表示は変化しません。 Dim result As Image = Mosaic(PictureBox1.Image, 10) '生成した画像をPictureBox2に表示させます。 PictureBox2.Image = result End Sub Private Sub NumericUpDown1_ValueChanged(sender As Object, e As EventArgs) Handles NumericUpDown1.ValueChanged Dim result As Image = Mosaic(PictureBox1.Image, CInt(Math.Max(NumericUpDown1.Value, 2))) PictureBox2.Image = result End Sub