Vb.net 在visual basic中刷新picturebox图像

Vb.net 在visual basic中刷新picturebox图像,vb.net,Vb.net,我正在编写一个编辑图片的程序,我有一个图片框,在这里我加载一个位图,第一个图像加载很好,但是如果我想加载第二个图像,第二个图像不会加载,第一个图像保持不变,它不会刷新。如何使用2个不同的位图更改图片框中的图像 我有PictureBox3.Image=bm,其中bm是一个位图变量,它可以很好地加载,但是如果我按其他按钮在PictureBox3.Image=bm2中加载另一个位图,它将不会加载 Private Sub Button3_Click(sender As Object, e As Even

我正在编写一个编辑图片的程序,我有一个图片框,在这里我加载一个位图,第一个图像加载很好,但是如果我想加载第二个图像,第二个图像不会加载,第一个图像保持不变,它不会刷新。如何使用2个不同的位图更改图片框中的图像

我有PictureBox3.Image=bm,其中bm是一个位图变量,它可以很好地加载,但是如果我按其他按钮在PictureBox3.Image=bm2中加载另一个位图,它将不会加载

Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
    Dim clr As Integer
    Dim ymax As Integer
    Dim xmax As Integer
    Dim x As Integer
    Dim y As Integer
    Dim bm As Bitmap = PictureBox1.Image
    xmax = bm.Width - 1
    ymax = bm.Height - 1
    For y = 0 To ymax
        For x = 0 To xmax
            With bm.GetPixel(x, y)
                clr = 0.21 * .R + 0.72 * .G + 0.07 * .B
            End With
            bm.SetPixel(x, y, _
            Color.FromArgb(255, clr, clr, clr))
        Next x
    Next y
    PictureBox3.Image = bm
End Sub

Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
    Dim clr As Integer
    Dim ymax As Integer
    Dim xmax As Integer
    Dim x As Integer
    Dim y As Integer
    Dim bm2 As Bitmap = PictureBox1.Image
    xmax = bm2.Width - 1
    ymax = bm2.Height - 1
    For y = 0 To ymax
        For x = 0 To xmax
            With bm2.GetPixel(x, y)
                clr = (1 * .R + 1 * .G + 1 * .B) / 3
            End With
            bm2.SetPixel(x, y, _
            Color.FromArgb(255, clr, clr, clr))
        Next x
    Next y
    PictureBox3.Image = bm2
End Sub

期末班

对你的答案添加一些评论?这个答案是你需要的解决方案吗?
Dim bm2 As Bitmap = new Bitmap(PictureBox1.Image)