视频生成缩略图如何实现?
视频生成缩略图如何实现?
------解决方案--------------------Imports System.Drawing
Imports System.IO
Public Class admin_upimg
Inherits Web.PageBase
Protected WithEvents Btnup As System.Web.UI.WebControls.Button
Protected WithEvents uplTheFile As System.Web.UI.HtmlControls.HtmlInputFile
Protected WithEvents fileinfo As System.Web.UI.WebControls.Label
Protected WithEvents chkslt As System.Web.UI.WebControls.CheckBox
Protected WithEvents Txtslt As System.Web.UI.WebControls.TextBox
Protected WithEvents Txt As System.Web.UI.WebControls.TextBox
Protected WithEvents Chkonly As System.Web.UI.WebControls.CheckBox
Protected WithEvents Chkshow As System.Web.UI.WebControls.CheckBox
Protected WithEvents Txtfileadd As System.Web.UI.WebControls.TextBox
#Region " Web 窗体设计器生成的代码 "
'该调用是 Web 窗体设计器所必需的。
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: 此方法调用是 Web 窗体设计器所必需的
'不要使用代码编辑器修改它。
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'在此处放置初始化页的用户代码
End Sub
Private Sub Btnup_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnup.Click
Txtfileadd.Text = " "
Txtslt.Text = " "
'-------------------------------------
'
'显示分类列表--list.aspx
'
'-------------------------------------
If uplTheFile.PostedFile.ContentLength = 0 Then
fileinfo.Visible = False
Txtfileadd.Text = "文件长度不能为0 "
Exit Sub
Else
fileinfo.Visible = True
End If
Dim temnow As String = System.DateTime.Now.ToString( "yyMMddhhffffff ")
'保存图片
If Chkonly.Checked Then
Else
uplTheFile.PostedFile.SaveAs(Server.MapPath( "../images/upload " + "/ " + temnow + ".jpg "))
End If
'生成缩略图
If chkslt.Checked Then
Try
Dim Image As System.Drawing.Image
If Chkonly.Checked Then
Image = System.Drawing.Image.FromStream(uplTheFile.PostedFile.InputStream)
Else
Image = System.Drawing.Image.FromFile(Server.MapPath( "../images/upload " + "/ " + temnow + ".jpg "))
End If
Dim width = Image.Width
Dim height = Image.Height
Dim newwidth As Integer
Dim newheight As Integer
If width > height Then
newwidth = 120
newheight = Image.Height / Image.Width * newwidth
Else
newheight = 90
newwidth = Image.Width / Image.Height * newheight
End If
Dim callb As System.Drawing.Image.GetThumbnailImageAbort
Dim anewimage = Image.GetThumbnailImage(newwidth, newheight, callb, Ne