2013-05-10 104 views
-3

我有一个视图,我显示的图像列表中的滑块每一件事情都完成了,但想要编码时,用户选择两个图像的控制器应该合并图像彼此,也执行一些text.well是否有可能在Jquery中复制两个div并将它们转换为图像并发送给控制器。Asp.net mvc 4合并两个图像

任何例子 C# jQuery,请让我知道

[HttpPost] 
     public ActionResult Index(HttpPostedFileBase Imageone, HttpPostedFileBase Imagetwo) 
     { 



      return View(); 
     } 

    public static System.IO.MemoryStream CombineImages(byte[] imageBytes1, byte[] imageBytes2) 
     { 
      if ((imageBytes1 == null || imageBytes1.Length == 0) || 
       (imageBytes2 == null || imageBytes2.Length == 0)) 
       return null; 

      //convert bytes to Image 
      var image1 = System.Drawing.Image.FromStream(new System.IO.MemoryStream(imageBytes1)); 
      var image2 = System.Drawing.Image.FromStream(new System.IO.MemoryStream(imageBytes2)); 

      //create the Bitmap object 
      var bitmap = new System.Drawing.Bitmap(image1.Width, image1.Height, PixelFormat.Format32bppPArgb); 
      //create the Graphics object 
      var g = System.Drawing.Graphics.FromImage(bitmap); 

      g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; 
      g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High; 
      g.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality; 

      g.DrawImage(image1, 0, 0); 

      g.DrawImage(image2, 0, 0); 

      var ms = new System.IO.MemoryStream(bitmap.Width * bitmap.Height); 

      bitmap.Save(ms, System.Drawing.Imaging.ImageFormat.Png); 

      return ms; 

     } 

回答

1

你不必同时复制的div,假设你在页面上的图像您的服务器上,你可以简单地询问用户对于这两个图像,只需将文件路径上传为json,然后从控制器本身的文件夹中检索它们并从那里开始。