→パソコン
→周辺機器
Wi-Fi設定 カレンダーへの予定登録 連絡先への登録 メールアドレス(メール送信) 電話番号による発信 電話番号によるSMS送信 地球上の位置(緯度経度)によるマップの起動 URLによるWebページ閲覧 その他文字列の指定
WIFI:T:WPA;S:mynetwork;P:mypasscode;;
// QRコードクラスライブラリ for Java の準備。
Qrcode qrcodeLogic = new Qrcode();
qrcodeLogic.setQrcodeEncodeMode('*');
qrcodeLogic.setQrcodeErrorCorrect('M');
qrcodeLogic.setQrcodeVersion(7);
// QR コードデータを作成。
byte[] targetBytes = target.getBytes();
boolean[][] qrcodeData = qrcodeLogic.calQrcode(targetBytes);
// QR コード画像用の BufferedImage を準備。
// 周りに 4cell 分のマージンを用意する。
BufferedImage image = new BufferedImage(size.getCellSize()
* (qrcodeData[0].length + 8), size.getCellSize()
* (qrcodeData[0].length + 8), BufferedImage.TYPE_INT_BGR);
Graphics g = image.getGraphics();
g.setColor(QRCODE_IMAGE_BACKGROUNDCOLOR);
g.fillRect(0, 0, image.getWidth(), image.getHeight());
// QR コードデータを画像に変換。
for (int i = 0; i < qrcodeData.length; i++) {
for (int j = 0; j < qrcodeData[i].length; j++) {
boolean cellFilled = qrcodeData[i][j];
Color cellColor = cellFilled ? QRCODE_IMAGE_FOREGROUNDCOLOR
: QRCODE_IMAGE_BACKGROUNDCOLOR;
g.setColor(cellColor);
g.fillRect(size.getCellSize() * (i + 4), size.getCellSize()
* (j + 4), size.getCellSize(), size.getCellSize());
}
}
g.dispose();import pao.barcode.QRCode;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import javax.imageio.ImageIO;
import javax.imageio.ImageWriter;
import javax.imageio.stream.ImageOutputStream;
private static void QRcodeTest() throws Exception,
FileNotFoundException, IOException {
BufferedImage im = new BufferedImage(400, 300,
BufferedImage.TYPE_3BYTE_BGR);
Graphics2D g = im.createGraphics();
g.setColor(Color.WHITE);
g.fillRect(0, 0, 400, 300);
QRCode c = new QRCode(g);
c.setVersion(3); //バージョン
c.setErrorCorrect("M"); //エラー訂正レベル
c.setEncodeMode("A"); //英数字モード
c.drawDelicate("0123456789ABCDEFGHIJ", 10, 10, 3);
// Open output file.
OutputStream out = new FileOutputStream("testQR.jpg");
ImageOutputStream ios =
ImageIO.createImageOutputStream(out);
ImageWriter iw = (ImageWriter)ImageIO.
getImageWritersByFormatName("jpeg").next();
iw.setOutput(ios);
iw.write(im);
// Close output file.
out.close();
}