picturebox放大、缩小、旋转、拖拽
来源:互联网 发布:数据库安全管理原则 编辑:程序博客网 时间:2024/06/04 23:34
1、加载图像
Dim temp As Byte()
Try
If cxh <> "" Then
temp = myYw.GetPic(cxh)
Dim stream As New MemoryStream(temp)
picfile.Image = Image.FromStream(stream)
picfile.SizeMode = PictureBoxSizeMode.AutoSize
txtkuan.Text = picfile.Width
txtgao.Text = picfile.Height
End If
Catch ex As Exception
End Try
'获取缩略图
Public Function GetPic(ByVal xh As String) As Byte()
Dim strSQL As String
Dim dr As SqlDataReader
strSQL = "Select * From ec_m Where xh=" & xh
Try
dr = SqlHelper.ExecuteReader(o.GetConn, CommandType.Text, strSQL)
If dr.Read Then
Return DirectCast(dr("cd"), Byte())
End If
'Return SqlHelper.ExecuteScalar(o.GetConn, CommandType.Text, strSQL)
Catch ex As Exception
Finally
If Not dr Is Nothing Then dr.Close()
End Try
End Function
2、缩小
picfile.SizeMode = PictureBoxSizeMode.StretchImage
picfile.Width = CInt(picfile.Width * 0.8)
picfile.Height = CInt(picfile.Height * 0.8)
3、旋转
Dim bmp As New Bitmap(picfile.Image)
picfile.SizeMode = PictureBoxSizeMode.AutoSize
bmp.RotateFlip(RotateFlipType.Rotate90FlipNone)
picfile.Image = bmp
txtgao.Text = picfile.Height
txtkuan.Text = picfile.Width
4、最适合大小
Dim tempkuan As Double
Dim tempgao As Double
picfile.SizeMode = PictureBoxSizeMode.StretchImage
If CDbl(txtkuan.Text) > 1000 Then
If txtgao.Text > 500 Then
'1300*2300
tempkuan = (1000 / picfile.Width)
tempgao = (500 / picfile.Height)
If tempkuan > tempgao Then
picfile.Width = CDbl(tempgao * txtkuan.Text)
picfile.Height = CDbl(tempgao * txtgao.Text)
Else
picfile.Width = CDbl(tempkuan * txtkuan.Text)
picfile.Height = CDbl(tempkuan * txtgao.Text)
End If
Else
'1200*490
picfile.Width = (1000 / picfile.Width) * txtkuan.Text
picfile.Height = (1000 / picfile.Width) * txtgao.Text
End If
Else
If txtgao.Text > 500 Then
tempgao = (500 / picfile.Height)
picfile.Width = CDbl(tempgao * txtkuan.Text)
picfile.Height = CDbl(tempgao * txtgao.Text)
Else
picfile.Width = txtkuan.Text
picfile.Height = txtgao.Text
End If
End If
5、拖拽
‘先声明
Dim mousePos0 As Point
Dim canMove0 As Boolean
’事件处理
Private Sub picfile_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles picfile.MouseUp
canMove0 = False
End Sub
Private Sub picfile_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles picfile.MouseMove
If canMove0 Then
picfile.Location = New Point(picfile.Location.X - mousePos0.X + e.X, picfile.Location.Y - mousePos0.Y + e.Y)
End If
End Sub
Private Sub picfile_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles picfile.MouseDown
canMove0 = True
mousePos0 = New Point(e.X, e.Y)
End Sub
- picturebox放大、缩小、旋转、拖拽
- ---Transform---放大缩小旋转
- 在winform 中PictureBox放大缩小图片
- android 旋转,放大,缩小图片
- silverlight图片旋转、放大、缩小
- 放大、缩小、旋转、开始动画
- 控件移动,放大,缩小,旋转
- unity触摸放大缩小旋转
- 基于rapheal图片放大 缩小 旋转 拖拽 双击
- pictureBox里用滚轮实现 放大缩小功能
- picturebox 中画完图后续的放大、缩小、平移处理求助
- javascript做图片放大,缩小,旋转
- JS控制图片拖动 放大 缩小 旋转
- JS控制图片拖动 放大 缩小 旋转
- 微博图片放大、缩小、旋转
- android之imageView放大缩小与旋转
- WPF多点触摸放大缩小旋转
- 安卓实现图片旋转放大缩小
- document.all用法
- 大数运算
- getDeclaredMethod()和getMethod()的区别
- usb摄像头在s3c6410平台上的测试
- 类名.class, class.forName(), getClass()区别
- picturebox放大、缩小、旋转、拖拽
- 9-socket的实践到内核--client调用connect .
- js动态操作select,按周得到workday工作日的日期段即每月的周一到周五
- windows xp下配置JDK环境变量
- Stanford Machine Learning - Lecture 01
- 嵌入式软件工程师笔试题(含答案)
- Gtk线程刷新界面
- 这样的考试让我说什么好呢?
- 第十五周项目3 带姓名的成绩单