[android]代码库
public static void encode(String content, String format, String filePath) {
try {
Hashtable hints = new Hashtable();//设置编码类型
hints.put(EncodeHintType.CHARACTER_SET, DEFAULT_ENCODING); //编码
BitMatrix bitMatrix = new QRCodeWriter().encode(content,
BarcodeFormat.QR_CODE, DEFAULT_IMAGE_WIDTH,
DEFAULT_IMAGE_HEIGHT,hints);
//输出到文件,也可以输出到流
File file = new File(filePath);
MatrixToImageWriter.writeToFile(bitMatrix, format, file);
} catch (IOException e) {
e.printStackTrace();
} catch (WriterException e1) {
e1.printStackTrace();
}
}