vb.net像素颜色值 vb颜色代码rgb

怎样获取vb.net中的颜色的ARGB値Dim btp As Bitmap = PictureBox1.Image
Dim c As Color = btp.GetPixel(x_x, y_x)
'然后c.A,c.R,c.G,c.B就是对应的颜色的ARGB値
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) '创建带有透明通道vb.net像素颜色值的ARGB颜色
Dim outcr As Color = Color.FromArgb(R, G, B) '创建不透明vb.net像素颜色值的RGB颜色
vb编程 获取图片全面像素颜色信息'使用DIB获取图象,根据他人代码修改,ImgData()中保存的是颜色
Private Declare Function GetDIBits Lib "gdi32" (ByVal aHDC As Long, ByVal hBitmap As Long, ByVal nStartScan As Long, ByVal nNumScans As Long, lpBits As Any, lpBI As BITMAPINFO, ByVal wUsage As Long) As Long
Private Declare Function SetDIBits Lib "gdi32" (ByVal hdc As Long, ByVal hBitmap As Long, ByVal nStartScan As Long, ByVal nNumScans As Long, lpBits As Any, lpBI As BITMAPINFO, ByVal wUsage As Long) As Long
Private Type BITMAPINFOHEADER '40 bytes
biSize As Long
biWidth As Long
biHeight As Long
biPlanes As Integer
biBitCount As Integer
biCompression As Long
biSizeImage As Long
biXPelsPerMeter As Long
biYPelsPerMeter As Long
biClrUsed As Long
biClrImportant As Long
End Type
Private Type RGBQUAD
rgbBlue As Byte
rgbGreen As Byte
rgbRed As Byte
rgbReserved As Byte
End Type
Private Type BITMAPINFO
bmiHeader As BITMAPINFOHEADER
bmiColors As RGBQUAD
End Type
Private Const DIB_RGB_COLORS = 0 'color table in RGBs
Private Sub Command1_Click()
Picture1.Line (0, 0)-(Picture1.Width, Picture1.Height), vbRed
Dim BITMAP As BITMAPINFO
Dim ImgData() As Byte'图象颜色
Dim lIndex As Long
Dim i As Long, j As Long, n As Long, t As Long, m
With BITMAP
.bmiHeader.biSize = 40 'BMP3.0版本
End With
If GetDIBits(Picture1.hdc, Picture1.Picture.Handle, 0, 0, 0, BITMAP, DIB_RGB_COLORS)0 Then'获取图像位图数据大小
ReDim ImgData(BITMAP.bmiHeader.biSizeImage - 1) '重定义数组准备接收位图数据
If GetDIBits(Picture1.hdc, Picture1.Picture.Handle, 0, BITMAP.bmiHeader.biHeight, ImgData(0), BITMAP, DIB_RGB_COLORS)0 Then'正式获取位图数据并将数据存入定义的数组中
'注意数组中颜色分量的存储顺序为:B、G、R(并不是R、G、B),如果你需要对图像进行处理只需改变数组中的数据即可完成
'我试验的位图62x62像素,24色图,3字节存储,每行188字节(一个扫描行的长度必须是4的倍数),这样扫描后共11656字节
'**************** 下面这段程序是将图像亮度变暗(只作为演示,其它效果你可以自己动手做) ***********************
'注意:第一条扫描线的位置是从左下角开始
'BITMAP.bmiHeader.biHeight 位图的高度,单位是像素
'BITMAP.bmiHeader.biWidth 位图的宽度,单位是像素
'BITMAP.bmiHeader.biBitCount 图像的颜色位数
'每个像素点的颜色是:(从下往上)
t = ((BITMAP.bmiHeader.biWidth * 33) \ 4) * 4'每行的字节数
For i = 1 To BITMAP.bmiHeader.biHeight
DoEvents
m = t * (i - 1)
For j = 1 To BITMAP.bmiHeader.biWidth
n = m(j - 1) * 3
Debug.Print "("i","j")"n": R="ImgData(n)" G="ImgData(n1)" B="ImgData(n2)
Next
Next
For lIndex = 0 To BITMAP.bmiHeader.biSizeImage - 1
DoEvents
If ImgData(lIndex) - 1000 Then
ImgData(lIndex) = 0
Else
ImgData(lIndex) = ImgData(lIndex) - 100
End If
Next
'*********************************************************************
SetDIBits Picture2.hdc, Picture2.Image.Handle, 0, BITMAP.bmiHeader.biHeight - 1, ImgData(0), BITMAP, DIB_RGB_COLORS '将位图数据写入PICTURE2中
End If
End If
End Sub
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.net 如何读取ini文件定义的ForeColor颜色值你好vb.net像素颜色值,我不知道你是用什么方法保存vb.net像素颜色值的,不过.net里的color有一个方法是Color.FromArgb 你可以这么做,dim
c
as
color=richtextbox1.ForeColor dim
colorstring
as
string=c.ToArgb().ToString
colorstring就是颜色的值(字符串)再把colorstring保存到ini文件加载颜色的时候,从ini里读取colorstring 具体是:dim
RtextColor
as
color=Color.FromArgb(cint(colorstring))richtextbox1.ForeColor
=RtextColor
在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像素颜色值 vb颜色代码rgb】vb.net像素颜色值的介绍就聊到这里吧 , 感谢你花时间阅读本站内容,更多关于vb颜色代码rgb、vb.net像素颜色值的信息别忘了在本站进行查找喔 。

    推荐阅读