Torna al Thread
<%@ WebHandler Language="C#" Class="Thumb" %>
using System;
using System.Web;
using System.Drawing;
public class Thumb : IHttpHandler {
public bool ThumbnailCallback()
{
return false;
}
public bool IsReusable {
get { return false; }
}
public void ProcessRequest(HttpContext context)
{
System.Drawing.Image.GetThumbnailImageAbort myCallback = new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback);
System.Drawing.Bitmap myBitmap;
System.Drawing.Image myThumbnail;
bool zNoImg = false;
string zParam = string.Empty;
string zFile = string.Empty;
string zPath = context.Server.MapPath("~/public/foto/");
if (System.IO.File.Exists(zPath + context.Request.QueryString["nomefile"]))
{
zFile = zPath + context.Request.QueryString["nomefile"];
}
else
{
zFile = zPath + "none.jpg";
zNoImg = true;
}
myBitmap = new System.Drawing.Bitmap(zFile);
if (!zNoImg)
myThumbnail = myBitmap.GetThumbnailImage(100, 100, myCallback, IntPtr.Zero);
else
myThumbnail = myBitmap;
myThumbnail.Save(context.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
myThumbnail.Dispose();
myBitmap.Dispose();
}
}