本文实例讲述了asp.net创建动态缩略图的方法。分享给大家供大家参考。具体分析如下:

提示:

1. 导入 System.IO
2. 创建 类C lass “CreateThumbnails”
or any class and place following function inside that class

You need one function to response call back to main function

Function ImageAbortDummyCallback() As Boolean
Return False
End Function

具体代码如下:

Function CreateJPEGThumbnail(ByVal inSourceFile As String, ByVal inDestinationFile As String, ByVal ThumbWidth As Integer, ByVal ThumbHeight As Integer) As Boolean
  Dim imageFile As System.Drawing.Image
  Dim outputFstream As New FileStream(inSourceFile, FileMode.Open, FileAccess.Read) 
  'Exposes a System.IO.Stream around a file, supporting both synchronous and asynchronous read and write operations.
  Dim ImageAbortCallBack As System.Drawing.Image.GetThumbnailImageAbort 
  'This method returns true if it decides that the System.Drawing.Image.GetThumbnailImage method should prematurely stop execution; otherwise, it returns false.
  imageFile = System.Drawing.Image.FromStream(outputFstream)
  ImageAbortCallBack = New System.Drawing.Image.GetThumbnailImageAbort(AddressOf ImageAbortDummyCallback)
  imageFile = imageFile.GetThumbnailImage(ThumbWidth, ThumbHeight, ImageAbortCallBack, IntPtr.Zero) 
  'IntPtr = A platform-specific type that is used to represent a pointer or a handle.
  imageFile.Save(inDestinationFile, System.Drawing.Imaging.ImageFormat.Jpeg)
  outputFstream.Close()
  outputFstream = Nothing
  imageFile = Nothing
End Function

希望本文所述对大家的asp.net程序设计有所帮助。

您可能感兴趣的文章:

  • asp.net生成缩略图示例方法分享
  • asp.net中生成缩略图并添加版权实例代码
  • asp.net生成缩略图实现代码
  • asp.net文件上传功能(单文件,多文件,自定义生成缩略图,水印)
  • asp.net 生成缩略图代码
  • asp.net 上传图片并同时生成缩略图的代码
  • asp.net 点缩略图弹出随图片大小自动调整的页面
  • ASP.Net 上传图片并生成高清晰缩略图
  • asp.net生成高质量缩略图通用函数(c#代码),支持多种生成方式
  • ASP.NET中高质量缩略图的生成代码
  • asp.net图片上传生成缩略图的注意事项
  • ASP.NET实现根据URL生成网页缩略图的方法
声明:本站(华域联盟www.cnhackhy.com)所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。