Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/visual-studio-2010/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vb.net 我如何扩展这个函数?_Vb.net_Visual Studio 2010_Scrollbar - Fatal编程技术网

Vb.net 我如何扩展这个函数?

Vb.net 我如何扩展这个函数?,vb.net,visual-studio-2010,scrollbar,Vb.net,Visual Studio 2010,Scrollbar,我创建了一个重新着色函数来重新着色我的图片框 我的函数是红色的,它把所有的东西都变成红色 但是现在我想输入一些滚动条函数来控制它 如果我想要3个代表R,G,B的滚动条 根据我目前的职能,我如何才能做到这一点 Try ' Retrieve the image. image1 = New Bitmap("C:\Users\Anons\Desktop\Winter.jpg", True) Dim x, y As Integer

我创建了一个重新着色函数来重新着色我的图片框

我的函数是红色的,它把所有的东西都变成红色

但是现在我想输入一些滚动条函数来控制它

如果我想要3个代表R,G,B的滚动条

根据我目前的职能,我如何才能做到这一点

    Try
        ' Retrieve the image.
        image1 = New Bitmap("C:\Users\Anons\Desktop\Winter.jpg", True)

        Dim x, y As Integer

        ' Loop through the images pixels to reset color.
        For x = 0 To image1.Width - 1
            For y = 0 To image1.Height - 1
                Dim pixelColor As Color = image1.GetPixel(x, y)
                Dim newColor As Color = _
                    Color.FromArgb(pixelColor.R, 0, 0)
                image1.SetPixel(x, y, newColor)
            Next
        Next

        ' Set the PictureBox to display the image.
        PictureBox1.Image = image1

        ' Display the pixel format in Label1.
        Label1.Text = "Pixel format: " + image1.PixelFormat.ToString()

    Catch ex As ArgumentException
        MessageBox.Show("There was an error." _
            & "Check the path to the image file.")
    End Try
End Sub$

只需将所有三个颜色分量(R、G和B)乘以由滚动条确定的分数因子即可。例如,系数为1将使其保持相同的颜色。因子0.5将使颜色亮度减半。系数为2会使其亮度加倍,等等

Dim rFactor As Single = rScroll.Value / 100
Dim gFactor As Single = gScroll.Value / 100
Dim bFactor As Single = bScroll.Value / 100
Dim newColor As Color = Color.FromArgb(pixelColor.R * rFactor, pixelColor.R * gFactor, pixelColor.B * bFactor)

我是否在函数中声明这些因子?我已经在示例中演示了如何声明它们。您在理解示例的哪一部分时遇到困难?