我有一个视图,我在 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;
}