如何在zbar中为Android平台禁用未使用的符号?

时间:2014-08-02 14:13:36

标签: android barcode zxing barcode-scanner zbar

我已将Android的zbar扫描程序集成到我的应用程序中,我只使用该应用程序扫描qrcode,所以现在我想通过禁用未使用的符号系统(如PDF417 CODE39等)来优化阅读器,我应该在哪里更改?我总是想知道Symbol.java文件中数字的含义是什么,比如“QRCODE = 64”Thx :) 这些是一些核心文件:

Config.java

public class Config
{

    public static final int ENABLE = 0;
    public static final int ADD_CHECK = 1;
    public static final int EMIT_CHECK = 2;
    public static final int ASCII = 3;
    public static final int MIN_LEN = 32;
    public static final int MAX_LEN = 33;
    public static final int UNCERTAINTY = 64;
    public static final int POSITION = 128;
    public static final int X_DENSITY = 400;
    public static final int Y_DENSITY = 400;

}

Symbol.java

public class Symbol
{

    public static final int NONE = 0;
    public static final int PARTIAL = 1;
    public static final int EAN8 = 8;
    public static final int UPCE = 9;
    public static final int ISBN10 = 10;
    public static final int UPCA = 12;
    public static final int EAN13 = 13;
    public static final int ISBN13 = 14;
    public static final int I25 = 25;
    public static final int DATABAR = 34;
    public static final int DATABAR_EXP = 35;
    public static final int CODABAR = 38;
    public static final int CODE39 = 39;
    public static final int PDF417 = 57;
    public static final int QRCODE = 64;
    public static final int CODE93 = 93;
    public static final int CODE128 = 128;
    private long peer;
    private int type;

    private static native void init();

    Symbol(long l)
    {
        peer = l;
    }

    protected void finalize()
    {
        destroy();
    }

    public synchronized void destroy()
    {
        if (peer != 0L)
        {
            destroy(peer);
            peer = 0L;
        }
    }

    private native void destroy(long l);

    public int getType()
    {
        if (type == 0)
            type = getType(peer);
        return type;
    }

    private native int getType(long l);

    public native int getConfigMask();

    public native int getModifierMask();

    public native String getData();

    public native byte[] getDataBytes();

    public native int getQuality();

    public native int getCount();

    public int[] getBounds()
    {
        int i = getLocationSize(peer);
        if (i <= 0)
            return null;
        int ai[] = new int[4];
        int j = 0x7fffffff;
        int k = 0x80000000;
        int l = 0x7fffffff;
        int i1 = 0x80000000;
        for (int j1 = 0; j1 < i; j1++)
        {
            int k1 = getLocationX(peer, j1);
            if (j > k1)
                j = k1;
            if (k < k1)
                k = k1;
            int l1 = getLocationY(peer, j1);
            if (l > l1)
                l = l1;
            if (i1 < l1)
                i1 = l1;
        }

        ai[0] = j;
        ai[1] = l;
        ai[2] = k - j;
        ai[3] = i1 - l;
        return ai;
    }

    private native int getLocationSize(long l);

    private native int getLocationX(long l, int i);

    private native int getLocationY(long l, int i);

    public int[] getLocationPoint(int i)
    {
        int ai[] = new int[2];
        ai[0] = getLocationX(peer, i);
        ai[1] = getLocationY(peer, i);
        return ai;
    }

    public native int getOrientation();

    public SymbolSet getComponents()
    {
        return new SymbolSet(getComponents(peer));
    }

    private native long getComponents(long l);

    native long next();

    static
    {
        System.loadLibrary("zbarjni");
        init();
    }
}

Modifier.java

public class Modifier
{

    public static final int GS1 = 0;
    public static final int AIM = 1;

    public Modifier()
    {
    }
}

SymbolSet.java

public class SymbolSet extends AbstractCollection
{

    private long peer;

    private static native void init();

    SymbolSet(long l)
    {
        peer = l;
    }

    protected void finalize()
    {
        destroy();
    }

    public synchronized void destroy()
    {
        if (peer != 0L)
        {
            destroy(peer);
            peer = 0L;
        }
    }

    private native void destroy(long l);

    public Iterator iterator()
    {
        long l = firstSymbol(peer);
        if (l == 0L)
            return new SymbolIterator(null);
        else
            return new SymbolIterator(new Symbol(l));
    }

    public native int size();

    private native long firstSymbol(long l);

    static
    {
        System.loadLibrary("zbarjni");
        init();
    }
}

1 个答案:

答案 0 :(得分:2)

像这样:

scanner = new ImageScanner();
// disable all symbologies first
scanner.setConfig(0, Config.ENABLE, 0);
// only enable QRCODE
scanner.setConfig(Symbol.QRCODE, Config.ENABLE, 1);

对于setConfig,有三个参数都是int&#39; s。第一个是您想要使用Symbol静态属性影响的符号,或者对所有符号使用0。第二个是您要使用Config静态属性设置的设置。第三是设定值。