vb.net颜色索引表的简单介绍

vb.net拾色器设计,要求:能获取图片任意位置的颜色

VB可使用Point方法来获取图片指定点的颜色。

新建ssl适用于网站、小程序/APP、API接口等需要进行数据传输应用场景,ssl证书未来市场广阔!成为成都创新互联的ssl证书销售渠道,可以享受市场价格4-6折优惠!如果有意向欢迎电话联系或者加微信:13518219792(备注:SSL证书合作)期待与您的合作!

Point 方法

按照长整数,返回在 Form 或 PictureBox 上所指定磅的红-绿-蓝 (RGB) 颜色。

语法

object.Point(x, y)

'窗体判色代码:

Private Sub Form1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)

Text1 = X

Text2 = Y

Text3 = Point(X, Y)

Text4 = (Val(Text3) Mod 65536) Mod 256 'Red

Text5 = (Val(Text3) Mod 65536) \ 256 'Green

Text6 = Val(Text3) \ 65536 'Blue

Shape1.FillColor = RGB(Val(Text4), Val(Text5), Val(Text6))

End Sub

'PictureBox判色代码:

Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)

Text1 = X

Text2 = Y

Text3 = Picture1.Point(X, Y)

Text4 = (Val(Text3) Mod 65536) Mod 256 'Red

Text5 = (Val(Text3) Mod 65536) \ 256 'Green

Text6 = Val(Text3) \ 65536 'Blue

Shape1.FillColor = RGB(Val(Text4), Val(Text5), Val(Text6))

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中,如何获取Graphics中某一指定点(像素)的颜色值?(VB语言)

要使用GetPixel函数来取得像素的颜色值,代码如下:

1

2

3

4

5

private void button1_Click(object sender, EventArgs e)

{

Color color = new Bitmap(pictureBox1.Image).GetPixel(10, 10);

MessageBox.Show(color.ToString());

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

c#/vb.net如何通过反射获得颜色名称(字符串)对应的颜色(Color类型)?

public Color col(string colorName)

{

Type colorType = typeof(Color);

PropertyInfo info = colorType.GetProperty(colorName, BindingFlags.Public | BindingFlags.Static);

if (infos == null)

{

//throw Exception

}

return(Color)info.GetValue(null, null);

}

是这个意思么?输入“Red”, 返回Color.Red 区分大小写


分享题目:vb.net颜色索引表的简单介绍
文章出自:http://ybzwz.com/article/docgcss.html