【发布时间】:2014-10-25 16:57:21
【问题描述】:
我一直在寻找大约一周的时间来寻找答案,但我在这里有代码是徒劳的
Dim bmap As Bitmap
bmap = New Bitmap(PictureBox1.Width, PictureBox1.Height)
Dim g As Graphics = graphics.FromImage(bmap)
g.FillRectangle(Brushes.Black, 0, 0, 100, 100)
For q As Integer = 0 To bmap.Width - 1
For w As Integer = 0 To bmap.Height - 1
If bmap.GetPixel(q, w) = Color.Black Then
bmap.SetPixel(q, w, Color.Green)
End If
Next
Next
PictureBox1.Image = bmap
所以当我点击按钮时,它会绘制 100 x 100 黑框,但不会将像素设置为绿色
所以位图无法识别图形
【问题讨论】:
-
您想要一个绿色矩形还是将所有黑色像素都涂成绿色?
-
将所有黑色像素着色为绿色
-
If bmap.GetPixel(q, w).ToArgb = Color.Black.ToArgb Then... -
对比 bmap.GetPixel(q, w) = Color.FromArgb(&HFF000000) 也可以解决。看我的回答