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(); } }
Copyright © dotNetHell.it 2002-2024
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5