VB中使用DIB方法,取出图片中各个像素的 RGB值

VB中使用DIB方法,取出图片中各个像素的 RGB值,第1张

VB没DIB方法

但可采用Point 方法

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

'使用Point方法 , 窗体判色代码:

Private Sub Form_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

    Shape1FillColor = 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 = Picture1Point(X, Y)

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

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

    Text6 = Val(Text3) \ 65536 'Blue

    Shape1FillColor = RGB(Val(Text4), Val(Text5), Val(Text6))

End Sub

private void Form4_Load(object sender, EventArgs e) { //遍历panel1里的控件 foreach (Control c in panel1Controls) { if (c is PictureBox) { PictureBox pic = c as PictureBox; picClick += new EventHandler(pic_Click);//添加点击事件 } } } void pic_Click(object sender, EventArgs e) { panel2ControlsClear();//清空panel2中的控件 PictureBox pic = sender as PictureBox; PictureBox pic2 = new PictureBox (); pic2Image = picImage; pic2SizeMode = picSizeMode; panel2ControlsAdd(pic2);//向panel2添加新建的PictureBox }

PictureBox1Point(x, y),注意x,y的单位是Picture1ScaleMode决定的,要转换为像素,需要使用ScaleX,ScaleY转换,即

x=PictureBox1ScaleX(x, PictureBox1ScaleMode,VBPixels)y=PictureBox1ScaleY(y, PictureBox1ScaleMode,VBPixels)

lColor=PictureBox1Point(x, y)

以上就是关于VB中使用DIB方法,取出图片中各个像素的 RGB值全部的内容,包括:VB中使用DIB方法,取出图片中各个像素的 RGB值、c#,在panel1控件内添加pictureBox控件,请问点击pictureBox怎么取得针对panel1控件的坐标、vb问题:如何可以获取在pictutebox中的一坐标点的颜色信息等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/10139431.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-05
下一篇2023-05-05

发表评论

登录后才能评论

评论列表(0条)

    保存