- 热门文章:
- · ASP全程讲座
- · 在网页中添加天气预报
- · 鼠标下浮动的文字和时钟
- · 音乐城堡2004免费版
- · ASP汉字转拼音函数
- · Oracle常見問題集(四)
- · 以ASP实现数据查询及输入
- · ASP操作Excel技术总结
- · bak文件带来的灾难
- · 关于输入框中显示双引号和单引号
- · 关于&运算符效率低下的问题,好的解决办法
- · 右键失效
上一篇:几个开源项目实体层实现方式比较 >>
上传图片并生成缩略图
Dim iname As String
If Not (fileup.PostedFile Is Nothing) Then
Dim namestr1 As String = (fileup.PostedFile.FileName)
If LCase(fileup.PostedFile.ContentType.ToString()) = "image/pjpeg" Or LCase(fileup.PostedFile.ContentType.ToString()) = "image/jpg" Then
Dim j As Integer = namestr1.LastIndexOf(".")
Dim newname As String = namestr1.Substring(j) ‘’圖片得到後輟名
iname = CStr(Now.ToFileTimeUtc) ‘’隨機的文件名(不會重復)
Dim newnames As String = iname + newname ‘’重新組合文件名
Dim i As Integer = namestr1.LastIndexOf("\") + 1
Dim namestr As String = namestr1.Substring(i)
fileup.PostedFile.SaveAs(Server.MapPath(imagelocal) + "\" + newnames) ‘’保存文件到imagelocal文件夾
‘’生成縮略圖()
Dim image, sImage As System.Drawing.Image
image = System.Drawing.Image.FromStream(fileup.PostedFile.InputStream)‘’得到原图
Dim width As Decimal = image.Width过且过‘’得到原图的宽
Dim height As Decimal = image.Height‘’得到原图的高
Dim newwidth, newheight As Integer
‘’设置缩略图的高和宽
If (width > height) Then
newwidth = 150
newheight = CInt(height / width * 150)
Else
newheight = 150
newwidth = CInt(width / height * 150)
End If
sImage = image.GetThumbnailImage(newwidth, newheight, Nothing, IntPtr.Zero)
Dim x As Integer = sImage.Width / 2 - 30
Dim y As Integer = sImage.Height - 20
Dim output As Bitmap = New Bitmap(sImage)
Dim g As Graphics = Graphics.FromImage(output)
‘’ 給縮略圖加上版權信息()
Dim fonts As New Font("Courier New", 9)
g.DrawString("版權信息", fonts, New SolidBrush(Color.Red), x, y)
output.Save(Server.MapPath("Simagelocal") + "\s_" + newnames, System.Drawing.Imaging.ImageFormat.Jpeg)
‘’保存縮略圖到Simagelocal文件夾
Image1.Visible=true;
Image1.ImageUrl = "Simagelocal" + "\s_" + newnames
Else
Label1.Text = "請選擇jpg類型的圖片"
End If
End If
End Sub
下一篇:ASP全程讲座 >>
相关文章:
- · 显示用户是否在线的方法
- · 图片的导入导出
- · 取消缓存
- · n 行n列的显示数据
- · 转换十进制为二进制的函数
- · 随心所欲的定制“弹出窗口”
- · Duwamish深入剖析-结构篇
- · 如何实现无刷新的DropdownList联动效果
- · 交叉表应用-成绩统计
- · http1.1状态代码及其说明
- · 超级ASP大分页_我的类容我做主
- · 为TextBox增加隐藏属性,Value属性
- · 在网页中添加一个音乐对象
- · 每刷新一次就换一次图片的代码
- · 用ASP发送信使服务
- · asp.net 2.0有感-2.0的变化(2)
- · asp.net 2.0有感-2.0的变化(1)
- · Asp深度揭密(下)
- · Asp深度揭密(上)
- · 将数字转换成大写的金额换算函数
- · asp.net 2.0中用GRIDVIEW插入新记录
- · 农历与西历对照
- · 学习笔记(7.8) -- 对服务器控件应用样式
- · 无刷新聊天室(短信陪聊程序)
- · popup的两种方法
- · 一些js例子
- · 在js和cs中的排序
- · 教你一次下载网页中的所有资源
- · 几个经典的ASP应用
- · 实现无刷新DropdownList联动效果
- · 将ASP纪录集输出成n列表格的方法
- · 二级联动菜单详解
- · 在ASP.NET WEB控件中应用样式(Style)
- · SQL Server 中易混淆的数据类型
- · ASP通用分页类源码
- · 创建一个ASP通用分页类
- · ASP+javascript的完整的日历使用
- · 上传文件
