【问题标题】:QR Code Scanning in Asp.net Web application and taking picture option using c#在 Asp.net Web 应用程序中扫描二维码并使用 c# 拍照选项
【发布时间】:2017-10-21 04:16:38
【问题描述】:

我需要开发一个需要扫描二维码并读取其中内容的网络应用程序。

是否可以用Asp.net Web 应用,后面使用的代码是C#。

是否可以在 web 应用程序中使用 c#.net 拍照并保存

【问题讨论】:

    标签: c# asp.net camera qr-code


    【解决方案1】:

    在浏览器客户端拍照。将图像数据发送到 c# 页面。

    <input id="upload" name="upload" type="file" accept="image/*" />
    

    只是一个html文件输入,当select或camera接收到图像时,你可以得到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); 
        ...
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-11-24
      • 2021-08-24
      • 1970-01-01
      • 1970-01-01
      • 2020-06-18
      • 1970-01-01
      相关资源
      最近更新 更多