扫二维码与项目经理沟通
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流
GDI绘图用字体必须安装才能使用
让客户满意是我们工作的目标,不断超越客户的期望值来自于我们对这个行业的热爱。我们立志把好的技术通过有效、简单的方式提供给客户,将通过不懈努力成为客户在信息化领域值得信任、有价值的长期合作伙伴,公司提供的服务项目有:国际域名空间、网站空间、营销软件、网站建设、阜新网站维护、网站推广。
在客户机部署应用程序时,安装该字体就行
拖一个PictureBox1控件
创建一个Paint事件。在事件中加入
Private Sub PictureBox1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint
' Create pens.
Dim redPen As New Pen(Color.Red, 3)
Dim greenPen As New Pen(Color.Green, 3)
' Create points that define curve.
Dim point1 As New Point(50, 50)
Dim point2 As New Point(100, 25)
Dim point3 As New Point(200, 5)
Dim point4 As New Point(250, 50)
Dim point5 As New Point(300, 100)
Dim point6 As New Point(350, 200)
Dim point7 As New Point(250, 250)
Dim curvePoints As Point() = {point1, point2, point3, point4, _
point5, point6, point7}
' Draw lines between original points to screen.
e.Graphics.DrawLines(redPen, curvePoints)
' Draw curve to screen.
e.Graphics.DrawCurve(greenPen, curvePoints)
End Sub
得到数据后,改point的数据。然后PictureBox1.Refresh()就行了
'添加模块一个模块声明如下APIPublic Declare Function GdiTransparentBlt Lib "gdi32" (ByVal hdc1 As Long, ByVal x1 As Long, ByVal y1 As Long, ByVal W1 As Long, ByVal H1 As Long, ByVal Hdc2 As Long, ByVal X2 As Long, ByVal Y2 As Long, ByVal W2 As Long, ByVal H2 As Long, ByVal Color As Long) As Long'hdc1 要绘图目标句柄'x1图片显示的横坐标位置'y1图片显示的纵坐标位置'w1图片缩放比例宽度'h1图片缩放比例高度'hdc2要绘制透明色的图片或控件(这里指picture)'x2一般这里填0(图片左上角起始坐标)'y2一般这里填0(图片左上角起始坐标)'w2图片宽度'h2图片高度'color绘制颜色(RGB(255,255,255)为透明色)'picture控件属性设置成visible=falseautosize=trueautoredraw=trueborderstyle=0窗体autoredraw=true简单例子Private Sub Form_Load()GdiTransparentBlt form1.hDC, 0, 0, form1.picture1.Width, form1.picture1.Height, form1.picture1.hDC, 0, 0, form1.picture1.Width, form1.picture1.Height, RGB(255, 255, 255) '画图End Sub
绘图代码写在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()
如果是简单的移动,先把图形绘制到大小和PictureBox的Bitmap上,然后再绘制到PictureBox就行。
不过在VB.NET中用GDI绘制最好用BufferedGraphics图形缓冲区,速度马马虎虎(VB就这样了),但是不闪烁,不存在背景擦除的问题。
当然是全部重画。
层只不过是制图软件弄出来的一个方便的东西而已。
就像你画画,画上去如果你要擦掉当然是擦到底色咯。(当然GDI+也可以像你画画一样只擦一部分)
GDI+时钟我写过一个VB6的。代码详见我博客。地址显然百度不让贴上= =。所以你可以看下我的资料。
你可以模拟层,就是把所有绘制信息都保存起来。你的流程应当是:
如果要绘制了,更新绘制信息(可以是数组啥的。),交给一个Draw过程
Draw过程:根据绘制信息,全部绘制。
By vIstaswx ,before junior school graduation exam.
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流