Private Sub Form1_Load(ByVal sender As System.Object, ByVal _
e As System.EventArgs) Handles MyBase.Load
Dim bm_src1 As Bitmap = picSource1.Image.Clone
Dim bm_src2 As Bitmap = picSource2.Image.Clone
Dim bm_out As New Bitmap(bm_src1.Width, bm_src1.Height)
Dim gr As Graphics = Graphics.FromImage(bm_out)
' Give the images alpha gradients.
Dim alpha As Integer
For x As Integer = 0 To bm_src1.Width - 1
alpha = (255 * x) \ bm_src1.Width
For y As Integer = 0 To bm_src1.Height - 1
Dim clr As Color = bm_src1.GetPixel(x, y)
clr = Color.FromArgb(alpha, clr.R, clr.G, clr.B)
bm_src1.SetPixel(x, y, clr)
clr = bm_src2.GetPixel(x, y)
clr = Color.FromArgb(255 - alpha, clr.R, clr.G, _
clr.B)
bm_src2.SetPixel(x, y, clr)
Next y
Next x
' Draw the images onto the result.
gr.DrawImage(bm_src1, 0, 0)
gr.DrawImage(bm_src2, 0, 0)
' Display the result.
picResult.Image = bm_out
End Sub
|