我有一个视图,我在Slider中显示图像列表,但是当用户选择两个图像时,想要编码,控制器应该将图像相互合并,并在两个图像上实现一些文本。可能在Jquery中它复制了两个div并将它们转换为图像并很好地发送到控制器。
任何一个例子 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;
}
答案 0 :(得分:1)
您不必复制这两个div,假设您在页面上的图像在服务器上,您可以简单地向用户询问这两个图像,然后将文件路径上传为json,然后从中检索它们控制器本身的文件夹,然后从那里开始。