本文介绍了识别包含黑白框的位图文件上的黑盒子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好。请问我正在开发一个位图项目。此位图文件具有黑色和白色框,并将其加载到图片框中。我希望能够识别位图上黑框中的像素,并将它们保存到数组中,以便进一步处理项目。我可以获得VB.net(最好)或C#中执行此操作的代码的帮助。谢谢



抱歉,这是我第一次来这里,对于图形编程来说相对较新。这就是我所做的,它只能在richtextbox上显示x,y坐标和像素。 Sub Getcoordinates()

错误GoTo刷新

CheckForIllegalCrossThreadCalls = False

Dim Bild As Bitmap = CType(Me.PictureBox1.Image.Clone,位图)

昏暗宽度As Integer = Bild.Width - 1

昏暗高度As Integer = Bild.Height - 1

x = 0宽度

对于y = 0到高度



Dim R,G,B,A作为整数

R = Bild.GetPixel(x,y).R

G = Bild.GetPixel(x,y).G

B = Bild.GetPixel(x,y) .B

A = Bild.GetPixel(x,y).A

RichTextBox1.AppendText(R& - &G& - &B& - &A&Cordinates&x&,&y&vbNewLine)

下一页

下一页

RichTextBox1.Text = RichTextBox1。 Text.Substring(0,RichTextBox1.Text.Length - 1)

RichTextBox1.AppendText( |&width&*&height)





刷新:

刷新()

结束Sub

Hello all. Please I am working on a bitmap project. This bitmap file has black and white boxes and it is loaded to the picturebox. I want to be able to identify the pixels in the black box on the bitmap and save them to an array for use in further processing of the project. Please can I get help with the codes that does this in VB.net (preferably) or C#. Thanks

sorry guys it's my first time here and am relatively new to Graphics programming. This is what I have done, it can only display the x, y cordinates and pixels on a richtextbox. Sub Getcoordinates()
On Error GoTo Refresh
CheckForIllegalCrossThreadCalls = False
Dim Bild As Bitmap = CType(Me.PictureBox1.Image.Clone, Bitmap)
Dim width As Integer = Bild.Width - 1
Dim height As Integer = Bild.Height - 1
For x = 0 To width
For y = 0 To height

Dim R, G, B, A As Integer
R = Bild.GetPixel(x, y).R
G = Bild.GetPixel(x, y).G
B = Bild.GetPixel(x, y).B
A = Bild.GetPixel(x, y).A
RichTextBox1.AppendText(R & "-" & G & "-" & B & "-" & A & " Cordinates " & x & "," & y & vbNewLine)
Next
Next
RichTextBox1.Text = RichTextBox1.Text.Substring(0, RichTextBox1.Text.Length - 1)
RichTextBox1.AppendText("|" & width & "*" & height)


Refresh:
Refresh()
End Sub

推荐答案


这篇关于识别包含黑白框的位图文件上的黑盒子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-15 14:32