PictureBox1 PictureBox2 Button 1と2と3を貼る
Button1 ----> そのままコピー / Button2 ----> グレーに / Button3 ----> 黒色に
Private Sub Button1_Click(....
Dim bmp As Bitmap
Dim bmpDest As Bitmap
Dim i , j As Integer
Dim col As Color
bmp = New Bitmap(PictureBox1.Image)
bmpDest = New Bitmap(Picturebox1.Width , PictureBox1.Height )
For i = 0 To PictureBox1.Width - 1
For j = 0 To PictureBox1.Height - 1
col = bmp.GetPixel( i , j )
bmpDest.SetPixel( i , j , col )
Next
Next
PictureBox2.Image = bmpDest
End Sub
Private Sub Button2_Click(....
Dim bmp As Bitmap
Dim bmpDest As Bitmap
Dim i , j , lv As Integer
Dim col As Color
Dim colDest As Color
bmp = New Bitmap(PictureBox1.Image)
bmpDest = New Bitmap( PictureBox1.width , PictureBox1.Height )
For i = 0 To PictureBox1.Width - 1
For j = 0 To PictureBox1.Height - 1
col = bmp.GetPixel( i , j )
lv = (( col.R * 1.0 ) + ( col.G * 1.0 ) + ( col.B * 1.0 )) / 3.0
If lv > 255 Then
lv = 255
End If
colDest = color.FromArgb( lv , lv , lv )
bmpDest.SetPixel( i , j , colDest )
Next
Next
PictureBox2.Image = bmpDest
End Sub
Private Sub Button3_Click( .....
Dim bmp As Bitmap
Dim bmpDest As Bitmap
Dim i , j , l , m , lv , lvz As Integer
Dim col As Color
Dim colDest As Color
bmp = New Bitmap( PictureBox1.Image )
bmpDest = New Bitmap( PictureBox1.width , PictureBox1.Height )
For i = 0 To PictureBox1.Width - 1 Step 4
For j = 0 To PictureBox1.Height - 1 Step 4
lv = 0
For l = 0 To 3
For m = 0 To 3
col = bmp.GetPixel( i + 1 , j + m )
lv = lv + col.R
Next
Next
lvz = lv / ( 4 * 4 )
colDest = Color.FromArgb( lvz , lvz , lvz )
For l = 0 To 3
For m = 0 To 3
bmpDest.SetPixel( i + l , j + m , colDest )
Next
Next
Next
Next
PictureBox2.Image = bmpDest
End Sub
0 件のコメント:
コメントを投稿