关于vb.net中绘图并保存图片的问题ImportsSystem.Drawing.Imaging
PublicClassForm1
DimimageNameAsString="C:\DocumentsandSettings\...\1126.jpg "
DimiAsImage=Image.FromFile(imageName)
DimgAsGraphics=Graphics.FromImage(i)'此处从背景图创建Greaphics
PrivateSubButton1_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton1.Click
'划线
DimBluePenAsNewPen(Color.Blue,5)
BluePen.DashStyle=Drawing2D.DashStyle.Solid
g.DrawLine(BluePen,100.0F,170,500.0F,170)
g.Dispose()
PictureBox1.Image=i
EndSub
PrivateSubButton2_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton2.Click
'退出
Me.Close()
EndSub
PrivateSubButton3_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton3.Click
'存盘
i.Save( "C:\testimage.jpg ",ImageFormat.Jpeg)
i.Dispose()
EndSub
PrivateSubForm1_Load(ByValsenderAsObject,ByValeAsSystem.EventArgs)HandlesMe.Load
PictureBox1.Image=i
EndSub
EndClass
如何使用vb.net调用cad进行绘图你去查查书吧 , 书上挺详细的,在这说不好说 , 你先在项目里引用 。然后 Dim acadapp As AcadApplication Dim acaddoc As AcadDocument On Error Resume Next AcadApp = GetObject(, "AutoCAD.Application") If Err.Number Then Err.Clear() AcadApp = CreateObject("AutoCAD.Application") If Err.Number Then MsgBox("不能运行AutoCAD,请检查是否安装了AutoCAD") Exit Sub End If End If AcadApp.Visible = True '界面可视
VB.net中如何画图?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()
formGraphics.DrawEllipse(myPen, New Rectangle(0,0,200,300))
myPen.Dispose()
formGraphics.Dispose()
End Sub
Private Sub DrawRectangle()
Dim myPen As New System.Drawing.Pen(System.Drawing.Color.Red)
Dim formGraphics as System.Drawing.Graphics
formGraphics = Me.CreateGraphics()
formGraphics.DrawRectangle(myPen, New Rectangle(0,0,200,300))
myPen.Dispose()
formGraphics.Dispose()
End Sub
用vb.net 绘图在Button1_Click可以画出一条线 。但是换成form1的Load事件就不能画图了,为什么?换成form1的Load事件就不能画图了:
是因为form1在Load的时候,它还不能创建图形界面,也就不能执行 Me.CreateGraphics
vb.net绘图问题代码:
Public Class Form1
'*********************************************************************
'作者:章鱼哥,QQ:3107073263 群:309816713
'如有疑问或好的建议请联系我 , 大家一起进步
'*********************************************************************
'绘制圆角矩形函数
Private Function GetRoundedRectPath(ByVal rect As Rectangle, ByVal radius As Integer) As System.Drawing.Drawing2D.GraphicsPath
rect.Offset(-1, -1)
Dim RoundRect As New Rectangle(rect.Location, New Size(radius - 1, radius - 1))
Dim path As New System.Drawing.Drawing2D.GraphicsPath
path.AddArc(RoundRect, 180, 90)'左上角
RoundRect.X = rect.Right - radius'右上角
path.AddArc(RoundRect, 270, 90)
RoundRect.Y = rect.Bottom - radius'右下角
path.AddArc(RoundRect, 0, 90)
RoundRect.X = rect.Left'左下角
path.AddArc(RoundRect, 90, 90)
path.CloseFigure()
Return path
End Function
'绘制矩形
Private Sub DrawingRect()
Dim g As Graphics = Me.CreateGraphics
Dim Pen As New Pen(Brushes.DarkRed, 2)
Dim Hei As Integer = Me.Height
Dim Wid As Integer = Me.Width
'矩形的位置和长宽随着窗体的变化而改变
Dim Rec As New Rectangle(Int(Wid / 5), Int(Hei / 5), Int(Wid / 2), Int(Hei / 2))
'g.DrawRectangle(Pen, Rec)
'清楚现有的矩形
g.Clear(Me.BackColor)
g.DrawPath(Pen, GetRoundedRectPath(Rec, 30))
End Sub
Private Sub Form1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
DrawingRect()
End Sub
Private Sub Form1_SizeChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.SizeChanged
Me.Invalidate() '此函数可引发Paint事件
End Sub
End Class
效果截图:
原窗口:
缩小后:
【VB.net点击按钮绘图 vbs 点击窗口指定按钮】VB.net点击按钮绘图的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于vbs 点击窗口指定按钮、VB.net点击按钮绘图的信息别忘了在本站进行查找喔 。
推荐阅读
- 刘耕宏直播用的是什么音乐,刘耕宏 健身
- 火种射击游戏,火的射击游戏
- 新月海直播软件,新海月新书
- 在mysql中怎么取反 英朗16t冷启动抖动
- 小程序怎么分享到qq上,自己的小程序怎么发到里
- erp带收银系统吗,erp系统收货操作流程
- 代理ip在哪,代理ip在哪买
- java登录时间限制代码 java实现登录功能怎么做
- 关于3857gis的信息