vb.net2005 绘图编辑器
来源:互联网 发布:php和mysql连接 编辑:程序博客网 时间:2024/04/25 14:02
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
- vb.net2005 绘图编辑器
- VB.NET2005 窗体调用
- [VB.NET].NET2005问题
- vb.net2005 LinkLabel1的使用
- VB.NET2005读取XML数据
- vb.net2005中回调功能的简单实现
- vb.net2005里 webclient实现文件下载
- VB.NET2005 AxWindowsMediaPlayer1连续播放问题解决
- vb.net2005 网页自动填写并提交
- vb.net2005 获取网页链接,并提示
- vb.net2005资料收集(系统篇)
- vb.net2005资料收集(数据库篇)
- VB.net2005多线程访问界面控件
- VB.NET2005 动态添加 ToolStrip 控件
- vb.net2005 PictureBox生成bmp彩色图片
- VB.NET2005创建SQL数据库(转贴)
- Vb.net2005实现屏幕截图功能
- [VB.NET]资源管理器如何用.net2005实现
- 怎么转几份啊?
- matlab绘制立体图
- 感觉
- initial catalog与database的区别是什么
- C 标准库函数getchar的陷阱
- vb.net2005 绘图编辑器
- c++ -if语句比较注意
- C++程序标识符注意
- hibernate Set与Map的排序
- C++类编码注意
- 自然辩证法课后答案
- 什么是测试需求
- 新手乍到
- f o r k函数