189 8069 5689

vb.netrgb的简单介绍

VB.NET 获取当前鼠标点的RGB

Private Sub PictureBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown

雁江网站制作公司哪家好,找成都创新互联!从网页设计、网站建设、微信开发、APP开发、成都响应式网站建设公司等网站项目制作,到程序开发,运营维护。成都创新互联从2013年成立到现在10年的时间,我们拥有了丰富的建站经验和运维经验,来保证我们的工作的顺利进行。专注于网站建设就选成都创新互联

Dim GetColor As Color = CType(PictureBox1.Image, Bitmap).GetPixel(e.X, e.Y)

TextBox3.Text = GetColor.B.ToString

TextBox2.Text = GetColor.G.ToString

TextBox1.Text = GetColor.R.ToString

End Sub

VBNET怎么获取控件颜色的RGB值,又怎么用RGB将颜色赋给控件颜色。

R/G/B值最小是0最大是255属Byte值类型

Dim cr As Color = 控件.BackColor '获取控件背景色

Dim alpha As Byte = cr.A '透明度

Dim R As Byte = cr.R 'R值

Dim G As Byte = cr.G 'G值

Dim B As Byte = cr.B 'B值

Dim outAcr As Color = Color.FromArgb(alpha, R, G, B) '创建带有透明通道的ARGB颜色

Dim outcr As Color = Color.FromArgb(R, G, B) '创建不透明的RGB颜色

在vb.net里,这行代码是错误的:Label4.ForeColor = RGB(255, 255, 255),相信大家都懂什么意思,那么正确的代

应改成

Label4.ForeColor = Color.FromArgb(255, 255, 255, 255)

RGB函数是这样的

Public Function RGB(Red As Integer, Green As Integer, Blue As Integer) As Integer

它返回一个Integer不是Color结构

应该用Color.FromArgb

Public Shared Function FromArgb(alpha As Integer, red As Integer, green As Integer, blue As Integer) As System.Drawing.Color

VB.NET:绘图后,如何才能取得所绘图形的颜色值?

加入一个TextBox控件,一个Command控件

代码:

Private Declare Function GetPixel Lib "gdi32" (ByVal hDC As Long, ByVal X As Long, ByVal Y As Long) As Long

Private Declare Function GetWindowDC Lib "user32" (ByVal hWnd As Long) As Long

Private Sub Command1_Click()

Dim Color As Long

WindowDC = GetWindowDC(0) '获取屏幕的设备场景

Color = GetPixel(WindowDC, 500, 100) '获指定点的颜色

'分解RGB颜色值

R = (Color Mod 256) '红色

b = (Int(Color \ 65536)) '蓝色

G = ((Color - (b * 65536) - R) \ 256) '绿色

Text1.BackColor = RGB(R, G, b)

End Sub


本文题目:vb.netrgb的简单介绍
文章出自:http://jkwzsj.com/article/dodciei.html

其他资讯