在ASP.NET裡輕鬆實現縮圖 (轉)
在ASP.NET裡輕鬆實現縮圖 (轉)[@more@].Thumbnail" %>
w3c//DTD HTML 4.0 Transitional//EN">
在裡輕鬆實現縮圖
microsoft .NET 7.0" name="GENERATOR">
7.0" name="CODE_LANGUAGE">
script" name="vs_defaultClientScript">
intellisense/" name="vs_targetSchema">
id="Form1" method="post" runat="server" enctype="multipart/form-data">
gerStepThrough()> Private Sub InitializeComponent() End Sub Private Sub Page_Init(ByVal sender As System., ByVal e As System.EventArgs) Handles MyBase.Init 'CODEGEN: This method call is required by the Web Form Designer 'Do not modify it using the code editor. InitializeComponent() End Sub #End Region Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Label1.Text = "
在裡輕鬆實現縮圖
playground.com/">
以前,在頁面上實現縮圖必須藉助第三方。現在,有了.NET,就可以很輕鬆地實現縮圖。下面就是實現縮圖的例子。
" target=_blank>檢視例子
程式碼如下:Thumbnail.aspx
gerStepThrough()> Private Sub InitializeComponent() End Sub Private Sub Page_Init(ByVal sender As System., ByVal e As System.EventArgs) Handles MyBase.Init 'CODEGEN: This method call is required by the Web Form Designer 'Do not modify it using the code editor. InitializeComponent() End Sub #End Region Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Label1.Text = "
在ASP.NET裡輕鬆實現縮圖
" Button1.Text = "上載並顯示縮圖" End Sub Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click Dim MyFileColl As HttpFileCollection = HttpContext.Current.Request.Files Dim MyPostedFile As HttpPostedFile = MyFileColl.Item(0) If LCase(MyPostedFile.ContentType.ToString()).IndexOf("image") <0 then exit sub end if end sub private function as href="tag-73-1.html">select Case (strContentType.ToString().ToLower()) Case "image/pjpeg" GetImageType = System.Drawing.Imaging.ImageFormat.Jpeg Case "image/gif" GetImageType = System.Drawing.Imaging.ImageFormat.Gif Case "image/bmp" GetImageType = System.Drawing.Imaging.ImageFormat.Bmp Case "image/tiff" GetImageType = System.Drawing.Imaging.ImageFormat.Tiff Case "image/x-icon" GetImageType = System.Drawing.Imaging.ImageFormat.Icon Case "image/x-png" GetImageType = System.Drawing.Imaging.ImageFormat.Png Case "image/x-emf" GetImageType = System.Drawing.Imaging.ImageFormat.Emf Case "image/x-exif" GetImageType = System.Drawing.Imaging.ImageFormat.Exif Case "image/x-wmf" GetImageType = System.Drawing.Imaging.ImageFormat.Wmf Case Else GetImageType = System.Drawing.Imaging.ImageFormat.MemoryBmp End Select End Function Private Sub GetThumbNail(ByVal strFileName, ByVal iWidth, ByVal iheight, ByVal strContentType, _ ByVal blnGetFromFile, ByVal ImgStream) Dim oImg As Image If blnGetFromFile Then oImg = oImg.FromFile(strFileName) Else oImg = oImg.FromStream(ImgStream) End If oImg = oImg.GetThumbnailImage(iWidth, iheight, Nothing, (New IntPtr()).Zero) Dim strGuid As String = (New Guid()).NewGuid().ToString().ToUpper() Dim strFileExt As String = strFileName.Substring(strFileName.LastIndexOf(".")) '儲存到本地 'oImg.Save(Server.MapPath("images") + "" + strGuid + strFileExt, GetImageType(strContentType)) '直接輸出url 'Response.Redirect("images/" + strGuid + strFileExt) '以下顯示在螢幕上 Response.ContentType = strContentType Dim MemStream As New MemoryStream() ' 注意:這裡如果直接用 oImg.Save(Response.OutputStream, GetImageType(strContentType)) ' 對不同的格式可能會出錯,比如Png格式。 oImg.Save(MemStream, GetImageType(strContentType)) MemStream.WriteTo(Response.OutputStream) End Sub End Class來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/10752019/viewspace-957924/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 輕鬆實現刪除確認 (轉)
- 在Delphi中實現圖片的旋轉、縮放 (轉)
- 輕鬆實現session的mysql處理 (轉)SessionMySql
- [轉]Android輕鬆實現RecyclerView懸浮條AndroidView
- 輕鬆實現SINDOWS 98動態選單 (轉)
- 輕鬆實現報表整合
- 輕鬆復現一張AI圖片AI
- ASP環境下輕鬆實現報表的列印 (轉)
- 輕鬆實現在家高效辦公
- 輕鬆實現 Web 效能優化Web優化
- web 報表中電子圖章 / 水印的輕鬆實現Web
- 辦公室革命,教你輕鬆搞定輕鬆玩轉ExcelExcel
- Diagramly:輕鬆在網頁上繪製流程圖網頁流程圖
- Redis輕鬆實現秒殺系統Redis
- js輕鬆實現摺疊皮膚JS
- PowerPoint輕鬆實現列表播放功能
- 在Gentoo Linux下輕鬆安裝ALSA(轉)Linux
- 在Android上用AChartEngine輕鬆繪製圖表Android
- 電子表格轉身購物車:三步輕鬆實現
- 基於 URL 的縮圖在 Laravel 中的實現Laravel
- 在ASP.NET開發中輕鬆讓網頁彈出視窗ASP.NET網頁
- 實現圖片縮放
- 用Redis輕鬆實現秒殺系統Redis
- Android 輕鬆實現 RecyclerView 懸浮條AndroidView
- Word中輕鬆實現逆頁序列印
- 用 Redis 輕鬆實現秒殺系統Redis
- localForage——輕鬆實現 Web 離線儲存Web
- 知識分享 | 輕鬆實現優質建模
- ASP.NET SignalR 與 LayIM2.0 配合輕鬆實現Web聊天室(三) 之 實現單聊,群聊,傳送圖片,檔案。ASP.NETSignalRWeb
- 在BCB中輕鬆使用ActiveX控制元件 (轉)控制元件
- asp.net上傳圖片並同時生成縮圖 (轉)ASP.NET
- 用asp.net輕鬆打造功能完備的分頁技術!!!! (轉)ASP.NET
- 讀懂這4條建議,輕鬆實現數字化轉型
- Windows XP 輕鬆實現作業系統備份與還原(轉)Windows作業系統
- DSP應用例項(一)--輕鬆實現BT多點下載 (轉)
- 掌握Snagit 2023:輕鬆實現螢幕錄製與截圖Git
- 輕鬆加密ASP.NET 2.0 Web程式配置資訊加密ASP.NETWeb
- ASP.NET SignalR 與LayIM配合,輕鬆實現網站客服聊天室(二) 實現聊天室連線ASP.NETSignalR網站