我尝试过,但是我的代码在这里不起作用
Private Sub PictureBox3_Paint(sender As Object, e As PaintEventArgs) Handles PictureBox3.Paint
Dim pencolor As String
pencolor = "89; 179; 105"
Dim s(1) As Integer
Dim f(1) As Integer
Dim pen As Pen = Pens.pencolor
End Sub
谢谢!
答案 0 :(得分:0)
要在笔上使用自定义颜色,您需要先为笔创建画笔。
在此示例中,我假设RGB颜色值是您字符串中的序列。
Dim r As Integer = 89
Dim g As Integer = 179
Dim b As Integer = 105
Dim customColour As Color = Color.FromArgb(r, g, b)
Using customBrush As New SolidBrush(customColour)
Using customPen As New Pen(customBrush)
' use the custom pen...
End Using
End Using
使用自定义颜色创建画笔,然后使用画笔创建自定义笔。使用笔时,它的颜色将由您的R,G,B值定义
编辑 (感谢Ahmed Abdelhameed提醒其他构造函数)
还可以通过简单地在构造函数中指定所需的颜色来创建Pen
,而无需使用画笔:
Dim customPen As New Pen(Color.FromArgb(r, g, b))