要使用GetPixel函数来取得像素的颜色值,代码如下:
private void button1_Click(object sender, EventArgs e)
{
Color color = new Bitmap(pictureBox1.Image).GetPixel(10, 10);
MessageBox.Show(color.ToString());
VB.net与VB不同.
VB.net已经有专门绘图的类.
可以定义笔刷然后用Drawing类中的方法绘制.
Private Sub DrawEllipse()
Dim myPen As New System.Drawing.Pen(System.Drawing.Color.Red)
Dim formGraphics as System.Drawing.Graphics
formGraphics = Me.CreateGraphics()
myPen.Dispose()
formGraphics.Dispose()
End Sub
Private Sub DrawRectangle()
Dim BmpData As New BitmapData
Dim PixleValue(Stride * Bmp.Height) As Byte
Dim Hanlde As GCHandle = GCHandle.Alloc(PixleValue, GCHandleType.Pinned)
BmpData.Scan0 = Hanlde.AddrOfPinnedObject()
应该是边界溢出了,因为默认是0开始,所以 PictureBox1.Image.Width-1
同理PictureBox1.Image.Height - 1,不然行循环也会溢出
以上就是土嘎嘎小编为大家整理的vb.net画图像素相关主题介绍,如果您觉得小编更新的文章只要能对粉丝们有用,就是我们最大的鼓励和动力,不要忘记讲本站分享给您身边的朋友哦!!