用vb.net如何编写图片浏览器的基本步骤功能是:图片的打开、显示、缩放、旋转。
窗体上放一个PictureBox,两个CommandButton,一个FileListBox
成都创新互联专注为客户提供全方位的互联网综合服务,包含不限于做网站、成都网站制作、巴州网络推广、成都小程序开发、巴州网络营销、巴州企业策划、巴州品牌公关、搜索引擎seo、人物专访、企业宣传片、企业代运营等,从售前售中售后,我们都将竭诚为您服务,您的肯定,是我们最大的嘉奖;成都创新互联为所有大学生创业者提供巴州建站搭建服务,24小时服务热线:13518219792,官方网址:www.cdcxhl.com
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
用VB.NET制作图片浏览器时 ,打开图片文件时只能一张一张的打开,如何设置可以一次打开多个图片文件
Public Class Form1
Dim Files() As String
Dim ImgNum As Integer = 0
Dim CurIdx As Integer = 0
Sub OpenFiles()
InitialSet()
Try
If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
If Not OpenFileDialog1.FileNames Is Nothing Then
Files = OpenFileDialog1.FileNames
Else
Files(0) = OpenFileDialog1.FileName
End If
ImgNum = Files.Length
Dim s As String = String.Format("你共打开 {0} 张图片", ImgNum)
Me.Text = s
StateSet()
CurIdx = 1
DisplayImage(CurIdx)
Else
StateSet()
Me.PictureBox1.Image = Nothing
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Sub InitialSet()
Me.OpenFileDialog1.Multiselect = True
Me.OpenFileDialog1.Filter = "(*.jpg)|*jpg"
Me.OpenFileDialog1.FilterIndex = 0
ImgNum = 0
CurIdx = 0
If Not Files Is Nothing Then
Array.Clear(Files, 0, Files.Length - 1)
End If
End Sub
Sub DisplayImage(ByRef Idx As Integer)
If IO.Path.GetExtension(Files(Idx - 1)).ToLower = ".jpg" Then
Me.PictureBox1.Load(Files(Idx - 1))
End If
StateSet()
End Sub
Sub StateSet()
If ImgNum 1 Then
Me.btnNext.Enabled = True
Else
Me.btnNext.Enabled = False
Me.btnPervious.Enabled = False
Exit Sub
End If
If CurIdx 1 And ImgNum 1 Then
Me.btnPervious.Enabled = True
Else
Me.btnPervious.Enabled = False
End If
If CurIdx ImgNum And ImgNum 1 Then
Me.btnNext.Enabled = True
Else
Me.btnNext.Enabled = False
End If
End Sub
Sub NextIamge(ByRef Idx As Integer)
If Idx ImgNum Then
Idx += 1
Else
Exit Sub
End If
DisplayImage(Idx)
End Sub
Sub PerviousIagme(ByRef Idx As Integer)
If Idx 1 Then
Idx -= 1
Else
Exit Sub
End If
DisplayImage(Idx)
End Sub
Private Sub btnNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNext.Click
Try
NextIamge(CurIdx)
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub btnOpen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOpen.Click
OpenFiles()
End Sub
Private Sub btnPervious_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPervious.Click
Try
PerviousIagme(CurIdx)
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
End Class
VB.NET如何装载一个文件夹的所有图片 就是FolderBrowserDialog选定一个文件夹 自动装载里面所有图片
‘ 导入图片按钮
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
FolderBrowserDialog1.Description = "选择图片文件夹导入图片"
FolderBrowserDialog1.ShowDialog()
path = FolderBrowserDialog1.SelectedPath()
If path = "" Then Return
strSrcFile = Dir(path "\*.tif")
PictureBox1.Image = Image.FromFile(path "\" strSrcFile)
dirFiles.Add(path "\" strSrcFile)
FileNames.Add(strSrcFile)
Do
strSrcFile = Dir()
dirFiles.Add(path "\" strSrcFile)
If (strSrcFile IsNot Nothing) Then
FileNames.Add(strSrcFile)
End If
Loop Until Len(strSrcFile) = 0
End Sub
’ 上一张图片(我做的按钮,鼠标左键的话原理也是一样 的,你放到鼠标左键事件中就可以了)
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click '向前
If path "" Then
If (saveDirFiles.Count = 0) Then
Return
End If
MyPos = 0
PictureBox1.Image = Image.FromFile(saveDirFiles(saveDirFiles.Count - 1).ToString())
dirFiles.Insert(0, saveDirFiles(saveDirFiles.Count - 1).ToString())
saveDirFiles.RemoveAt(saveDirFiles.Count - 1)
End If
End Sub
’ 下一张图片
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click '向后
If path "" Then
If (dirFiles.Count = 0) Then
Return
End If
MyPos = 0
Dim iCurrentPos As Integer = 0
Try
PictureBox1.Image = Image.FromFile(dirFiles(iCurrentPos + 1).ToString())
Catch ex As Exception
MsgBox("已翻至图片的最后一页")
Return
End Try
saveDirFiles.Add(dirFiles(iCurrentPos))
dirFiles.RemoveAt(iCurrentPos)
End sub
在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
vb.net编写一个照片浏览器程序,程序执行时单击下一张,将会显示下一张照片
我说选把打开多个图片路径加载到一个listbox里,利用listbox写代码
Private Sub picbox_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
If ListBox1.SelectedIndex = count Then
Try
ListBox1.SelectedIndex = ListBox1.SelectedIndex + 1
Catch
ListBox1.SelectedIndex = 0
End Try
End If
picbox.Image = ListBox1.SelectedItem.ToString
End Sub
在VB.NET中浏览图片
转换成位图肯定是可以浏览的,WMF文件没试过。
你可以将图片以二进制形式存储在数据库中,如果是SQL Server,对应字段的类型应该是image。
网站题目:vb.net图片浏览器 win 图片浏览工具
标题网址:http://lswzjz.com/article/doddsdh.html