Asp.net mvc 4 base64图像到视频输出文件的序列
net MVC4应用程序。Asp.net mvc 4 base64图像到视频输出文件的序列,asp.net-mvc-4,html5-canvas,Asp.net Mvc 4,Html5 Canvas,net MVC4应用程序。 如何在asp.net mvc4应用程序中生成视频文件。我有一组URL,它们是从画布输出生成的base64格式的图像序列。请给我推荐控制器代码 以下是发送画布数据的ajax和接收画布数据的控制器代码: // Send the canvas image to the server using ajax // You can modify this ajax to fit your needs, var canvas=getElementById("yourCanvas"
如何在asp.net mvc4应用程序中生成视频文件。我有一组URL,它们是从画布输出生成的base64格式的图像序列。请给我推荐控制器代码 以下是发送画布数据的ajax和接收画布数据的控制器代码:
// Send the canvas image to the server using ajax
// You can modify this ajax to fit your needs,
var canvas=getElementById("yourCanvas");
var image = canvas.toDataURL("image/png");
image = image.replace('data:image/png;base64,', '');
$.ajax({
type: 'POST',
url: 'yourController/UploadImage',
data: '{ "imageData" : "' + image + '" }',
contentType: 'application/json; charset=utf-8',
dataType: 'json',
success: function(msg){ console.log(msg); }
});
// receive the 64bit encoded string in the controller
// I just convert it to an Image,
// but you can do what you want with the MemoryStream
[HttpPost]
public ActionResult UploadImage(string imageData)
{
byte[] byteArray = System.Convert.FromBase64String(imageData);
// convert to an image (or do whatever else you need to do)
Image image;
using(MemoryStream s=new MemoryStream(byteArray){
image=Image.FromStream(ms);
}
return("done");
}
以下是发送画布数据的ajax和接收画布数据的控制器代码:
// Send the canvas image to the server using ajax
// You can modify this ajax to fit your needs,
var canvas=getElementById("yourCanvas");
var image = canvas.toDataURL("image/png");
image = image.replace('data:image/png;base64,', '');
$.ajax({
type: 'POST',
url: 'yourController/UploadImage',
data: '{ "imageData" : "' + image + '" }',
contentType: 'application/json; charset=utf-8',
dataType: 'json',
success: function(msg){ console.log(msg); }
});
// receive the 64bit encoded string in the controller
// I just convert it to an Image,
// but you can do what you want with the MemoryStream
[HttpPost]
public ActionResult UploadImage(string imageData)
{
byte[] byteArray = System.Convert.FromBase64String(imageData);
// convert to an image (or do whatever else you need to do)
Image image;
using(MemoryStream s=new MemoryStream(byteArray){
image=Image.FromStream(ms);
}
return("done");
}