我正在编写一个应用程序,它将生成qr代码。
大多数编程逻辑都是实现的。
该过程的下一步将是生成qr代码映像。
最简单的qr代码是基于一个21x21网格,在这个网格中,我必须制作一个(1x1)块(1x1),或者是黑色/白色。
欲了解更多信息:http://www.thonky.com/qr-code-tutorial/part-3-mask-pattern/
最好的方法是什么。
我需要:
application
例如,如何制作一个像上面这样的图像,以及如何保存它?
发布于 2011-08-21 00:30:39
为了创建QR代码映像,您需要在应用程序中生成一个位图。这样做的示例代码是:
'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)发布于 2011-08-20 20:33:27
我个人会尝试使用谷歌图表服务,以生成qr代码图像。简单又简单。这是谷歌网站上的一个例子。
https://chart.googleapis.com/chart?chs=150x150&cht=qr&chl=Hello%20world&choe=UTF-8
查看这里的文档:http://code.google.com/apis/chart/infographics/docs/qr_codes.html
https://stackoverflow.com/questions/7134398
复制相似问题