ZXing を使用して QR コードを生成し、画面に表示したいのですが、QR コードを特定の背景 [画像] の上に表示する必要があります。ZXingで可能ですか?
ありがとう
編集:ステータスバーのタイトルをプレーンテキスト[私はTYPE_TEXTを使用しています]から別のものに変更できることも素晴らしいでしょう。
これは、ZXING ライブラリを使用して透明な QR コードを作成する方法の例です。
QRCodeWriter qrCodeWriter = new QRCodeWriter();
// create output image
BufferedImage image = new BufferedImage(382, 382, BufferedImage.TYPE_INT_ARGB);
// create bit matrix
BitMatrix bitMatrix = new MultiFormatWriter().encode(
qrCodeString,
BarcodeFormat.QR_CODE, 382, 382);
// set pixels of output image based of bit matrix (black or translucent)
for (int i = 0; i < 382; i++) {
for (int j = 0; j < 382; j++) {
image.setRGB(i,j, bitMatrix.get(i,j) ? Color.BLACK.getRGB() : Color.TRANSLUCENT);
}
}
// write output image as png
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
ImageIO.write(image, "PNG", outputStream);
ライブラリを使用してバーコード イメージを作成し、独自のアクティビティに表示するだけです。好きなようにスタイリングできます。
方法はありません。通常、バーコードには周囲に白い静かなゾーンが必要なため、一般的にやりたいことではありません。これが本当に必要な場合は、独自のレイアウトを作成し、ディスプレイを作成するのと同じ種類のコードを埋め込む場合です。