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);
}
}
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;
}
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);
}
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");
}
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);
}
Aggregations