Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int width = iPara_size; // QRコードの横サイズ
- int height = iPara_size; // QRコードの縦サイズ
- // 異なる型の値を入れるためgenericは使えない
- Hashtable<EncodeHintType, ErrorCorrectionLevel> hints = new Hashtable<EncodeHintType, ErrorCorrectionLevel>();
- // 日本語を扱うためにシフトJISを指定
- //エラー修復レベルを指定
- // ErrorCorrectionLevel.L : 7%の補正レベル
- // ErrorCorrectionLevel.M : 15%の補正レベル
- // ErrorCorrectionLevel.Q : 25%の補正レベル
- // ErrorCorrectionLevel.H : 30%の補正レベル
- hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.M);
- //QRコードをエンコードするクラス
- QRCodeWriter writer = new QRCodeWriter();
- BitMatrix bitMatrix = writer.encode(contents, format, width, height, hints);
- BufferedImage image = MatrixToImageWriter.toBufferedImage(bitMatrix);
- ImageIO.write(image, "png", new File("/usr/local/apache-tomcat-5.5.33/webapps/ROOT/api/file/qr_code_0001/barcode.png"));
- return null;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement