当前位置: 移动技术网 > IT编程>开发语言>.net > ASP.NET创建动态缩略图的方法

ASP.NET创建动态缩略图的方法

2017年12月12日  | 移动技术网IT编程  | 我要评论

杜华瑾,为保名声不许求助,北京缓解拥堵

本文实例讲述了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程序设计有所帮助。

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网