たとえば、XML のかなり大きなデータセットがあります。
<book id=“…” serial_no="8472385" height="210" width="600" books="1">
<content>
<barcode encoding="code128c" data1="22" data2="50" description="Barcode 1”>…</barcode>
<barcode encoding="code128c" data1="510" data2="75" description="Barcode 2”>…</barcode>
<chapter sections="8" data1="214" data2="12" description=“Info 1”>…</chapter>
<chapter sections="11" data1="88" data2="63" description=“Info 2”>…</chapter>
<chapter sections="16" data1="88" data2="42" description=“Info 3”>…</chapter>
<chapter sections="13" data1="88" data2="83" description=“Info 4”>…</chapter>
<chapter sections="11" data1="88" data2="105" description=“Info 5“>Mon, 24 Aug 2015, 8:30am</chapter>
<chapter sections="18" data1="286" data2="120" description=“Info 6”>…</chapter>
<chapter sections="19" data1="466" data2="12" description=“Info 7“>…</chapter>
<chapter sections="11" data1="496" data2="26" description=“Info 8“>…</chapter>
<chapter sections="9" data1="531" data2="28" description=“Info 9“>…</chapter>
<chapter sections="11" data1="497" data2="12" description=“Info 10“>8:30am</chapter>
<chapter sections="12" data1="88" data2="147" description=“Info 11“>…</chapter>
<chapter sections="10" data1="88" data2="125" description=“Info 12”>…</chapter>
<chapter sections="13" data1="338" data2="158" description=“Info 13”>…</chapter>
<chapter sections="9" data1="81" data2="192" description="book Id”>…</chapter>
<chapter sections="8" data1="394" data2="192" description="book Id”>…</chapter>
<chapter sections="8" data1="140" data2="12" description=“Info 14”>…</chapter>
<chapter sections="9" data1="132" data2="192" description="" />
<chapter sections="10" data1="88" data2="177" description=“Info 15“ />
<chapter sections="12" data1="88" data2="163" description="Some sample data”>…</chapter>
<chapter sections="8" data1="286" data2="192" description="Time Stamp">2015-08-19 10:00:55</chapter>
<logo data1="402" data2="37" description="Logo">cache/images/logoSample.pcx</logo>
<logo_gif data1="402" data2="37" description="Logo">cache/images/book_….gif</logo_gif>
<chapter sections="12" data1="446" data2="187" description="Price">$100.00</chapter>
</content>
</book>
そして、これを PDF417 画像にエンコードして、Android デバイス デバイスに表示したいと考えています。ZXing フレームワークをインポートしました。現在、次のようなことを試みています。
ImageView book = (ImageView) mRootView.findViewById(R.id.book_image);
Display display = getActivity().getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
int width = size.x;
int height = size.x / 2;
String raw = bookXmlString.replace("<","<").replace(">",">");
MultiFormatWriter writer = new MultiFormatWriter();
try {
Log.e("PDF_417", String.format("w: %d, h: %d, d: %s", width, height, raw));
BitMatrix bm = writer.encode(raw, BarcodeFormat.PDF_417, width, height);
Bitmap ImageBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
for (int i = 0; i < width; i++) {//width
for (int j = 0; j < height; j++) {//height
ImageBitmap.setPixel(i, j, bm.get(i, j) ? Color.BLACK : Color.WHITE);
}
}
book.setImageBitmap(ImageBitmap);
} catch (WriterException e) {
Log.e("PDF_417", e.getMessage());
}
しかし、次のようなエラーが発生し続けます。
メッセージを列に収めることができません
私は次のようなサイトをクラッシュさせ続けています: - http://www.racoindustries.com/barcodegenerator/2d/pdf417.aspx
より少ないデータをエンコードすると、問題なく PDF417 が得られます。エラー訂正レベルの設定方法もわかりません。
また、ここでメソッドを実装して、幅と高さを設定する最善の方法を試してみましたが、実際にはうまくいきませんでした:列数が固定されている PDF417 バーコードでは、一部のテキストに必要な行数をどのように計算しますか?
要約すると、私は尋ねています:
- 文字列の長さが異なる可能性がある場合、このデータを PDF417 バーコードとしてエンコードする方法は?
- エラー訂正レベルを設定するにはどうすればよいですか?
- 幅/高さと行数/列数を設定する最良の方法は何ですか?