我需要开发一个web应用程序,需要扫描二维码,并读取它的内容。
有没有可能使用Asp.net Web应用程序,所使用的代码是C#。
是否可以在web应用程序中使用c#.net拍摄并保存照片
发布于 2017-10-23 15:23:48
在浏览器客户端拍照。将图像数据发送到c#页。
<input id="upload" name="upload" type="file" accept="image/*" />它只是一个html文件输入,你可以得到QR图像数据,当图像接收到选择或相机。
$("#upload").on('change', function() {
var file = $(this)[0].files[0];
if(!file) {//undefined
return;
}
if(!startLoading()) {
return;
}
var file = $(this)[0].files[0];
var reader = new FileReader();
reader.readAsDataURL(file); // read file as Data URL
reader.onload = function() {
var base64 = this.result;
//send this base64 string to c# backend page using ajax
...
});然后在您的c#页面中编写代码,获取base64字符串,更改为图像。
byte[] arr2 = Convert.FromBase64String(base64);
using (MemoryStream ms2 = new MemoryStream(arr2))
{
System.Drawing.Bitmap bmp2 = new System.Drawing.Bitmap(ms2);
bmp2.Save(filePath + ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
...https://stackoverflow.com/questions/46860004
复制相似问题