-2

我想知道如何在我的项目中更正此功能,

我的计划是

让我的 picBox2 变成位图

从中获取 RGB 像素

然后把它放回一个新的位图之后我可以使用这个函数来转换我的图像的颜色

我是这样写的:

    For row = 1 To 300
        For col = 1 To 300
            'MsgBox(row, MsgBoxStyle.YesNo + MsgBoxStyle.Question, "DEBUGSHIT")

            PixelColor = BitMapforRGB.GetPixel(row, col)
            PixelColor = BitMapforRGB.GetPixel(row, col)

            R = (PixelColor.R + vsbRed.Value) * 0.5
            G = (PixelColor.G + vsbGreen.Value) * 0.5
            B = (PixelColor.B + vsbBlue.Value) * 0.5

            Dim newColor As New Color
            newColor = Color.FromArgb(R, G, B)

            RGBtoBitmap.SetPixel(row, col, newColor)

        Next
    Next

    'I try to change it to 
    'Dim MyShade As Color = ColorTranslator.FromOle(
    '   RGB(Red(row,col),Green(row,col),Blue(row,col))
    'but it seem not right.

    Dim reColor As New Bitmap(Me.pixBox2.Image)
    pixBox2.Image = reColor
End Sub

ps:这个错误是Parameter must be positive and < Height.

参数名称:y

4

1 回答 1

1

您应该从 0 迭代到图像的大小。即 0 到BitMapforRGB.Width-1for col

于 2012-12-01T05:56:52.650 回答