VB.NET 画图工具代码

适于VB.NET编程使用,有基本的一些功能就好了,最好图文并茂。不能有错。... 适于VB.NET编程使用,有基本的一些功能就好了,最好图文并茂。不能有错。 展开
 我来答
匿名用户
2013-07-12
展开全部
Imports System
Imports System.IO
Public Class Form2
Private mBmpBuffer As Bitmap
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
mBmpBuffer = New Bitmap(Me.PictureBox1.Width, Me.PictureBox1.Height, Me.PictureBox1.CreateGraphics) Dim g As Graphics = Graphics.FromImage(mBmpBuffer)
Dim i As Integer
Dim aa(3, 1) As Single
Dim stra() As String
Try
Dim sr As StreamReader = New StreamReader("D:\模型相关\modeldesign\modelpaint\data.csv")
Dim line As String
Do
line = sr.ReadLine() i = i + 1
If i > 1 Then
stra = Split(line, ";")
aa(i - 2, 0) = Val(stra(0))
aa(i - 2, 1) = Val(stra(1))
End If Loop Until line Is Nothing
sr.Close()
Catch ex As Exception End Try Dim ix As Single
Dim iy As Single
Dim temp As Single temp = aa(0, 0)
For i = 0 To 3
If aa(i, 0) > temp Then
temp = aa(i, 0)
End If
Next
ix = temp temp = aa(0, 1)
For i = 0 To 3
If aa(i, 1) > temp Then
temp = aa(i, 1)
End If
Next
iy = temp
'变换坐标
Dim bx As Single
Dim by As Single bx = PictureBox1.Width / ix
by = PictureBox1.Height / iy 'Dim g As Graphics = Me.PictureBox1.CreateGraphics
g.Clear(Color.White)
Dim mypoint(3) As Point
Dim n As Integer = 3
'变换坐标原点
g.TranslateTransform(PictureBox1.Width / 15, PictureBox1.Height * 14 / 15)
'g.ScaleTransform(PictureBox1.Width / ix, PictureBox1.Height / iy) '绘制坐标轴
Dim mypen As New Pen(Color.Black)
Dim sb As New SolidBrush(Color.Black)
'Dim sb1 As Brush = Brushes.Red
Dim mypen1 As New Pen(Color.Blue, 6)
g.DrawLine(mypen, 0, 0, PictureBox1.Width - 40, 0)
g.DrawLine(mypen, 0, 0, 0, 20 - PictureBox1.Height)
For i = 0 To PictureBox1.Width - 40 Step 40
g.DrawLine(mypen, i, 0, i, -10)
g.DrawString(Int(i / 0.9 / bx), New Font("宋体", 8), sb, i - 10, 0)
Next
g.DrawString("C", New Font("宋体", 8), sb, PictureBox1.Width - 50, 0) For i = 40 To PictureBox1.Height - 40 Step 40
g.DrawLine(mypen, 0, -i, 10, -i)
g.DrawString(Int(i / 0.9 / by), New Font("宋体", 8), sb, -20, -i - 10)
Next
g.DrawString("x", New Font("宋体", 8), sb, -10, 20 - PictureBox1.Height)
'mypen.Width = 1
g.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias
For i = 0 To n
mypoint(i).X = aa(i, 0) * bx * 0.9
mypoint(i).Y = -aa(i, 1) * by * 0.9
'g.FillRectangle(sb1, mypoint(i).X, mypoint(i).Y, 3, mypoint(i).Y)
g.DrawLine(mypen1, mypoint(i).X, 0, mypoint(i).X, mypoint(i).Y)
Next '开始画线
'g.DrawCurve(mypen, mypoint)
Me.PictureBox1.Refresh()
End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim strFilter As String = "BMP文件(*.bmp)|*.bmp"
Dim pdlg As SaveFileDialog = New SaveFileDialog
pdlg.Title = "地图另存为"
pdlg.Filter = strFilter
pdlg.OverwritePrompt = True
pdlg.ShowDialog() If Not pdlg.FileName.Equals("") Then
If Not (mBmpBuffer Is Nothing) Then
'mBmpBuffer.Save("c:\a.bmp")
mBmpBuffer.Save(pdlg.FileName)
End If End If
End Sub Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click End Sub Private Sub PictureBox1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint
If Not (mBmpBuffer Is Nothing) Then
e.Graphics.DrawImage(mBmpBuffer, 0, 0)
End If
End Sub Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ComboBox1.Items.Clear()
ComboBox1.Items.Add("模型一")
ComboBox1.Items.Add("模型二")
ComboBox1.Items.Add("模型三")
ComboBox1.Text = "模型一"
End Sub
End Class
发表于 @ 2007年10月31日 11:53:00 | 评论( 0 ) | 编辑| 举报| 收藏 旧一篇:SharpMap AjaxMapControl 中 Zoomin/Zoomout 操作时冻结问题 | 新一篇:Windows 窗体控件进行线程安全调用
本文来自CSDN博客,转载请标明出处: http://blog.csdn.net/Chendy/archive/2007/10/31/1859110.aspx
AiPPT
2024-09-19 广告
随着AI技术的飞速发展,如今市面上涌现了许多实用易操作的AI生成工具1、简介:AiPPT: 这款AI工具智能理解用户输入的主题,提供“AI智能生成”和“导入本地大纲”的选项,生成的PPT内容丰富多样,可自由编辑和添加元素,图表类型包括柱状图... 点击进入详情页
本回答由AiPPT提供
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式