Torna al Thread
<%@ WebHandler Language="C#" Class="Thumb" %>
using System;
using System.Web;
using System.Drawing;
using System.IO;
public class Thumb : IHttpHandler {
public bool ThumbnailCallback()
{
return false;
}
public bool IsReusable
{
get { return false; }
}
public void ProcessRequest(HttpContext context)
{
Image.GetThumbnailImageAbort myCallback = new Image.GetThumbnailImageAbort(ThumbnailCallback);
Bitmap myBitmap;
Image myThumbnail;
string filePath = Path.Combine(context.Server.MapPath("."), context.Request.QueryString["file"]);
myBitmap = new Bitmap(filePath);
myThumbnail = myBitmap.GetThumbnailImage(100, 100, myCallback, IntPtr.Zero);
myThumbnail.Save(context.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
myThumbnail.Dispose();
myBitmap.Dispose();
}
}