예제 #1
0
int zbar_image_scanner_set_config (zbar_image_scanner_t *iscn,
								   zbar_symbol_type_t sym,
								   zbar_config_t cfg,
								   int val)
{
	if(cfg < ZBAR_CFG_POSITION)
		return(zbar_decoder_set_config(iscn->dcode, sym, cfg, val));

	if(sym > ZBAR_PARTIAL)
		return(1);

	if(cfg >= ZBAR_CFG_X_DENSITY && cfg <= ZBAR_CFG_Y_DENSITY) {

		CFG(iscn, cfg) = val;
		return(0);
	}

	if(cfg > ZBAR_CFG_POSITION)
		return(1);
	cfg -= ZBAR_CFG_POSITION;

	if(!val)
		iscn->config &= ~(1 << cfg);
	else if(val == 1)
		iscn->config |= (1 << cfg);
	else
		return(1);

	return(0);
}
예제 #2
0
int zbar_decoder_set_config (zbar_decoder_t *dcode,
                             zbar_symbol_type_t sym,
                             zbar_config_t cfg,
                             int val)
{
    if(sym == ZBAR_NONE) {
        static const zbar_symbol_type_t all[] = {
	    ZBAR_EAN13, ZBAR_EAN2, ZBAR_EAN5, ZBAR_EAN8,
            ZBAR_UPCA, ZBAR_UPCE, ZBAR_ISBN10, ZBAR_ISBN13,
            ZBAR_I25, ZBAR_DATABAR, ZBAR_DATABAR_EXP,
	    ZBAR_CODE39, ZBAR_CODE93, ZBAR_CODE128, ZBAR_QRCODE, 
	    ZBAR_PDF417, 0
        };
        const zbar_symbol_type_t *symp;
        for(symp = all; *symp; symp++)
            zbar_decoder_set_config(dcode, *symp, cfg, val);
        return(0);
    }

    if(cfg >= 0 && cfg < ZBAR_CFG_NUM)
        return(decoder_set_config_bool(dcode, sym, cfg, val));
    else if(cfg >= ZBAR_CFG_MIN_LEN && cfg <= ZBAR_CFG_MAX_LEN)
        return(decoder_set_config_int(dcode, sym, cfg, val));
    else
        return(1);
}
예제 #3
0
int zbar_image_scanner_set_config (zbar_image_scanner_t *iscn,
                                   zbar_symbol_type_t sym,
                                   zbar_config_t cfg,
                                   int val)
{
    if((sym == 0 || sym == ZBAR_COMPOSITE) && cfg == ZBAR_CFG_ENABLE) {
        iscn->ean_config = !!val;
        if(sym)
            return(0);
    }

    if(cfg < ZBAR_CFG_UNCERTAINTY)
        return(zbar_decoder_set_config(iscn->dcode, sym, cfg, val));

    if(cfg < ZBAR_CFG_POSITION) {
        int c, i;
        if(cfg > ZBAR_CFG_UNCERTAINTY)
            return(1);
        c = cfg - ZBAR_CFG_UNCERTAINTY;
        if(sym > ZBAR_PARTIAL) {
            i = _zbar_get_symbol_hash(sym);
            iscn->sym_configs[c][i] = val;
        }
        else
            for(i = 0; i < NUM_SYMS; i++)
                iscn->sym_configs[c][i] = val;
        return(0);
    }

    if(sym > ZBAR_PARTIAL)
        return(1);

    if(cfg >= ZBAR_CFG_X_DENSITY && cfg <= ZBAR_CFG_Y_DENSITY) {
        CFG(iscn, cfg) = val;
        return(0);
    }

    if(cfg > ZBAR_CFG_POSITION)
        return(1);
    cfg -= ZBAR_CFG_POSITION;

    if(!val)
        iscn->config &= ~(1 << cfg);
    else if(val == 1)
        iscn->config |= (1 << cfg);
    else
        return(1);

    return(0);
}
예제 #4
0
int zbar_image_scanner_set_config (zbar_image_scanner_t *iscn,
                                   zbar_symbol_type_t sym,
                                   zbar_config_t cfg,
                                   int val)
{
    if(cfg >= ZBAR_CFG_X_DENSITY && cfg <= ZBAR_CFG_Y_DENSITY) {
        if(sym > ZBAR_PARTIAL)
            return(1);

        CFG(iscn, cfg) = val;
        return(0);
    }
    return(zbar_decoder_set_config(iscn->dcode, sym, cfg, val));
}
예제 #5
0
static PyObject*
decoder_set_config (zbarDecoder *self,
                    PyObject *args,
                    PyObject *kwds)
{
    zbar_symbol_type_t sym = ZBAR_NONE;
    zbar_config_t cfg = ZBAR_CFG_ENABLE;
    int val = 1;
    static char *kwlist[] = { "symbology", "config", "value", NULL };
    if(!PyArg_ParseTupleAndKeywords(args, kwds, "|iii", kwlist,
                                    &sym, &cfg, &val))
        return(NULL);

    if(zbar_decoder_set_config(self->zdcode, sym, cfg, val)) {
        PyErr_SetString(PyExc_ValueError, "invalid configuration setting");
        return(NULL);
    }
    Py_RETURN_NONE;
}
예제 #6
0
파일: decoder.c 프로젝트: foaf/foaftown
int zbar_decoder_set_config (zbar_decoder_t *dcode,
                             zbar_symbol_type_t sym,
                             zbar_config_t cfg,
                             int val)
{
    if(sym == ZBAR_NONE) {
        zbar_decoder_set_config(dcode, ZBAR_EAN13, cfg, val);
        zbar_decoder_set_config(dcode, ZBAR_EAN8, cfg, val);
        zbar_decoder_set_config(dcode, ZBAR_UPCA, cfg, val);
        zbar_decoder_set_config(dcode, ZBAR_UPCE, cfg, val);
        zbar_decoder_set_config(dcode, ZBAR_ISBN10, cfg, val);
        zbar_decoder_set_config(dcode, ZBAR_ISBN13, cfg, val);
        zbar_decoder_set_config(dcode, ZBAR_I25, cfg, val);
        zbar_decoder_set_config(dcode, ZBAR_CODE39, cfg, val);
        zbar_decoder_set_config(dcode, ZBAR_CODE128, cfg, val);
        zbar_decoder_set_config(dcode, ZBAR_PDF417, cfg, val);
        zbar_decoder_set_config(dcode, ZBAR_QRCODE, cfg, val);
        return(0);
    }

    if(cfg >= 0 && cfg < ZBAR_CFG_NUM)
        return(decoder_set_config_bool(dcode, sym, cfg, val));
    else if(cfg >= ZBAR_CFG_MIN_LEN && cfg <= ZBAR_CFG_MAX_LEN)
        return(decoder_set_config_int(dcode, sym, cfg, val));
    else
        return(1);
}