CaptureHandler.java 文件源码

java
阅读 29 收藏 0 点赞 0 评论 0

项目:QrCode 作者:
@Override
public void handleMessage(Message message) {
    switch (message.what) {
        case AUTO_FOCUS:
            if (state == State.PREVIEW) {
                cameraManager.requestAutoFocus(this, AUTO_FOCUS);
            }
            break;
        case RESTART_PREVIEW:
            restartPreviewAndDecode();
            break;
        case DECODE_SUCCEEDED:
            state = State.SUCCESS;
            Bundle bundle = message.getData();
            Bitmap barcode = null;
            float scaleFactor = 1.0f;
            if (bundle != null) {
                byte[] compressedBitmap = bundle.getByteArray(DecodeThread.BARCODE_BITMAP);
                if (compressedBitmap != null) {
                    barcode = BitmapFactory.decodeByteArray(compressedBitmap, 0, compressedBitmap.length, null);
                    // Mutable copy:
                    barcode = barcode.copy(Bitmap.Config.ARGB_8888, true);
                }
                scaleFactor = bundle.getFloat(DecodeThread.BARCODE_SCALED_FACTOR);
            }
            mIScanCallback.handleDecode((Result) message.obj, barcode, scaleFactor);
            break;
        case DECODE_FAILED:
            // We're decoding as fast as possible, so when one decode fails, start another.
            state = State.PREVIEW;
            cameraManager.requestPreviewFrame(decodeThread.getHandler(), DECODE);
            break;
        case RETURN_SCAN_RESULT:
            break;
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号