QR Code multi-format 1D/2D barcode
1.QR code free
zxing library: https://github.com/zxing/zxing
How to create QRcode: http://www.swetake.com/qrcode/index-e.html
Open Source QR Code Library: https://osdn.jp/projects/qrcode
jquery.qrcode.js: https://github.com/jeromeetienne/jquery-qrcode
2.PDF417 no utf-16
3.DM no free
https://en.wikipedia.org/wiki/VCard
<!DOCTYPE html>
<html>
<head>
<title>basic example</title>
</head>
<body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>
<!--<script type="text/javascript" src="../jquery.qrcode.min.js"></script>
--><script type="text/javascript" src="js/jquery.qrcode.min.js"></script>
<script type="text/javascript" src="js/qrcode.min.js"></script>
<p>Render in table</p>
<div id="qrcodeTable"></div>
<p>Render in canvas</p>
<div id="qrcodeCanvas"></div>
<hr>
<div id="qrcodeCanvas2"></div>
<script>
//jQuery('#qrcode').qrcode("this plugin is great");
jQuery('#qrcodeTable').qrcode({
render : "table",
text : "http://joinxin.blogspot.com Jin XinChen"
});
jQuery('#qrcodeCanvas').qrcode({
text : "joinxin.blogspot.com Jin XinChen"
});
jQuery('#qrcodeCanvas2').qrcode({
render : "canvas",
width:56,
height:56,
typeNumber:-1,
correctLevel : 2,
background:"#ffffff",
foreground:"#000000",
text:"joinxin.blogspot.com Jin XinChen"
});
</script>
</body>
</html>
4. https://github.com/zxing/zxing update in C#
using System;
using ZXing.QrCode;
string contentStr="id2-4905-jin";
var writeQR= new ZXing.BarcodeWriterQRPixelData
{
Format = ZXing.BarcodeFormat.QR_CODE,
Options = new QrCodeEncodingOptions{ Height = 100, Width = 100, Margin = 2 }
};
var QRPixelData = writeQR.Write(contentStr);
using (var bitmap = new System.Drawing.Bitmap(QRPixelData.Width, QRPixelData.Height, System.Drawing.Imaging.PixelFormat.Format32bppRgb))
{
var bitmapData = bitmap.LockBits(new System.Drawing.Rectangle(0, 0, QRPixelData.Width, QRPixelData.Height),
System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppRgb);
try
{
//The row stride of the bitmap is aligned to 4 byte multiplied by the width of the image
System.Runtime.InteropServices.Marshal.Copy(QRPixelData.Pixels, 0, bitmapData.Scan0,
QRPixelData.Pixels.Length);
}
finally
{
bitmap.UnlockBits(bitmapData);
}
bitmap.Save("./wwwroot/images/" + contentStr + ".png", System.Drawing.Imaging.ImageFormat.Png);
}
5. reference :https://stackoverflow.com/questions/8859268/how-to-encode-a-string-in-a-qr-code-using-zxing-on-android
java
zxing library: https://github.com/zxing/zxing
How to create QRcode: http://www.swetake.com/qrcode/index-e.html
Open Source QR Code Library: https://osdn.jp/projects/qrcode
jquery.qrcode.js: https://github.com/jeromeetienne/jquery-qrcode
2.PDF417 no utf-16
3.DM no free
https://en.wikipedia.org/wiki/VCard
/* utf.js - UTF-8 <=> UTF-16 convertion
*
* Copyright (C) 1999 Masanao Izumo <iz@onicos.co.jp>
* Version: 1.0
* LastModified: Dec 25 1999
* This library is free. You can redistribute it and/or modify it.
*/
/*
* Interfaces:
* utf8 = utf16to8(utf16);
* utf16 = utf16to8(utf8);
*/
function utf16to8(str) {
var out, i, len, c;
out = "";
len = str.length;
for(i = 0; i < len; i++) {
c = str.charCodeAt(i);
if ((c >= 0x0001) && (c <= 0x007F)) {
out += str.charAt(i);
} else if (c > 0x07FF) {
out += String.fromCharCode(0xE0 | ((c >> 12) & 0x0F));
out += String.fromCharCode(0x80 | ((c >> 6) & 0x3F));
out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F));
} else {
out += String.fromCharCode(0xC0 | ((c >> 6) & 0x1F));
out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F));
}
}
return out;
}
function utf8to16(str) {
var out, i, len, c;
var char2, char3;
out = "";
len = str.length;
i = 0;
while(i < len) {
c = str.charCodeAt(i++);
switch(c >> 4)
{
case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7:
// 0xxxxxxx
out += str.charAt(i-1);
break;
case 12: case 13:
// 110x xxxx 10xx xxxx
char2 = str.charCodeAt(i++);
out += String.fromCharCode(((c & 0x1F) << 6) | (char2 & 0x3F));
break;
case 14:
// 1110 xxxx 10xx xxxx 10xx xxxx
char2 = str.charCodeAt(i++);
char3 = str.charCodeAt(i++);
out += String.fromCharCode(((c & 0x0F) << 12) |
((char2 & 0x3F) << 6) |
((char3 & 0x3F) << 0));
break;
}
}
return out;
}
----------------------<!DOCTYPE html>
<html>
<head>
<title>basic example</title>
</head>
<body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>
<!--<script type="text/javascript" src="../jquery.qrcode.min.js"></script>
--><script type="text/javascript" src="js/jquery.qrcode.min.js"></script>
<script type="text/javascript" src="js/qrcode.min.js"></script>
<p>Render in table</p>
<div id="qrcodeTable"></div>
<p>Render in canvas</p>
<div id="qrcodeCanvas"></div>
<hr>
<div id="qrcodeCanvas2"></div>
<script>
//jQuery('#qrcode').qrcode("this plugin is great");
jQuery('#qrcodeTable').qrcode({
render : "table",
text : "http://joinxin.blogspot.com Jin XinChen"
});
jQuery('#qrcodeCanvas').qrcode({
text : "joinxin.blogspot.com Jin XinChen"
});
jQuery('#qrcodeCanvas2').qrcode({
render : "canvas",
width:56,
height:56,
typeNumber:-1,
correctLevel : 2,
background:"#ffffff",
foreground:"#000000",
text:"joinxin.blogspot.com Jin XinChen"
});
</script>
</body>
</html>
4. https://github.com/zxing/zxing update in C#
using System;
using ZXing.QrCode;
string contentStr="id2-4905-jin";
var writeQR= new ZXing.BarcodeWriterQRPixelData
{
Format = ZXing.BarcodeFormat.QR_CODE,
Options = new QrCodeEncodingOptions{ Height = 100, Width = 100, Margin = 2 }
};
var QRPixelData = writeQR.Write(contentStr);
using (var bitmap = new System.Drawing.Bitmap(QRPixelData.Width, QRPixelData.Height, System.Drawing.Imaging.PixelFormat.Format32bppRgb))
{
var bitmapData = bitmap.LockBits(new System.Drawing.Rectangle(0, 0, QRPixelData.Width, QRPixelData.Height),
System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppRgb);
try
{
//The row stride of the bitmap is aligned to 4 byte multiplied by the width of the image
System.Runtime.InteropServices.Marshal.Copy(QRPixelData.Pixels, 0, bitmapData.Scan0,
QRPixelData.Pixels.Length);
}
finally
{
bitmap.UnlockBits(bitmapData);
}
bitmap.Save("./wwwroot/images/" + contentStr + ".png", System.Drawing.Imaging.ImageFormat.Png);
}
5. reference :https://stackoverflow.com/questions/8859268/how-to-encode-a-string-in-a-qr-code-using-zxing-on-android
java
public static Bitmap encodeToQrCode(String text, int width, int height){
QRCodeWriter writer = new QRCodeWriter();
BitMatrix matrix = null;
try {
matrix = writer.encode(text, BarcodeFormat.QR_CODE, 100, 100);
} catch (WriterException ex) {
ex.printStackTrace();
}
Bitmap bmp = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565);
for (int x = 0; x < width; x++){
for (int y = 0; y < height; y++){
bmp.setPixel(x, y, matrix.get(x,y) ? Color.BLACK : Color.WHITE);
}
}
return bmp;
}


评论
发表评论