重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
画点:
创新互联是一家专注于网站设计、成都网站设计与策划设计,文圣网站建设哪家好?创新互联做网站,专注于网站建设十多年,网设计领域的专业建站公司;建站业务涵盖:文圣等地区。文圣做网站价格咨询:028-86922220
在PictureBox的Paint事件里面:
dim myGraphics=e.Graphics
Dim myPointArray As Point() = {New Point(0, 0), New Point(50, 30), New Point(30, 60)}
myGraphics.DrawPolygon(myPen, myPointArray)
画圆:
Dim g As Graphics
g = PictureBox1.CreateGraphics
g.FillEllipse(Brushes.Red, x, y, 10, 10)
Dim b As New Bitmap(320, 200)'定义图像宽高
Dim clrs As Color=Color.Black
for y as int32=1 to 199
for x as int32=1 to 319
if x=y then
clrs = Color.White'假设是对角线,x=y时使用白色
else
clrs = Color.Black'平时使用黑色
endif
b.SetPixel(x, y, clrs)'画点
next
next
b.Save("test.tif", System.Drawing.Imaging.ImageFormat.Tiff)'保存到图片文件
==================
原创例子,祝进步!!
Call Pset(x,y,RGB(Red,Green,Blue))
x,y是坐标
RGB是颜色
可以随时调用!!!
哦,对不起,没看清。
我没用过VB.Net,代码是没办法给你了
但我有办法:
用API函数SetPixel,SetPixelv(后者快一点)
语法参见
.NET确实没有提供画一个像素点得方法
你可以试一下用FillEllipse填充一个宽1像素,高2像素的椭圆
原理就是FillEllipse的时候,最左边那一列一般都会多出一个一像素的点;高至少要2,少了就什么都画不出来
画点:
在PictureBox的Paint事件里面:
dim myGraphics=e.Graphics
Dim myPointArray As Point() = {New Point(0, 0), New Point(50, 30), New Point(30, 60)}
myGraphics.DrawPolygon(myPen, myPointArray)
画圆:
Dim g As Graphics
g = PictureBox1.CreateGraphics
g.FillEllipse(Brushes.Red, x, y, 10, 10)
先在桌面新建一个文本文档,输入20个点坐标
Dim x As Integer
Dim y As Integer
Dim z As Single
Dim i As Integer
Private Sub Command1_Click()
Form1.Picture1.Scale (0, 0)-(100, 100)
Open "c:\1.txt" For Input As #1
i = 0
Do While Not EOF(1)
i = i + 1
Input #1, x(i), y(i), z(i)
Form1.Picture1.PSet (x(i), y(i))
Loop
Close #1
End Sub
Private Sub Command2_Click()
For n = 1 To i - 1
For j = n + 1 To i - 1
If x(n) x(j) Then
t = x(n)
x(n) = x(j)
x(j) = t
k = y(n)
y(n) = y(j)
y(j) = k
End If
Next j
Next n
For n = 1 To i - 2
Form1.Picture1.Line (x(n), y(n))-(x(n + 1), y(n + 1))
Next n
End Sub
Private Sub Command3_Click()
Form1.Picture2.Scale (0, 0)-(100, 100)
Open "c:\1.txt" For Input As #1
i = 1
Do While Not EOF(1)
Input #1, x(i), y(i), z(i)
Form1.Picture2.PSet (x(i), y(i))
i = i + 1
Loop
Close #1
End Sub
Private Sub Command4_Click()
For n = 1 To i - 1
Form1.Picture2.Line (x(n) - z(n), y(n))-(x(n) + z(n), y(n))
Form1.Picture2.Line (x(n), y(n) + z(n))-(x(n), y(n) - z(n))
Next n
End Sub