Search in sources :

Example 26 with Size

use of android.hardware.Camera.Size in project android_packages_apps_Camera by CyanogenMod.

the class VideoModule method onSharedPreferenceChanged.

@Override
public void onSharedPreferenceChanged() {
    // ignore the events after "onPause()" or preview has not started yet
    if (mPaused)
        return;
    synchronized (mPreferences) {
        // startPreview().
        if (mActivity.mCameraDevice == null)
            return;
        boolean recordLocation = RecordLocationPreference.get(mPreferences, mContentResolver);
        mLocationManager.recordLocation(recordLocation);
        // Check if the current effects selection has changed
        if (updateEffectSelection())
            return;
        if (mActivity.setStoragePath(mPreferences)) {
            mActivity.updateStorageSpaceAndHint();
            mActivity.reuseCameraScreenNail(!mIsVideoCaptureIntent);
        }
        readVideoPreferences();
        showTimeLapseUI(mCaptureTimeLapse);
        // We need to restart the preview if preview size is changed.
        Size size = mParameters.getPreviewSize();
        if (size.width != mDesiredPreviewWidth || size.height != mDesiredPreviewHeight || mProfile.videoFrameWidth != mVideoWidth || mProfile.videoFrameHeight != mVideoHeight) {
            if (!effectsActive()) {
                stopPreview();
            } else {
                mEffectsRecorder.release();
                mEffectsRecorder = null;
            }
            resizeForPreviewAspectRatio();
            // Parameters will be set in startPreview().
            startPreview();
        } else {
            setCameraParameters();
        }
        updateOnScreenIndicators();
        mActivity.initPowerShutter(mPreferences);
    }
}
Also used : Size(android.hardware.Camera.Size)

Example 27 with Size

use of android.hardware.Camera.Size in project android_packages_apps_Camera by CyanogenMod.

the class Util method getOptimalVideoSnapshotPictureSize.

// Returns the largest picture size which matches the given aspect ratio.
public static Size getOptimalVideoSnapshotPictureSize(List<Size> sizes, double targetRatio) {
    // Use a very small tolerance because we want an exact match.
    final double ASPECT_TOLERANCE = 0.001;
    if (sizes == null)
        return null;
    Size optimalSize = null;
    // Try to find a size matches aspect ratio and has the largest width
    for (Size size : sizes) {
        double ratio = (double) size.width / size.height;
        if (Math.abs(ratio - targetRatio) > ASPECT_TOLERANCE)
            continue;
        if (optimalSize == null || size.width > optimalSize.width) {
            optimalSize = size;
        }
    }
    // Ignore the requirement.
    if (optimalSize == null) {
        Log.w(TAG, "No picture size match the aspect ratio");
        for (Size size : sizes) {
            if (optimalSize == null || size.width > optimalSize.width) {
                optimalSize = size;
            }
        }
    }
    return optimalSize;
}
Also used : Size(android.hardware.Camera.Size)

Example 28 with Size

use of android.hardware.Camera.Size in project MagicCamera by wuhaoyu1990.

the class CameraEngine method setDefaultParameters.

private static void setDefaultParameters() {
    Parameters parameters = mCamera.getParameters();
    if (parameters.getSupportedFocusModes().contains(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE)) {
        parameters.setFocusMode(Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);
    }
    Size previewSize = getLargePreviewSize();
    parameters.setPreviewSize(1280, 720);
    Size pictureSize = getLargePictureSize();
    parameters.setPictureSize(pictureSize.width, pictureSize.height);
    mCamera.setParameters(parameters);
}
Also used : Parameters(android.hardware.Camera.Parameters) Size(android.hardware.Camera.Size)

Example 29 with Size

use of android.hardware.Camera.Size in project android_packages_apps_Camera by CyanogenMod.

the class CameraSettings method initialCameraPictureSize.

public static void initialCameraPictureSize(Context context, Parameters parameters) {
    // When launching the camera app first time, we will set the picture
    // size to the first one in the list defined in "arrays.xml" and is also
    // supported by the driver.
    List<Size> supported = parameters.getSupportedPictureSizes();
    if (supported == null)
        return;
    for (String candidate : context.getResources().getStringArray(R.array.pref_camera_picturesize_entryvalues)) {
        if (setCameraPictureSize(candidate, supported, parameters)) {
            SharedPreferences.Editor editor = ComboPreferences.get(context).edit();
            editor.putString(KEY_PICTURE_SIZE, candidate);
            editor.apply();
            return;
        }
    }
    Log.e(TAG, "No supported picture size found");
}
Also used : SharedPreferences(android.content.SharedPreferences) Size(android.hardware.Camera.Size) Editor(android.content.SharedPreferences.Editor)

Example 30 with Size

use of android.hardware.Camera.Size in project JustAndroid by chinaltz.

the class CameraConfigurationManager method setDesiredCameraParameters.

/**
	 * 设置相机参数
	 * 
	 * @param camera
	 */
void setDesiredCameraParameters(Camera camera, int cameraID) {
    Parameters parameters = camera.getParameters();
    parameters.setPreviewSize(cameraResolution.x, cameraResolution.y);
    parameters.setPictureSize(pictureResolution.x, pictureResolution.y);
    Size size = parameters.getPreviewSize();
    Log.e(TAG, "camera default previewSize: " + size.width + "," + size.height);
    Size size1 = parameters.getPictureSize();
    Log.e(TAG, "camera default pictureSize: " + size1.width + "," + size1.height);
    parameters.setPictureFormat(ImageFormat.JPEG);
    //parameters.setJpegQuality(85);
    parameters.setPreviewFormat(ImageFormat.NV21);
    Log.e(TAG, "camera setPreviewSize: " + cameraResolution.x + "," + cameraResolution.y);
    if (cameraID == 0) {
        //对焦模式
        if (Config.focusMode == 0) {
            parameters.setFocusMode(Parameters.FLASH_MODE_AUTO);
        } else {
            parameters.setFocusMode(Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);
        }
    }
    parameters.setZoom(0);
    setFlash(camera, false);
    //setZoom(parameters);
    camera.setParameters(parameters);
}
Also used : Parameters(android.hardware.Camera.Parameters) Size(android.hardware.Camera.Size)

Aggregations

Size (android.hardware.Camera.Size)30 Parameters (android.hardware.Camera.Parameters)4 Point (android.graphics.Point)3 Camera (android.hardware.Camera)3 Uri (android.net.Uri)2 IOException (java.io.IOException)2 TargetApi (android.annotation.TargetApi)1 SharedPreferences (android.content.SharedPreferences)1 Editor (android.content.SharedPreferences.Editor)1 SurfaceTexture (android.graphics.SurfaceTexture)1 Location (android.location.Location)1 Bundle (android.os.Bundle)1 Handler (android.os.Handler)1 Message (android.os.Message)1 Nullable (android.support.annotation.Nullable)1 BinaryBitmap (com.google.zxing.BinaryBitmap)1 PlanarYUVLuminanceSource (com.google.zxing.PlanarYUVLuminanceSource)1 ReaderException (com.google.zxing.ReaderException)1 Result (com.google.zxing.Result)1 HybridBinarizer (com.google.zxing.common.HybridBinarizer)1