Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vb.net 生成二维码_Vb.net_Image_Qr Code - Fatal编程技术网

Vb.net 生成二维码

Vb.net 生成二维码,vb.net,image,qr-code,Vb.net,Image,Qr Code,我正在写一个应用程序,它将生成二维码 大部分编程逻辑都已实现 该过程的下一步是生成二维码图像 最简单的二维码是基于21x21网格的,我必须在其中制作一个黑白瓷砖(1x1) 有关更多信息: 最好的方法是什么 我需要: 在应用程序中显示代码的预览 为用户提供将二维码保存为图像(.jpg)的选项 也就是说,如何制作可以像上面那样构建的图像以及如何保存它?我个人会尝试使用谷歌图表服务来生成二维码图像。简单明了。下面是一幅来自谷歌网站的图片示例 请在此处查看文档: 要创建二维码图像,您需要在应用程序中生

我正在写一个应用程序,它将生成二维码

大部分编程逻辑都已实现

该过程的下一步是生成二维码图像

最简单的二维码是基于21x21网格的,我必须在其中制作一个黑白瓷砖(1x1)

有关更多信息:

最好的方法是什么

我需要:

  • 在应用程序中显示代码的预览

  • 为用户提供将二维码保存为图像(.jpg)的选项


  • 也就是说,如何制作可以像上面那样构建的图像以及如何保存它?

    我个人会尝试使用谷歌图表服务来生成二维码图像。简单明了。下面是一幅来自谷歌网站的图片示例

    请在此处查看文档:
    要创建二维码图像,您需要在应用程序中生成位图。执行此操作的示例代码是:

    'Create a new QR bitmap image  
    Dim bmp As New Bitmap(21, 21)
    
    'Get the graphics object to manipulate the bitmap
    Dim gr As Graphics = Graphics.FromImage(bmp)
    
    'Set the background of the bitmap to white
    gr.FillRectangle(Brushes.White, 0, 0, 21, 21)
    
    'Draw position detection patterns
    'Top Left
    gr.DrawRectangle(Pens.Black, 0, 0, 6, 6)
    gr.FillRectangle(Brushes.Black, 2, 2, 3, 3)
    
    'Top Right
    gr.DrawRectangle(Pens.Black, 14, 0, 6, 6)
    gr.FillRectangle(Brushes.Black, 2, 16, 3, 3)
    
    'Bottom Left
    gr.DrawRectangle(Pens.Black, 0, 14, 6, 6)
    gr.FillRectangle(Brushes.Black, 16, 2, 3, 3)
    
    
    '*** Drawing pixels is done off the bitmap object, not the graphics object
    
    'Arbitrary black pixel
    bmp.SetPixel(8, 14, Color.Black)
    
    'Top timing pattern
    bmp.SetPixel(8, 6, Color.Black)
    bmp.SetPixel(10, 6, Color.Black)
    bmp.SetPixel(12, 6, Color.Black)
    
    'Left timing pattern
    bmp.SetPixel(6, 8, Color.Black)
    bmp.SetPixel(6, 10, Color.Black)
    bmp.SetPixel(6, 12, Color.Black)
    
    'Add code here to set the rest of the pixels as needed
    
    为了向最终用户显示图像,您可以使用PictureBox控件:

    Me.PictureBox1.Image = bmp
    
    最后,为了保存位图,可以对其调用save函数:

    bmp.Save("C:\QR.jpg", Drawing.Imaging.ImageFormat.Jpeg)
    

    你看过这个Stackoverflow问题吗@Mark Hall:我不是在找二维码库。我已经把我需要的东西都(编码)好了。除了图像的生成。这个代码项目库可能会帮助你,但这并不是我问题的答案。下一步是什么?建议使用Regex/jQuery?;)根据链接。。此api已被弃用,取而代之的是