当前位置: 首页>>代码示例>>Java>>正文


Java MultiFormatReader.setHints方法代码示例

本文整理汇总了Java中com.google.zxing.MultiFormatReader.setHints方法的典型用法代码示例。如果您正苦于以下问题:Java MultiFormatReader.setHints方法的具体用法?Java MultiFormatReader.setHints怎么用?Java MultiFormatReader.setHints使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.zxing.MultiFormatReader的用法示例。


在下文中一共展示了MultiFormatReader.setHints方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: decodeWithZxing

import com.google.zxing.MultiFormatReader; //导入方法依赖的package包/类
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;
}
 
开发者ID:snice,项目名称:androidscan,代码行数:26,代码来源:DecodeUtils.java

示例2: analyzeBitmap

import com.google.zxing.MultiFormatReader; //导入方法依赖的package包/类
/**
 * 解析二维码图片工具类
 *
 * @param bitmap
 */
public static String analyzeBitmap(Bitmap bitmap) {
    MultiFormatReader 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);

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

    if (rawResult != null) {
        return rawResult.getText();
    } else {
        return "Failed";
    }
}
 
开发者ID:ymqq,项目名称:CommonFramework,代码行数:41,代码来源:ImageUtils.java

示例3: createDecoder

import com.google.zxing.MultiFormatReader; //导入方法依赖的package包/类
@Override
public Decoder createDecoder(Map<DecodeHintType, ?> baseHints) {
    Map<DecodeHintType, Object> hints = new EnumMap<>(DecodeHintType.class);

    hints.putAll(baseHints);

    if(this.hints != null) {
        hints.putAll(this.hints);
    }

    if(this.decodeFormats != null) {
        hints.put(DecodeHintType.POSSIBLE_FORMATS, decodeFormats);
    }

    if (characterSet != null) {
        hints.put(DecodeHintType.CHARACTER_SET, characterSet);
    }

    MultiFormatReader reader = new MultiFormatReader();
    reader.setHints(hints);

    return inverted ? new InvertedDecoder(reader) : new Decoder(reader);

}
 
开发者ID:yinhaojun,项目名称:ZxingForAndroid,代码行数:25,代码来源:DefaultDecoderFactory.java

示例4: doInBackground

import com.google.zxing.MultiFormatReader; //导入方法依赖的package包/类
@Override
protected Result doInBackground(Void... params) {
	BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(luminanceSource));
	Hashtable<DecodeHintType, Object> hints = new Hashtable<DecodeHintType, Object>(3);
	hints.put(DecodeHintType.CHARACTER_SET, "UTF-8");
	hints.put(DecodeHintType.NEED_RESULT_POINT_CALLBACK, listener);
	MultiFormatReader multiFormatReader = new MultiFormatReader();
	multiFormatReader.setHints(hints);
	long start = System.currentTimeMillis();
	Result rawResult = null;
	try {
		rawResult = multiFormatReader.decodeWithState(bitmap);
		mBitmap = luminanceSource.renderCroppedGreyScaleBitmap();
		long end = System.currentTimeMillis();
		Log.d("DecodeThread", "Decode use " + (end - start) + "ms");
	} catch (ReaderException re) {
	} finally {
		multiFormatReader.reset();
	}
	return rawResult;
}
 
开发者ID:Revival-liangjialiang,项目名称:ShoppingApp,代码行数:22,代码来源:DecodeThread.java

示例5: createDecoder

import com.google.zxing.MultiFormatReader; //导入方法依赖的package包/类
@Override
public Decoder createDecoder(Map<DecodeHintType, ?> baseHints) {
    Map<DecodeHintType, Object> hints = new EnumMap<DecodeHintType, Object>(DecodeHintType.class);

    hints.putAll(baseHints);

    if(this.hints != null) {
        hints.putAll(this.hints);
    }

    if(this.decodeFormats != null) {
        hints.put(DecodeHintType.POSSIBLE_FORMATS, decodeFormats);
    }

    if (characterSet != null) {
        hints.put(DecodeHintType.CHARACTER_SET, characterSet);
    }

    MultiFormatReader reader = new MultiFormatReader();
    reader.setHints(hints);

    return new Decoder(reader);
}
 
开发者ID:OpenIchano,项目名称:Viewer,代码行数:24,代码来源:DefaultDecoderFactory.java

示例6: BitmapDecoder

import com.google.zxing.MultiFormatReader; //导入方法依赖的package包/类
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);

	}
 
开发者ID:oneapp1e,项目名称:BarcodeScanner,代码行数:27,代码来源:BitmapDecoder.java

示例7: analyzeBitmap

import com.google.zxing.MultiFormatReader; //导入方法依赖的package包/类
/**
 * 解析二维码图片工具类
 */
public static void analyzeBitmap(String path, AnalyzeCallback analyzeCallback) {

    /**
     * 首先判断图片的大小,若图片过大,则执行图片的裁剪操作,防止OOM
     */
    BitmapFactory.Options options = new BitmapFactory.Options();
    options.inJustDecodeBounds = true; // 先获取原大小
    Bitmap mBitmap = BitmapFactory.decodeFile(path, options);
    options.inJustDecodeBounds = false; // 获取新的大小

    int sampleSize = (int) (options.outHeight / (float) 400);

    if (sampleSize <= 0)
        sampleSize = 1;
    options.inSampleSize = sampleSize;
    mBitmap = BitmapFactory.decodeFile(path, options);

    MultiFormatReader 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);

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

    if (rawResult != null) {
        if (analyzeCallback != null) {
            analyzeCallback.onAnalyzeSuccess(mBitmap, rawResult.getText());
        }
    } else {
        if (analyzeCallback != null) {
            analyzeCallback.onAnalyzeFailed();
        }
    }
}
 
开发者ID:beanu,项目名称:smart-farmer-android,代码行数:59,代码来源:ZxingUtil.java

示例8: initializeFromIntent

import com.google.zxing.MultiFormatReader; //导入方法依赖的package包/类
/**
 * Convenience method to initialize camera id, decode formats and prompt message from an intent.
 *
 * @param intent the intent, as generated by IntentIntegrator
 */
public void initializeFromIntent(Intent intent) {
    // Scan the formats the intent requested, and return the result to the calling activity.
    Set<BarcodeFormat> decodeFormats = DecodeFormatManager.parseDecodeFormats(intent);
    Map<DecodeHintType, Object> decodeHints = DecodeHintManager.parseDecodeHints(intent);

    CameraSettings settings = new CameraSettings();

    if (intent.hasExtra(Intents.Scan.CAMERA_ID)) {
        int cameraId = intent.getIntExtra(Intents.Scan.CAMERA_ID, -1);
        if (cameraId >= 0) {
            settings.setRequestedCameraId(cameraId);
        }
    }

    String customPromptMessage = intent.getStringExtra(Intents.Scan.PROMPT_MESSAGE);
    if (customPromptMessage != null) {
        setStatusText(customPromptMessage);
    }

    String characterSet = intent.getStringExtra(Intents.Scan.CHARACTER_SET);

    MultiFormatReader reader = new MultiFormatReader();
    reader.setHints(decodeHints);

    barcodeView.setCameraSettings(settings);
    barcodeView.setDecoderFactory(new DefaultDecoderFactory(decodeFormats, decodeHints, characterSet));
}
 
开发者ID:OpenIchano,项目名称:Viewer,代码行数:33,代码来源:CompoundBarcodeView.java

示例9: QRCodeDecode

import com.google.zxing.MultiFormatReader; //导入方法依赖的package包/类
private QRCodeDecode(Builder builder) {
    mMultiFormatReader = new MultiFormatReader();
    Map<DecodeHintType, Object> hints = new EnumMap<>(DecodeHintType.class);
    Collection<BarcodeFormat> formats = new ArrayList<>();
    formats.add(BarcodeFormat.QR_CODE);
    hints.put(DecodeHintType.POSSIBLE_FORMATS, formats);
    hints.put(DecodeHintType.CHARACTER_SET, builder.mCharset);
    mMultiFormatReader.setHints(hints);
}
 
开发者ID:hnlbxb2004,项目名称:ZxingSupport,代码行数:10,代码来源:QRCodeDecode.java

示例10: ScanDialog

import com.google.zxing.MultiFormatReader; //导入方法依赖的package包/类
/**
 * Create the dialog
 *
 * @param       parent          Parent frame
 * @param       webcam          Web camera
 */
public ScanDialog(JDialog parent, Webcam webcam) {
    super(parent, "Scan QR Code", Dialog.ModalityType.DOCUMENT_MODAL);
    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    //
    // Create the webcam panel (this will display the webcam stream to the user)
    //
    this.webcam = webcam;
    webcam.setViewSize(WebcamResolution.VGA.getSize());
    webcamPanel = new WebcamPanel(webcam);
    webcamPanel.setMirrored(true);
    //
    // Create the buttons (Cancel)
    //
    JPanel buttonPane = new ButtonPane(this, 10, new String[] {"Cancel", "cancel"});
    //
    // Set up the content pane
    //
    JPanel contentPane = new JPanel();
    contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS));
    contentPane.setOpaque(true);
    contentPane.setBorder(BorderFactory.createEmptyBorder(15, 15, 15, 15));
    contentPane.add(webcamPanel);
    contentPane.add(Box.createVerticalStrut(15));
    contentPane.add(buttonPane);
    setContentPane(contentPane);
    //
    // Set up the barcode reader to look for just QR codes
    //
    barcodeReader = new MultiFormatReader();
    Map<DecodeHintType, Object> hints = new HashMap<>();
    List<BarcodeFormat> formats = new ArrayList<>();
    formats.add(BarcodeFormat.QR_CODE);
    hints.put(DecodeHintType.POSSIBLE_FORMATS, formats);
    barcodeReader.setHints(hints);
    //
    // Listen for webcam events (we will scan webcam images looking for a QR code)
    //
    webcam.addWebcamListener(this);
}
 
开发者ID:ScripterRon,项目名称:BitcoinWallet,代码行数:46,代码来源:ScanDialog.java

示例11: DecodeHandler

import com.google.zxing.MultiFormatReader; //导入方法依赖的package包/类
DecodeHandler(CaptureActivity activity, Map<DecodeHintType,?> hints) {
  this.activity = activity;
  this.hints = hints;
  running = true;
  multiFormatReader = new MultiFormatReader();
  multiFormatReader.setHints(hints);
  enableEnhanced = true;
  enhancedDecodeExecutor = Executors.newSingleThreadExecutor();
  isEnhancedRunning = new AtomicBoolean(false);
  allowedContentPattern = parseAllowedContentPattern(activity);
}
 
开发者ID:srowen,项目名称:zxing-bsplus,代码行数:12,代码来源:DecodeHandler.java

示例12: ZXDecoder

import com.google.zxing.MultiFormatReader; //导入方法依赖的package包/类
public ZXDecoder()
{
    reader = new MultiFormatReader();

    hints.put(DecodeHintType.POSSIBLE_FORMATS, EnumSet.allOf(BarcodeFormat.class));
    hints.put(DecodeHintType.CHARACTER_SET, "utf-8");
    hints.put(DecodeHintType.TRY_HARDER, true);

    reader.setHints(hints);
}
 
开发者ID:LivotovLabs,项目名称:CamView,代码行数:11,代码来源:ZXDecoder.java

示例13: DecodeHandler

import com.google.zxing.MultiFormatReader; //导入方法依赖的package包/类
DecodeHandler(CaptureActivity activity, Hashtable<DecodeHintType, Object> hints) {
	multiFormatReader = new MultiFormatReader();
	multiFormatReader.setHints(hints);
	this.activity = activity;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:6,代码来源:DecodeHandler.java

示例14: DecodeHandler

import com.google.zxing.MultiFormatReader; //导入方法依赖的package包/类
public DecodeHandler(CaptureActivity activity, Map<DecodeHintType, Object> hints) {
	multiFormatReader = new MultiFormatReader();
	multiFormatReader.setHints(hints);
	this.activity = activity;
}
 
开发者ID:TonnyL,项目名称:Espresso,代码行数:6,代码来源:DecodeHandler.java

示例15: DecodeHandler

import com.google.zxing.MultiFormatReader; //导入方法依赖的package包/类
DecodeHandler(IDecodeCallback mDecodeCallback, Map<DecodeHintType, Object> hints) {
    multiFormatReader = new MultiFormatReader();
    multiFormatReader.setHints(hints);
    this.mDecodeCallback = mDecodeCallback;
}
 
开发者ID:angcyo,项目名称:RLibrary,代码行数:6,代码来源:DecodeHandler.java


注:本文中的com.google.zxing.MultiFormatReader.setHints方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。