hi, i want to make image blending, when I worked in accordance with the formula, but there is an error as shown below, how do I fix it??
![Name: Untitled.png
Views: 24
Size: 34.3 KB]()
Private Sub btnBlending_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBlending.Click
Dim X As Long = 0
Dim Y As Long = 0
Dim jR, JG, JB As Integer
Dim jR1, JG1, JB1 As Double
Dim jR2, JG2, JB2 As Double
Dim Amount As Byte = 50
Dim tcolor1, tcolor2 As System.Drawing.Color
Dim image1 As New Bitmap(PictureBox1.Image)
Dim image2 As New Bitmap(PictureBox2.Image)
Dim image3 As New Bitmap(1280)
Using g As Graphics = Graphics.FromImage(image3)
For X = 0 To image1.Width - 1
For Y = 0 To image1.Height - 1
tcolor1 = image1.GetPixel(X, Y)
jR1 = tcolor1.R
JG1 = tcolor1.G
JB1 = tcolor1.B
tcolor2 = image2.GetPixel(X, Y)
jR2 = tcolor2.R
JG2 = tcolor2.G
JB2 = tcolor2.B
jR = ((jR1 * 0.5) + (jR2 * 0.5))
JG = ((JG1 * 0.5) + (JG2 * 0.5))
JB = ((JB1 * 0.5) + (JB2 * 0.5))
image3.SetPixel(X, Y, Color.FromArgb(jR, JG, JB))
Next
Next
g.DrawImage(image1, New Point(0, 0))
g.DrawImage(image2, New Point(0, 0))
End Using
PictureBox3.Image = image3
PictureBox3.Refresh()
End Sub
Private Sub btnBlending_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBlending.Click
Dim X As Long = 0
Dim Y As Long = 0
Dim jR, JG, JB As Integer
Dim jR1, JG1, JB1 As Double
Dim jR2, JG2, JB2 As Double
Dim Amount As Byte = 50
Dim tcolor1, tcolor2 As System.Drawing.Color
Dim image1 As New Bitmap(PictureBox1.Image)
Dim image2 As New Bitmap(PictureBox2.Image)
Dim image3 As New Bitmap(1280)
Using g As Graphics = Graphics.FromImage(image3)
For X = 0 To image1.Width - 1
For Y = 0 To image1.Height - 1
tcolor1 = image1.GetPixel(X, Y)
jR1 = tcolor1.R
JG1 = tcolor1.G
JB1 = tcolor1.B
tcolor2 = image2.GetPixel(X, Y)
jR2 = tcolor2.R
JG2 = tcolor2.G
JB2 = tcolor2.B
jR = ((jR1 * 0.5) + (jR2 * 0.5))
JG = ((JG1 * 0.5) + (JG2 * 0.5))
JB = ((JB1 * 0.5) + (JB2 * 0.5))
image3.SetPixel(X, Y, Color.FromArgb(jR, JG, JB))
Next
Next
g.DrawImage(image1, New Point(0, 0))
g.DrawImage(image2, New Point(0, 0))
End Using
PictureBox3.Image = image3
PictureBox3.Refresh()
End Sub