Java Code Examples for com.google.zxing.MultiFormatReader#setHints()

The following examples show how to use com.google.zxing.MultiFormatReader#setHints() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BitmapDecoder.java    From BarcodeScanner with Apache License 2.0 6 votes vote down vote up
public BitmapDecoder(Context context) {

		multiFormatReader = new MultiFormatReader();

		// 解码的参数
		Hashtable<DecodeHintType, Object> hints = new Hashtable<DecodeHintType, Object>(
				2);
		// 可以解析的编码类型
		Vector<BarcodeFormat> decodeFormats = new Vector<BarcodeFormat>();
		if (decodeFormats == null || decodeFormats.isEmpty()) {
			decodeFormats = new Vector<BarcodeFormat>();

			// 这里设置可扫描的类型,我这里选择了都支持
			decodeFormats.addAll(DecodeFormatManager.ONE_D_FORMATS);
			decodeFormats.addAll(DecodeFormatManager.QR_CODE_FORMATS);
			decodeFormats.addAll(DecodeFormatManager.DATA_MATRIX_FORMATS);
		}
		hints.put(DecodeHintType.POSSIBLE_FORMATS, decodeFormats);

		// 设置继续的字符编码格式为UTF8
		hints.put(DecodeHintType.CHARACTER_SET, "UTF8");

		// 设置解析配置参数
		multiFormatReader.setHints(hints);

	}
 
Example 2
Source File: DecodeUtils.java    From SimplifyReader with Apache License 2.0 6 votes vote down vote up
public String decodeWithZxing(Bitmap bitmap) {
    MultiFormatReader multiFormatReader = new MultiFormatReader();
    multiFormatReader.setHints(changeZXingDecodeDataMode());

    int width = bitmap.getWidth();
    int height = bitmap.getHeight();
    int[] pixels = new int[width * height];
    bitmap.getPixels(pixels, 0, width, 0, 0, width, height);

    Result rawResult = null;
    RGBLuminanceSource source = new RGBLuminanceSource(width, height, pixels);

    if (source != null) {
        BinaryBitmap binaryBitmap = new BinaryBitmap(new HybridBinarizer(source));
        try {
            rawResult = multiFormatReader.decodeWithState(binaryBitmap);
        } catch (ReaderException re) {
            // continue
        } finally {
            multiFormatReader.reset();
        }
    }

    return rawResult != null ? rawResult.getText() : null;
}
 
Example 3
Source File: CodeUtils.java    From UVCCameraZxing with Apache License 2.0 5 votes vote down vote up
public static void analyzeBitmap(Bitmap bitmap, AnalyzeCallback analyzeCallback) {
    MultiFormatReader multiFormatReader = new MultiFormatReader();

    // 解码的参数
    Hashtable<DecodeHintType, Object> hints = new Hashtable<>(2);
    // 可以解析的编码类型
    Vector<BarcodeFormat> decodeFormats = new Vector<>();
    // 这里设置可扫描的类型,我这里选择了都支持
    decodeFormats.addAll(DecodeFormatManager.ONE_D_FORMATS);
    decodeFormats.addAll(DecodeFormatManager.QR_CODE_FORMATS);
    decodeFormats.addAll(DecodeFormatManager.DATA_MATRIX_FORMATS);

    hints.put(DecodeHintType.POSSIBLE_FORMATS, decodeFormats);
    // 设置继续的字符编码格式为UTF8
    // hints.put(DecodeHintType.CHARACTER_SET, "UTF8");
    // 设置解析配置参数
    multiFormatReader.setHints(hints);

    // 开始对图像资源解码
    Result rawResult = null;
    try {
        rawResult = multiFormatReader.decodeWithState(
                new BinaryBitmap(new HybridBinarizer(new BitmapLuminanceSource(bitmap))));
    } catch (Exception e) {
        e.printStackTrace();
    }

    if (rawResult != null) {
        if (analyzeCallback != null) {
            analyzeCallback.onAnalyzeSuccess(bitmap, rawResult.getText());
        }
    } else {
        if (analyzeCallback != null) {
            analyzeCallback.onAnalyzeFailed();
        }
    }
}
 
Example 4
Source File: Decoder.java    From code-scanner with MIT License 5 votes vote down vote up
public Decoder(@NonNull final StateListener stateListener,
        @NonNull final List<BarcodeFormat> formats, @Nullable final DecodeCallback callback) {
    mReader = new MultiFormatReader();
    mDecoderThread = new DecoderThread();
    mHints = new EnumMap<>(DecodeHintType.class);
    mHints.put(DecodeHintType.POSSIBLE_FORMATS, formats);
    mReader.setHints(mHints);
    mCallback = callback;
    mStateListener = stateListener;
    mState = State.INITIALIZED;
}
 
Example 5
Source File: BarcodeUtils.java    From code-scanner with MIT License 5 votes vote down vote up
@NonNull
private static MultiFormatReader createReader(@Nullable final Map<DecodeHintType, ?> hints) {
    final MultiFormatReader reader = new MultiFormatReader();
    if (hints != null) {
        reader.setHints(hints);
    } else {
        reader.setHints(Collections
                .singletonMap(DecodeHintType.POSSIBLE_FORMATS, CodeScanner.ALL_FORMATS));
    }
    return reader;
}
 
Example 6
Source File: DecodeHandler.java    From ZXingProject with MIT License 4 votes vote down vote up
public DecodeHandler(CaptureActivity activity, Map<DecodeHintType, Object> hints) {
	multiFormatReader = new MultiFormatReader();
	multiFormatReader.setHints(hints);
	this.activity = activity;
}
 
Example 7
Source File: DecodeHandler.java    From barcodescanner-lib-aar with MIT License 4 votes vote down vote up
DecodeHandler(CaptureActivity activity, Map<DecodeHintType,Object> hints) {
  multiFormatReader = new MultiFormatReader();
  multiFormatReader.setHints(hints);
  this.activity = activity;
}
 
Example 8
Source File: DecodeHandler.java    From myapplication with Apache License 2.0 4 votes vote down vote up
public DecodeHandler(CaptureActivity activity, Map<DecodeHintType, Object> hints) {
    multiFormatReader = new MultiFormatReader();
    multiFormatReader.setHints(hints);
    this.activity = activity;
}
 
Example 9
Source File: DecodeHandler.java    From AndroidWebServ with Apache License 2.0 4 votes vote down vote up
DecodeHandler(CaptureActivity activity, Map<DecodeHintType, Object> hints) {
    multiFormatReader = new MultiFormatReader();
    multiFormatReader.setHints(hints);
    this.activity = activity;
}
 
Example 10
Source File: DecodeHandler.java    From ProjectX with Apache License 2.0 4 votes vote down vote up
DecodeHandler(CameraManager cameraManager, Handler mHandler, Map<DecodeHintType, Object> hints) {
    multiFormatReader = new MultiFormatReader();
    multiFormatReader.setHints(hints);
    this.cameraManager = cameraManager;
    this.mHandler = mHandler;
}
 
Example 11
Source File: DecodeHandler.java    From GOpenSource_AppKit_Android_AS with MIT License 4 votes vote down vote up
public DecodeHandler(CaptureActivity activity, Map<DecodeHintType, Object> hints) {
	multiFormatReader = new MultiFormatReader();
	multiFormatReader.setHints(hints);
	this.activity = activity;
}
 
Example 12
Source File: DecodeHandler.java    From CodeScaner with MIT License 4 votes vote down vote up
DecodeHandler(CaptureActivity activity, Map<DecodeHintType,Object> hints) {
  multiFormatReader = new MultiFormatReader();
  multiFormatReader.setHints(hints);
  this.activity = activity;
}
 
Example 13
Source File: DecodeHandler.java    From QrCodeLib with MIT License 4 votes vote down vote up
DecodeHandler(CaptureActivity activity, Hashtable<DecodeHintType, Object> hints) {
    multiFormatReader = new MultiFormatReader();
    multiFormatReader.setHints(hints);
    this.activity = activity;
}
 
Example 14
Source File: DecodeHandler.java    From BarcodeEye with Apache License 2.0 4 votes vote down vote up
DecodeHandler(CaptureActivity activity, Map<DecodeHintType,Object> hints) {
  multiFormatReader = new MultiFormatReader();
  multiFormatReader.setHints(hints);
  this.activity = activity;
}
 
Example 15
Source File: DecodeHandler.java    From weex with Apache License 2.0 4 votes vote down vote up
DecodeHandler(CaptureActivity activity, Map<DecodeHintType,Object> hints) {
  multiFormatReader = new MultiFormatReader();
  multiFormatReader.setHints(hints);
  this.activity = activity;
}
 
Example 16
Source File: DecodeHandler.java    From QrCodeDemo4 with MIT License 4 votes vote down vote up
DecodeHandler(CaptureActivity activity, Hashtable<DecodeHintType, Object> hints) {
  multiFormatReader = new MultiFormatReader();
  multiFormatReader.setHints(hints);
  this.activity = activity;
}
 
Example 17
Source File: DecodeCore.java    From qrcode_android with GNU Lesser General Public License v3.0 4 votes vote down vote up
public DecodeCore(Map<DecodeHintType, Object> hints) {
    multiFormatReader = new MultiFormatReader();
    multiFormatReader.setHints(hints);
}
 
Example 18
Source File: DecodeHandler.java    From Roid-Library with Apache License 2.0 4 votes vote down vote up
DecodeHandler(ZxingScanActivity activity, Hashtable<DecodeHintType, Object> hints) {
    multiFormatReader = new MultiFormatReader();
    multiFormatReader.setHints(hints);
    this.activity = activity;
}
 
Example 19
Source File: DecodeHandler.java    From AndroidWallet with GNU General Public License v3.0 4 votes vote down vote up
public DecodeHandler(CaptureActivity activity, Map<DecodeHintType, Object> hints) {
	multiFormatReader = new MultiFormatReader();
	multiFormatReader.setHints(hints);
	this.activity = activity;
}
 
Example 20
Source File: DecodeHandler.java    From vmqApk with MIT License 4 votes vote down vote up
DecodeHandler(CaptureActivity activity, Hashtable<DecodeHintType, Object> hints) {
  multiFormatReader = new MultiFormatReader();
  multiFormatReader.setHints(hints);
  this.activity = activity;
}