注册 登录
编程论坛 VB.NET论坛

【求助】帮我看看代码有没有什么问题

vbnetfans 发布于 2008-06-11 13:59, 1051 次点击
的窗体放上一个PictureBox和一个按钮  要做一个“图片逆反”的效果   下面代码运行后为什么没效果
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim tuxing As System.Drawing.Bitmap
        Dim color1 As System.Drawing.Color
        Dim color2 As System.Drawing.Color
        Dim i, j As Integer
        Dim g1 As System.Drawing.Graphics
        g1 = PictureBox1.CreateGraphics
        tuxing = PictureBox1.Image
        For i = 0 To PictureBox1.Image.Size.Width - 1
            For j = 0 To PictureBox1.Image.Size.Height - 1
                color1 = tuxing.GetPixel(i, j)
                color2 = Color.FromArgb(255 - color1.A, 255 - color1.B, 255 - color1.G, 255 - color1.R)
                tuxing.SetPixel(i, j, color1)
            Next j
            PictureBox1.Refresh()
        Next i


    End Sub
1 回复
#2
mthupc2008-07-20 20:12
呵呵
程序很不错,
tuxing.SetPixel(i, j, color1)改为
tuxing.SetPixel(i, j, color2)就有意思了
1