How to generate a thumbnail of files uploaded by users!

xiaoxiao2021-03-06  72

Specifically give an example clear. . as follows:

System.Web.httppostedFile Upfile = UPMHTFILE.POSTEDFILE;

System.io.Stream StreamObject = Upfile.InputStream;

System.IO.FileStream MyStream = new system.io.filestream (Upfile.FileName, System.IO.FileMode.Open, System.IO.FileAccess.read);

System.drawing.Image.getthumbnailimageabort mycallback =

New system.drawing.image.getthumbnailImageabort (thumbnailcallback);

System.drawing.image img1 = system.drawing.Image.fromstream (streamObject);

System.drawing.Image Timg = img1.getthumbnailimage (100, 100, MyCallback, System.intptr.zero);

Timg.save (response.outputstream, system.drawing.imaging.imageformat.jpeg);

UPMHTFILE is a UPFile WebControl, which converts uploaded pictures to streams, then generates a thumbnail, and stored directly in the output stream, which is generally used to generate picture browsing after reading out of the database.

转载请注明原文地址:https://www.9cbs.com/read-108947.html

New Post(0)