當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。