예제 #1
0
        public static PostImage CreateFromPostedFile(HttpPostedFileBase newImage)
        {
            var binaryReader = new BinaryReader(newImage.InputStream);
            var fileData = binaryReader.ReadBytes(newImage.ContentLength);

            PostImage image = new PostImage { Image = fileData, DateTime = DateTime.Now };

            return image;
        }
예제 #2
0
 public PostImage AddImage(PostImage image)
 {
     image = _db.Images.Add(image);
     _db.SaveChanges();
     return image;
 }
예제 #3
0
 private static MemoryStream ResizeImage(PostImage postImage, int height , int width)
 {
     MemoryStream outStream;
     using (outStream = new MemoryStream())
     {
         using (var inStream = new MemoryStream(postImage.Image))
         {
             var settings = new ResizeSettings("maxwidth="+width+"&maxheight="+height);
             ImageResizer.ImageBuilder.Current.Build(inStream, outStream, settings);
             postImage.Image = outStream.ToArray();
             //   return new FileContentResult(outBytes, "image/jpeg");
         }
     }
     return outStream;
 }
예제 #4
0
        private PostImage UploadPicture(HttpPostedFileBase NewImage, string caption)
        {
            var binaryReader = new BinaryReader(NewImage.InputStream);
            var fileData = binaryReader.ReadBytes(NewImage.ContentLength);

            PostImage image = new PostImage { Image = fileData, DateTime = DateTime.Now, Caption = caption};
            return _blogPostDao.AddImage(image);
        }
예제 #5
0
 private static MemoryStream ReizeImage(PostImage postImage)
 {
     return ResizeImage(postImage, 1000, 1000);
 }