快上网专注成都网站设计 成都网站制作 成都网站建设
成都网站建设公司服务热线:028-86922220

网站建设知识

十年网站开发经验 + 多家企业客户 + 靠谱的建站团队

量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决

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

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:绘图后,如何才能取得所绘图形的颜色值?

加入一个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颜色值

你好,我不知道你是用什么方法保存的,不过.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如何查找像素读取颜色

既然小方框的边为纯黑色,那么还是比较好找出小方框的位置的。

假设小方框的大小是不变的(我不知道是否会变,长为a,宽为b,单位pt)

1,通过api取点的颜色。2,因为只找左右的两条边,所以从上到下跳越式的搜索(步长=小方框的宽度b)3,每跳一下,就从左至右的逐像素的搜索,如果找到黑色的点,就上下连续搜索一定数量的点

如果全部为黑色,则证明是一条黑线,说明找到了左边,在左边的基本上,加上宽度,就是右边了。

在此右边还可以用来校验搜索的结果是否正确。4,找到了左右两条边的位置,剩下的就设置你的竖线的位置。

下面给出大体上的代码:

GetPixel函数是获取设备指定点颜色值的。

for

y

=

to

yMax

step

b-1for

x=0

to

xMax

if

GetPixel(hdc,x,y)

=vbBlack

then

'向上搜索一定数量的点,判断是否全部为黑色

'.........

'向下搜索一定数量的点,判断是否全部为黑色

'.........

end

ifnextnext

在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.NET设置屏幕分辨率、颜色位数、刷新率

实例代码,有需要的朋友可以参考一下

复制代码

代码如下:

Private

Declare

Function

GetDeviceCaps

Lib

"gdi32"

(ByVal

hdc

As

Long,

ByVal

nIndex

As

Long)

As

Long

Private

Declare

Function

ChangeDisplaySettings

Lib

"user32"

Alias

"ChangeDisplaySettingsA"

(lpDevMode

As

Any,

ByVal

dwflags

As

Long)

As

Long

Private

Const

CCDEVICENAME

As

Long

=

32

Private

Const

CCFORMNAME

As

Long

=

32

Private

Const

DM_BITSPERPEL

As

Long

=

H40000

Private

Const

DM_PELSWIDTH

As

Long

=

H80000

Private

Const

DM_PELSHEIGHT

As

Long

=

H100000

Private

Const

DM_DISPLAYFLAGS

As

Long

=

H200000

Private

Const

DM_DISPLAYFREQUENCY

=

H400000

Private

Const

CDS_FORCE

As

Long

=

H80000000

Private

Const

BITSPIXEL

As

Long

=

12

Private

Const

HORZRES

As

Long

=

8

Private

Const

VERTRES

As

Long

=

10

Private

Const

VREFRESH

=

116

Private

Type

DEVMODE

dmDeviceName

As

String

*

CCDEVICENAME

dmSpecVersion

As

Integer

dmDriverVersion

As

Integer

dmSize

As

Integer

dmDriverExtra

As

Integer

dmFields

As

Long

dmOrientation

As

Integer

dmPaperSize

As

Integer

dmPaperLength

As

Integer

dmPaperWidth

As

Integer

dmScale

As

Integer

dmCopies

As

Integer

dmDefaultSource

As

Integer

dmPrintQuality

As

Integer

dmColor

As

Integer

dmDuplex

As

Integer

dmYResolution

As

Integer

dmTTOption

As

Integer

dmCollate

As

Integer

dmFormName

As

String

*

CCFORMNAME

dmUnusedPadding

As

Integer

dmBitsPerPel

As

Integer

dmPelsWidth

As

Long

dmPelsHeight

As

Long

dmDisplayFlags

As

Long

dmDisplayFrequency

As

Long

End

Type

Private

Sub

cmdChangeDesktopMode_Click()

Dim

DM

As

DEVMODE

With

DM

.dmPelsWidth

=

CInt(txtNewWidth.Text)

.dmPelsHeight

=

CInt(txtNewHeight.Text)

.dmBitsPerPel

=

CInt(txtNewColor.Text)

.dmDisplayFrequency

=

CInt(txtNewFreq.Text)

.dmFields

=

DM_PELSWIDTH

Or

DM_PELSHEIGHT

Or

DM_BITSPERPEL

Or

DM_DISPLAYFREQUENCY

.dmSize

=

LenB(DM)

End

With

If

ChangeDisplaySettings(DM,

CDS_FORCE)

Then

MsgBox

"错误!不支持此模式!"

End

If

End

Sub

Private

Sub

Form_Load()

txtOldWidth.Text

=

GetDeviceCaps(Me.hdc,

HORZRES)

txtOldHeight.Text

=

GetDeviceCaps(Me.hdc,

VERTRES)

txtOldColor.Text

=

GetDeviceCaps(Me.hdc,

BITSPIXEL)

txtOldFreq.Text

=

GetDeviceCaps(Me.hdc,

VREFRESH)

End

Sub


本文题目:vb.net像素颜色值 vb颜色代码rgb
标题链接:http://6mz.cn/article/dossjsj.html

其他资讯