我的pixBox1已修复,无法更改图像
和pixBox2没有修复,可以改变颜色并在这里旋转
我使用OpenFileDialog函数将图像放入那些pixbox
所以现在我如何将这两个pixbox组合到我的pixbox3中?
我试试这个,但它看起来不会起作用:
Dim image As New Bitmap(pixBox1.Image)
Dim image2 As New Bitmap(pixBox2.Image)
Dim Image3 As New Bitmap(300, 300)
Dim g As Graphics = Graphics.FromImage(Image3)
g.DrawImage(image1, New Point(300, 300))
g.DrawImage(image2, New Point(300, 300))
g.Dispose()
g = Nothing
pixBox3.Image = Image3
答案 0 :(得分:0)
这有点丑陋和缓慢,但它基本上将image2
中的所有像素设置为50%透明,然后将其绘制在Image
的顶部。
Dim image As New Bitmap(pixBox1.Image)
Dim image2 As New Bitmap(pixBox2.Image)
Dim Image3 As New Bitmap(300, 300)
Using g As Graphics = Graphics.FromImage(Image3)
'make 2nd bmp translucent
For Integer Xcount = 0 To image2.Width - 1
For Integer Ycount = 0 To image2.Height - 1
Dim c as Color = image2.GetPixel(Xcount, Ycount)
c = Color.FromARGB(125, c.R, c.G, c.B) '50% alpha
image2.SetPixel(Xcount, Ycount, c)
Next
Next
g.DrawImage(image1, New Point(0, 0))
g.DrawImage(image2, New Point(0, 0))
End Using
pixBox3.Image = Image3
作为旁注,Using
块确保无论发生什么情况都会处置g
。