0

I have a QR Code sample from a manufacturer for a mobile printer (below). What I need to know is how to generate a new QR Code in the same format? How do I create a QR Code in this format (actually I would prefer a byte array).

What confuses me is the hex data, it is not square nor does is seem to represent "ons" and "offs" as I would expect a QR code to do. I have tried using Zxing:

public byte[] CreateQRCode()
{
    Charset charset = Charset.forName("UTF-8");
    CharsetEncoder encoder = charset.newEncoder();
    byte[] b = null;
    try {
        // Convert a string to UTF-8 bytes in a ByteBuffer
        ByteBuffer bbuf = encoder.encode(CharBuffer.wrap("utf 8 characters - i used hebrew, but you should write some of your own language characters"));
        b = bbuf.array();
    } catch (CharacterCodingException e) {
        System.out.println(e.getMessage());
    }

    String data;
    try {
        data = new String(b, "UTF-8");
        // get a byte matrix for the data
        BitMatrix matrix = null;
        int h = 100;
        int w = 100;
        com.google.zxing.Writer writer = new MultiFormatWriter();
        try {
            Hashtable<EncodeHintType, String> hints = new Hashtable<EncodeHintType, String>(2);
            hints.put(EncodeHintType.CHARACTER_SET, "UTF-8");
            matrix = writer.encode(data,
                    com.google.zxing.BarcodeFormat.QR_CODE, w, h, hints);
        } catch (com.google.zxing.WriterException e) {
            System.out.println(e.getMessage());
        }
        //matrix.get(x, y) returns a boolean
        //matrix.getRow(arg0, arg1) takes a BitRow as a parameter - not sure how to use that method         
    } catch (UnsupportedEncodingException e) {
        System.out.println(e.getMessage());
    }       
}

What is confusing about the zxing code is that it takes width and height as a parameter... did they only write this library for it to produce images?

Hex QR Code:
1B 4B 2E 00 00 00 3F 3F 30 30 33 33 33 33 33 33 30 30 3F 3F 00 00 00 00 0C 0C 0F 0F 30 30 03 03 00 00 3F 3F 30 30 33 33 33 33 33 33 30 30 3F 3F 00 00 0D 1B 4B 2E 00 00 00 FF FF 03 03 F3 F3 F3 F3 F3 F3 03 03 FF FF 00 00 CF CF FC FC 3F 3F 0C 0C CF CF 00 00 FF FF 03 03 F3 F3 F3 F3 F3 F3 03 03 FF FF 00 00 0D 1B 4B 2E 00 00 00 0F 0F 3C 3C 3C 3C 0C 0C 00 00 0F 0F 33 33 00 00 CC CC FC FC CF CF 3C 3C 00 00 0F 0F 3C 3C 3F 3F 03 03 33 33 00 00 0C 0C 0F 0F 00 00 0D 1B 4B 2E 00 00 00 C3 C3 F3 F3 33 33 33 33 C3 C3 03 03 33 33 F0 F0 0C 0C FC FC 03 03 CC CC FF FF F0 F0 F3 F3 F0 F0 30 30 FC FC 0C 0C 3C 3C 3F 3F 00 00 0D 1B 4B 2E 00 00 00 FF FF 00 00 3F 3F 3F 3F 3F 3F 00 00 FF FF 00 00 03 03 F0 F0 3C 3C FF FF F3 F3 0F 0F 3C 3C 03 03 C3 C3 CF CF 00 00 C3 C3 33 33 00 00 0D 1B 4B 2E 00 00 00 F0 F0 30 30 30 30 30 30 30 30 30 30 F0 F0 00 00 C0 C0 C0 C0 C0 C0 F0 F0 30 30 F0 F0 F0 F0 F0 F0 30 30 F0 F0 00 00 00 00 30 30 00 00 0D


Image:
enter image description here

EDIT

This is the documentation:
3.24 ESC K Nl Nh d1 d2….dK
[Name] select bitmap print mode 1
[Format] ASCII ESC K nL nH d1….dK
Hex 1B 4B nL nH d1….dK
Decimal 27 75 nL nH d1….dK
[Range]
0 ≤ nL ≤ 255
0 ≤ nH ≤ 1
0 ≤ d ≤ 255
[Description] the maximum height of this command is 8 dots, and maximum width is in printable zone;
nL nH is low bit and high bit of the no-character bitmap, it represent the dots in the bitmap.
[Note]
• This command is under controlled by the command of amplify character;
When printers adapt reverse print command, This bitmap will be printed from bottom to top.

[Program example ]
Unsigned char Str[30];
Unsigned char i=0;
Str[i++] = 0x1B;
Str[i++] = 0x4B;
Str[i++] = 15; print 15-dot wide bitmap;
Str[i++] = 0x7C; Str[i++] = 0x44; Str[i++] = 0x44; Str[i++] = 0xFF;
Str[i++] = 0x44; Str[i++] = 0x44; Str[i++] = 0x7C; Str[i++] = 0x00;
Str[i++] = 0x41; Str[i++] = 0x62; Str[i++] = 0x54; Str[i++] = 0XC8;
Str[i++] = 0x54; Str[i++] = 0x62; Str[i++] = 0x41; Str[i++] = 0x0D;
SendDataToPrinter(Str,i); send bitmap command;
4

1 に答える 1

0

「同じ形式」とはどういう意味ですか? QR コードだけですか? はい、あなたはそれを正しくやっています。

このメソッドは幅/高さを取ります。これがないと意味がないためです。他の形式の場合もあります。「ピクセル」ごとに 1 つのモジュールを持つ生の QR コードだけが必要な場合は、Encodeクラス自体を見てください。

テスト用 QR コードには「prova」と表示されています。ヘックスがここにあるはずのものはわかりません。最後の部分が何であるかも明らかではありません。それが望ましい形式を説明している場合、それはあなたの例が従うものではありません。

これには多くの説明が必要です。

于 2013-08-04T21:42:29.133 に答える