重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
GDI绘图用字体必须安装才能使用
创新互联主要从事网站设计制作、成都网站设计、网页设计、企业做网站、公司建网站等业务。立足成都服务镇宁,十载网站建设经验,价格优惠、服务专业,欢迎来电咨询建站服务:18982081108
在客户机部署应用程序时,安装该字体就行
绘图代码写在Paint事件中,如
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
Dim g As Graphics = Me.CreateGraphics
g.DrawLine(Pens.Red, 100, 100, 200, 100)
End Sub
'方法二:在 PictureBox1上显示图像----图画在Bitmap
PictureBox1.Image = Nothing
Dim wid As Integer = PictureBox1.ClientSize.Width
Dim hgt As Integer = PictureBox1.ClientSize.Height
Dim bm As New Bitmap(wid, hgt)
Dim g As Graphics = Graphics.FromImage(bm)
'画图代码
'画图代码
PictureBox1.Image = bm
PictureBox1.Refresh()
g.Dispose()
123456789101112Dim picX, picY, x1, y1, x2, y2, a href=";tn=44039180_cprfenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1YLPhmknAcvPjNhnvRYPAF90ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EnHb3rjbkrjc3rHc4nHn1rj0vPs" target="_blank" class="baidu-highlight"gdi/aX, a href=";tn=44039180_cprfenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1YLPhmknAcvPjNhnvRYPAF90ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EnHb3rjbkrjc3rHc4nHn1rj0vPs" target="_blank" class="baidu-highlight"gdi/aYpicX = 0 '要转换的Picture1坐标XpicY = 0 '要转换的Picture1坐标Yx1 = Picture1.ScaleLefty1 = Picture1.ScaleTopx2 = Picture1.ScaleLeft + Picture1.ScaleWidthy2 = Picture1.ScaleTop + Picture1.ScaleHeight '记录原先的坐标系统Picture1.ScaleMode = 3 '坐标系统设为像素a href=";tn=44039180_cprfenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1YLPhmknAcvPjNhnvRYPAF90ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EnHb3rjbkrjc3rHc4nHn1rj0vPs" target="_blank" class="baidu-highlight"gdi/aX = Round((picX - x1) / (x2 - x1) * Picture1.ScaleWidth)gdiY = Round((picY - y1) / (y2 - y1) * Picture1.ScaleHeight)MsgBox "Picture1的坐标(" picX "," picY ")转为GDI坐标是(" gdiX "," gdiY ")"Picture1.Scale (x1, y1)-(x2, y2) '改回原先的坐标系统
如果是简单的移动,先把图形绘制到大小和PictureBox的Bitmap上,然后再绘制到PictureBox就行。
不过在VB.NET中用GDI绘制最好用BufferedGraphics图形缓冲区,速度马马虎虎(VB就这样了),但是不闪烁,不存在背景擦除的问题。