I’ve been looking around and reading about handlers, but I don’t fully understand how to implement them for my situation.
I want display a screenshot from the user’s clipboard. I already have code that retrieves the image from the clipboard into a bitmap format. This is what I have:
var dataobj = new DataObject();
dataobj = (DataObject)Clipboard.GetDataObject();
System.Drawing.Image img = dataobj.GetData(DataFormats.Bitmap) as System.Drawing.Image;
original = (System.Drawing.Image)img.Clone();
img = resizeImage(img, new Size(670, 500));
String s = "c:/Temp/temp.png";
img.Save(s, ImageFormat.Png);
Image1.ImageUrl = s;
Image1.DataBind();
My problem was that I am not able to save the images to the hard disk.
My first question is will an image handler help me in this situation?
if it will, how do I modify that code and tie it into my image handler with this code:
public class getmyimage : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
HttpResponse r = context.Response;
r.ContentType = "image/png";
// Write the requested image
r.WriteFile("temp.png");
}
public bool IsReusable
{
get { return false; }
}
}
Hello handlers http allow customers to redirect or rewrite requests, format headers of requests for security reasons, or display a banner in some forums. but for your example i think you don’t need http handler