
正文
vb.net图片浏览,vb制作图片浏览器
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
求大神指点vb.net 怎么以指定方式打开图片呢?
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
'建立新的系统进程
Dim process As New System.Diagnostics.Process()
If RadioButton1.Checked Then
'设置文件名,此处为图片的真实路径+文件名
process.StartInfo.FileName = "c:\a.bmp"
'设置进程运行参数
process.StartInfo.Arguments = "rundll32.exe shimgvw.dll"
Else
process.StartInfo.FileName = "mspaint.exe"
process.StartInfo.Arguments = "c:\a.bmp"
End If
'此项为是否使用Shell执行程序,因系统默认为true,此项也可不设,但若设置必须为true
'process.StartInfo.UseShellExecute = True
'此处可以更改进程所打开窗体的显示样式,可以不设
'process.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden
process.Start()
process.Close()
End Sub
相关问答
Q1: 在vb.net下怎么制作一个图片浏览器,根据用户选择的文件夹,程序自动搜索改文件夹下的图片文件。
Public Class Form1
Private TPS As Integer
Private TPPath() As String '定义不确定元素个数组,及动态数组
Private Sub LoadPhoto()
'将图片路径及图片名加载到数组
Dim JS As Integer '计数用
For Each foundFile As String In My.Computer.FileSystem.GetFiles(CurDir() "\职员图片")
TPS = TPS + 1 '将图片数存入变量中
Next
ReDim TPPath(TPS - 1) '确定数组大小
For Each FoundFile As String In My.Computer.FileSystem.GetFiles(CurDir() "\职员图片")
'将图片路径存入数组
TPPath(JS) = FoundFile
JS = JS + 1
Next
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
LoadPhoto()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Label1.Text = TPPath.Length '获取数组大小
Label1.Text = TPPath(1) '获取数组中第2个元素的值
End Sub
Q2: 用vb.net实现查找显示图片?
IO.Directory.GetFiles
获取指定目录中的所有文件,比对文件名就行了。如果包括多层子目录,需要递归
Q3: 怎样用vb.net做一个图片浏览器?
在自定义工具箱中选择dirlistbox,drivelistbox,filelistbox,添加这3个控件,然后在窗体上添加这些控件和一个picturebox控件,代码如下:
Public Class Form1
Private Sub DirListBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DirListBox1.SelectedIndexChanged
FileListBox1.Path = DirListBox1.Path
End Sub
Private Sub DriveListBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DriveListBox1.SelectedIndexChanged
DirListBox1.Path = DriveListBox1.Drive
End Sub
Private Sub FileListBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles FileListBox1.SelectedIndexChanged
PictureBox1.Image = Image.FromFile(FileListBox1.Path + "\" + FileListBox1.SelectedItem.ToString())
End Sub
End Class
你可以自己在修改下,这只是个模型,呵呵!
Q4: 在VB.NET中浏览图片
转换成位图肯定是可以浏览的,WMF文件没试过。
你可以将图片以二进制形式存储在数据库中,如果是SQL Server,对应字段的类型应该是image。
Q5: 用vb.net如何编写图片浏览器的基本步骤功能是:图片的打开、显示、缩放、旋转。
窗体上放一个PictureBox,两个CommandButton,一个FileListBox
Private Sub Command1_Click()
If File1.ListIndex = 0 Then
ShowPic File1.ListCount - 1
Else
ShowPic File1.ListIndex - 1
End If
End Sub
Private Sub Command2_Click()
If File1.ListIndex = File1.ListCount - 1 Then
ShowPic 0
Else
ShowPic File1.ListIndex + 1
End If
End Sub
Private Sub Form_Load()
File1.Visible = False
File1.Pattern = "*.jpg;*.gif" '可以浏览的文件类型,使用分号隔开
File1.Path = App.Path '改成你需要浏览的目录,比如"C:\Pic"
If File1.ListCount 1 Then '目录中图片在两张以上可以浏览
ShowPic 0
Exit Sub
ElseIf File1.ListCount = 1 Then '目录中只有一张图片时只显示这一张
ShowPic 0
End If
Command1.Enabled = False
Command2.Enabled = False
End Sub
Private Sub ShowPic(Index As Long)
File1.ListIndex = Index
Picture1.Picture = LoadPicture(File1.Path "\" File1.List(Index))
End Sub
如果对您有帮助,请记得采纳为满意答案,谢谢!祝您生活愉快!
vaela







