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


Java CameraUtil类代码示例

本文整理汇总了Java中com.android.camera.util.CameraUtil的典型用法代码示例。如果您正苦于以下问题:Java CameraUtil类的具体用法?Java CameraUtil怎么用?Java CameraUtil使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: checkDisplayRotation

import com.android.camera.util.CameraUtil; //导入依赖的package包/类
private void checkDisplayRotation() {
    // Need to just be a no-op for the quick resume-pause scenario.
    if (mPaused) {
        return;
    }
    // Set the display orientation if display rotation has changed.
    // Sometimes this happens when the device is held upside
    // down and camera app is opened. Rotation animation will
    // take some time and the rotation value we have got may be
    // wrong. Framework does not have a callback for this now.
    if (CameraUtil.getDisplayRotation(mActivity) != mDisplayRotation) {
        setDisplayOrientation();
    }
    if (SystemClock.uptimeMillis() - mOnResumeTime < 5000) {
        mHandler.postDelayed(new Runnable() {
            @Override
            public void run() {
                checkDisplayRotation();
            }
        }, 100);
    }
}
 
开发者ID:jameliu,项目名称:Camera2,代码行数:23,代码来源:PhotoModule.java

示例2: setDisplayOrientation

import com.android.camera.util.CameraUtil; //导入依赖的package包/类
private void setDisplayOrientation() {
    mDisplayRotation = CameraUtil.getDisplayRotation(mActivity);
    Characteristics info =
            mActivity.getCameraProvider().getCharacteristics(mCameraId);
    mDisplayOrientation = info.getPreviewOrientation(mDisplayRotation);
    mUI.setDisplayOrientation(mDisplayOrientation);
    if (mFocusManager != null) {
        mFocusManager.setDisplayOrientation(mDisplayOrientation);
    }
    // Change the camera display orientation
    if (mCameraDevice != null) {
        mCameraDevice.setDisplayOrientation(mDisplayRotation);
    }
    Log.v(TAG, "setDisplayOrientation (screen:preview) " +
            mDisplayRotation + ":" + mDisplayOrientation);
}
 
开发者ID:jameliu,项目名称:Camera2,代码行数:17,代码来源:PhotoModule.java

示例3: showModeCoverUntilPreviewReady

import com.android.camera.util.CameraUtil; //导入依赖的package包/类
/**
 * A cover view showing the mode theme color and mode icon will be visible on
 * top of preview until preview is ready (i.e. camera preview is started and
 * the first frame has been received).
 */
private void showModeCoverUntilPreviewReady() {
    int modeId = mController.getCurrentModuleIndex();
    int colorId = R.color.mode_cover_default_color;;
    int iconId = CameraUtil.getCameraModeCoverIconResId(modeId, mController.getAndroidContext());
    mModeTransitionView.setupModeCover(colorId, iconId);
    mHideCoverRunnable = new Runnable() {
        @Override
        public void run() {
            mModeTransitionView.hideModeCover(null);
            if (!mDisableAllUserInteractions) {
                showShimmyDelayed();
            }
        }
    };
    mModeCoverState = COVER_SHOWN;
}
 
开发者ID:jameliu,项目名称:Camera2,代码行数:22,代码来源:CameraAppUI.java

示例4: doInBackground

import com.android.camera.util.CameraUtil; //导入依赖的package包/类
@Override
protected Bitmap doInBackground(Void... params) {
    // Decode image in background.
    Bitmap bitmap = CameraUtil.downSample(mData, DOWN_SAMPLE_FACTOR);
    if (mOrientation != 0 || mMirror) {
        Matrix m = new Matrix();
        m.preRotate(mOrientation);
        if (mMirror) {
            // Flip horizontally
            m.setScale(-1f, 1f);
        }
        return Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), m,
                false);
    }
    return bitmap;
}
 
开发者ID:asm-products,项目名称:nexus-camera,代码行数:17,代码来源:PhotoUI.java

示例5: takeASnapshot

import com.android.camera.util.CameraUtil; //导入依赖的package包/类
private void takeASnapshot() {
    // Only take snapshots if video snapshot is supported by device
    if(!mCameraCapabilities.supports(CameraCapabilities.Feature.VIDEO_SNAPSHOT)) {
        Log.w(TAG, "Cannot take a video snapshot - not supported by hardware");
        return;
    }
    if (!mIsVideoCaptureIntent) {
        if (!mMediaRecorderRecording || mPaused || mSnapshotInProgress
                || !mAppController.isShutterEnabled() || mCameraDevice == null) {
            return;
        }

        Location loc = mLocationManager.getCurrentLocation();
        CameraUtil.setGpsParameters(mCameraSettings, loc);
        mCameraDevice.applySettings(mCameraSettings);

        Log.i(TAG, "Video snapshot start");
        mCameraDevice.takePicture(mHandler,
                null, null, null, new JpegPictureCallback(loc));
        showVideoSnapshotUI(true);
        mSnapshotInProgress = true;
    }
}
 
开发者ID:jameliu,项目名称:Camera2,代码行数:24,代码来源:VideoModule.java

示例6: updateFocusUI

import com.android.camera.util.CameraUtil; //导入依赖的package包/类
public void updateFocusUI() {
    if (!mInitialized) return;
    // Show only focus indicator or face indicator.

    if (mState == STATE_IDLE) {
        if (mFocusDefault) {
            mUI.clearFocus();
        } else {
            // Users touch on the preview and the indicator represents the
            // metering area. Either focus area is not supported or
            // autoFocus call is not required.
            mUI.onFocusStarted();
        }
    } else if (mState == STATE_FOCUSING || mState == STATE_FOCUSING_SNAP_ON_FINISH) {
        mUI.onFocusStarted();
    } else {
        if (CameraUtil.FOCUS_MODE_CONTINUOUS_PICTURE.equals(mFocusMode)) {
            // TODO: check HAL behavior and decide if this can be removed.
            mUI.onFocusSucceeded(false);
        } else if (mState == STATE_SUCCESS) {
            mUI.onFocusSucceeded(false);
        } else if (mState == STATE_FAIL) {
            mUI.onFocusFailed(false);
        }
    }
}
 
开发者ID:asm-products,项目名称:nexus-camera,代码行数:27,代码来源:FocusOverlayManager.java

示例7: onAttachedToWindow

import com.android.camera.util.CameraUtil; //导入依赖的package包/类
@Override
public void onAttachedToWindow() {
    // Before the first time this view is attached to window, device rotation
    // will not trigger onConfigurationChanged callback. So in the first run
    // we need to rotate the view if necessary. After that, onConfigurationChanged
    // call will track all the subsequent device rotation.
    if (mPrevRotation == UNKOWN_ORIENTATION) {
        mIsDefaultToPortrait = CameraUtil.isDefaultToPortrait((Activity) getContext());
        if (mIsDefaultToPortrait) {
            // Natural orientation for tablet is landscape
            mPrevRotation =  mInitialOrientation == Configuration.ORIENTATION_PORTRAIT ?
                    0 : 90;
        } else {
            // When tablet orientation is 0 or 270 (i.e. getUnifiedOrientation
            // = 0 or 90), we load the layout resource without any rotation.
            mPrevRotation =  mInitialOrientation == Configuration.ORIENTATION_LANDSCAPE ?
                    0 : 270;
        }

        // check if there is any rotation before the view is attached to window
        rotateIfNeeded();
    }
}
 
开发者ID:asm-products,项目名称:nexus-camera,代码行数:24,代码来源:RotatableLayout.java

示例8: openCamera

import com.android.camera.util.CameraUtil; //导入依赖的package包/类
/**
 * Opens the camera device. The back camera has priority over the front
 * one.
 *
 * @return Whether the camera was opened successfully.
 */
private boolean openCamera() {
    int cameraId = CameraHolder.instance().getBackCameraId();
    // If there is no back camera, use the first camera. Camera id starts
    // from 0. Currently if a camera is not back facing, it is front facing.
    // This is also forward compatible if we have a new facing other than
    // back or front in the future.
    if (cameraId == -1) cameraId = 0;
    mCameraDevice = CameraUtil.openCamera(mActivity, cameraId,
            mMainHandler, mActivity.getCameraOpenErrorCallback());
    if (mCameraDevice == null) {
        return false;
    }
    mCameraOrientation = CameraUtil.getCameraOrientation(cameraId);
    if (cameraId == CameraHolder.instance().getFrontCameraId()) mUsingFrontCamera = true;
    return true;
}
 
开发者ID:asm-products,项目名称:nexus-camera,代码行数:23,代码来源:WideAnglePanoramaModule.java

示例9: storeImage

import com.android.camera.util.CameraUtil; //导入依赖的package包/类
private void storeImage(final byte[] data, Location loc) {
    long dateTaken = System.currentTimeMillis();
    String title = CameraUtil.createJpegName(dateTaken);
    ExifInterface exif = Exif.getExif(data);
    int orientation = Exif.getOrientation(exif);

    String flashSetting = mActivity.getSettingsManager()
        .getString(mAppController.getCameraScope(), Keys.KEY_VIDEOCAMERA_FLASH_MODE);
    Boolean gridLinesOn = Keys.areGridLinesOn(mActivity.getSettingsManager());
    UsageStatistics.instance().photoCaptureDoneEvent(
            eventprotos.NavigationChange.Mode.VIDEO_STILL, title + ".jpeg", exif,
            isCameraFrontFacing(), false, currentZoomValue(), flashSetting, gridLinesOn,
            null, null, null);

    getServices().getMediaSaver().addImage(
            data, title, dateTaken, loc, orientation,
            exif, mOnPhotoSavedListener, mContentResolver);
}
 
开发者ID:jameliu,项目名称:Camera2,代码行数:19,代码来源:VideoModule.java

示例10: onLayoutChange

import com.android.camera.util.CameraUtil; //导入依赖的package包/类
@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft,
                           int oldTop, int oldRight, int oldBottom) {
    Log.v(TAG, "onLayoutChange");
    int width = right - left;
    int height = bottom - top;
    int rotation = CameraUtil.getDisplayRotation(mPreview.getContext());
    if (mWidth != width || mHeight != height || mOrientation != rotation) {
        mWidth = width;
        mHeight = height;
        mOrientation = rotation;
        if (!updateTransform()) {
            clearTransform();
        }
    }
    if (mOnLayoutChangeListener != null) {
        mOnLayoutChangeListener.onLayoutChange(v, left, top, right, bottom, oldLeft, oldTop,
                oldRight, oldBottom);
    }
}
 
开发者ID:jameliu,项目名称:Camera2,代码行数:21,代码来源:TextureViewHelper.java

示例11: setupShutterBackgroundForModeIndex

import com.android.camera.util.CameraUtil; //导入依赖的package包/类
private void setupShutterBackgroundForModeIndex(int index) {
    LayerDrawable shutterBackground = applyCircleDrawableToShutterBackground(
            newDrawableFromConstantState(mShutterButtonBackgroundConstantStates[index]));
    mShutterButton.setBackground(shutterBackground);
    mCancelButton.setBackground(applyCircleDrawableToShutterBackground(
            newDrawableFromConstantState(mShutterButtonBackgroundConstantStates[index])));

    Drawable d = shutterBackground.getDrawable(0);
    mAnimatedCircleDrawable = null;
    mColorDrawable = null;
    if (d instanceof AnimatedCircleDrawable) {
        mAnimatedCircleDrawable = (AnimatedCircleDrawable) d;
    } else if (d instanceof ColorDrawable) {
        mColorDrawable = (ColorDrawable) d;
    }

    int colorId = CameraUtil.getCameraThemeColorId(index, getContext());
    int pressedColor = getContext().getResources().getColor(colorId);
    setBackgroundPressedColor(pressedColor);
    refreshPaintColor();
}
 
开发者ID:jameliu,项目名称:Camera2,代码行数:22,代码来源:BottomBar.java

示例12: takePictureNow

import com.android.camera.util.CameraUtil; //导入依赖的package包/类
private void takePictureNow() {
    Location location = mLocationManager.getCurrentLocation();

    // Set up the capture session.
    long sessionTime = System.currentTimeMillis();
    String title = CameraUtil.createJpegName(sessionTime);
    CaptureSession session = getServices().getCaptureSessionManager()
            .createNewSession(title, sessionTime, location);

    // Set up the parameters for this capture.
    PhotoCaptureParameters params = new PhotoCaptureParameters();
    params.title = title;
    params.callback = this;
    params.orientation = getOrientation();
    params.flashMode = getFlashModeFromSettings();
    params.heading = mHeading;
    params.debugDataFolder = mDebugDataDir;
    params.location = location;
    params.zoom = mZoomValue;
    params.timerSeconds = mTimerDuration > 0 ? (float) mTimerDuration : null;

    mCamera.takePicture(params, session);
}
 
开发者ID:jameliu,项目名称:Camera2,代码行数:24,代码来源:CaptureModule.java

示例13: doInBackground

import com.android.camera.util.CameraUtil; //导入依赖的package包/类
@Override
protected Bitmap doInBackground(Void... params) {
    // Decode image in background.
    Bitmap bitmap = CameraUtil.downSample(mData, DOWN_SAMPLE_FACTOR);
    if (mOrientation != 0 || mMirror) {
        Matrix m = new Matrix();
        if (mMirror) {
            // Flip horizontally
            m.setScale(-1f, 1f);
        }
        m.preRotate(mOrientation);
        return Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), m,
                false);
    }
    return bitmap;
}
 
开发者ID:jameliu,项目名称:Camera2,代码行数:17,代码来源:PhotoUI.java

示例14: pickBufferDimensions

import com.android.camera.util.CameraUtil; //导入依赖的package包/类
/**
 * Selects the preview buffer dimensions that are closest in size to the
 * size of the view containing the preview.
 */
public static Size pickBufferDimensions(Size[] supportedPreviewSizes,
        double bestPreviewAspectRatio,
        Context context) {
    // Swap dimensions if the device is not in its natural orientation.
    boolean swapDimens = (CameraUtil.getDisplayRotation(context) % 180) == 90;
    // Swap dimensions if the device's natural orientation doesn't match
    // the sensor orientation.
    if (CaptureModuleUtil.getDeviceNaturalOrientation(context)
            == Configuration.ORIENTATION_PORTRAIT) {
        swapDimens = !swapDimens;
    }
    double bestAspect = bestPreviewAspectRatio;
    if (swapDimens) {
        bestAspect = 1 / bestAspect;
    }

    Size pick = CaptureModuleUtil.getOptimalPreviewSize(context, supportedPreviewSizes,
            bestPreviewAspectRatio);
    Log.d(TAG, "Picked buffer size: " + pick.toString());
    return pick;
}
 
开发者ID:jameliu,项目名称:Camera2,代码行数:26,代码来源:CaptureModuleUtil.java

示例15: prepareCamera

import com.android.camera.util.CameraUtil; //导入依赖的package包/类
/**
 * Opens the camera device.
 *
 * @return Whether the camera was opened successfully.
 */
private boolean prepareCamera() {
    // We need to check whether the activity is paused before long
    // operations to ensure that onPause() can be done ASAP.
    mCameraDevice = CameraUtil.openCamera(
            mActivity, mCameraId, mHandler,
            mActivity.getCameraOpenErrorCallback());
    if (mCameraDevice == null) {
        Log.e(TAG, "Failed to open camera:" + mCameraId);
        return false;
    }
    mParameters = mCameraDevice.getParameters();

    initializeCapabilities();
    if (mFocusManager == null) initializeFocusManager();
    setCameraParameters(UPDATE_PARAM_ALL);
    mHandler.sendEmptyMessage(CAMERA_OPEN_DONE);
    mCameraPreviewParamsReady = true;
    startPreview();
    mOnResumeTime = SystemClock.uptimeMillis();
    checkDisplayRotation();
    return true;
}
 
开发者ID:asm-products,项目名称:nexus-camera,代码行数:28,代码来源:PhotoModule.java


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