當(dāng)我們要上傳圖片的時候,往往需要生成縮略圖,以往我們要使用第三方控件才能完成。在asp.net中用下面方法輕松搞定 <script language="vb" runat="server"> sub page_load(sender as object, e as eventargs)
dim image,anewimage as system.drawing.image dim width,height,newwidth,newheight as integer dim callb as system.drawing.image.getthumbnailimageabort
'生成縮略圖 image=system.drawing.image.fromfile(server.mappath("classpic/"+"rs1.jpg")) width=image.width height=image.height if width>height then newwidth=110 newheight=image.height/image.width*newwidth else newheight=110 newwidth=image.width/image.height*newheight end if