Esempio n. 1
0
 private static Action <Stream> GetImageContent(string imagePath)
 {
     return(stream =>
     {
         var image = System.Drawing.Image.FromFile(GenericFileResponse.GetFilePath(imagePath));
         image.Save(stream, image.RawFormat);
     });
 }
Esempio n. 2
0
 public ImageResponse(string imagePath)
 {
     if (string.IsNullOrEmpty(imagePath) ||
         !File.Exists(GenericFileResponse.GetFilePath(imagePath)) ||
         !Path.HasExtension(imagePath))
     {
         this.StatusCode = HttpStatusCode.NotFound;
     }
     else
     {
         this.Contents    = GetImageContent(imagePath);
         this.ContentType = "image/" + Path.GetExtension(imagePath).Substring(1);
         this.StatusCode  = HttpStatusCode.OK;
     }
 }