本文整理汇总了Java中android.hardware.Camera.Parameters.getSupportedPreviewSizes方法的典型用法代码示例。如果您正苦于以下问题:Java Parameters.getSupportedPreviewSizes方法的具体用法?Java Parameters.getSupportedPreviewSizes怎么用?Java Parameters.getSupportedPreviewSizes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.hardware.Camera.Parameters
的用法示例。
在下文中一共展示了Parameters.getSupportedPreviewSizes方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: configPreviewSize2
import android.hardware.Camera.Parameters; //导入方法依赖的package包/类
public BarcodeCameraConfig configPreviewSize2(int viewWidth, int viewHeight) {
Parameters params = camera.getParameters();
List<Size> sizes = params.getSupportedPreviewSizes();
if (sizes == null || sizes.size() <= 0) {
return this;
}
Size bestSize = null;
int diff = Integer.MAX_VALUE;
for (Size tmpSize : sizes) {
int newDiff = Math.abs(tmpSize.width - viewWidth) + Math.abs(tmpSize.height - viewHeight);
if (newDiff == 0) {
bestSize = tmpSize;
break;
} else if (newDiff < diff) {
bestSize = tmpSize;
diff = newDiff;
}
}
params.setPreviewSize(bestSize.width, bestSize.height);
camera.setParameters(params);
return this;
}
示例2: getSupportedVideoSizes
import android.hardware.Camera.Parameters; //导入方法依赖的package包/类
@TargetApi(VERSION_CODES.HONEYCOMB)
protected List<Size> getSupportedVideoSizes(int currentSdkInt) {
Parameters params = mNativeCamera.getNativeCameraParameters();
List<Size> supportedVideoSizes;
if (currentSdkInt < Build.VERSION_CODES.HONEYCOMB) {
CLog.e(CLog.CAMERA, "Using supportedPreviewSizes iso supportedVideoSizes due to API restriction");
supportedVideoSizes = params.getSupportedPreviewSizes();
} else if (params.getSupportedVideoSizes() == null) {
CLog.e(CLog.CAMERA, "Using supportedPreviewSizes because supportedVideoSizes is null");
supportedVideoSizes = params.getSupportedPreviewSizes();
} else {
supportedVideoSizes = params.getSupportedVideoSizes();
}
return supportedVideoSizes;
}
示例3: getPreferredPreviewSize
import android.hardware.Camera.Parameters; //导入方法依赖的package包/类
public static @Nullable Size getPreferredPreviewSize(int displayOrientation,
int width,
int height,
@NonNull Parameters parameters) {
final int targetWidth = displayOrientation % 180 == 90 ? height : width;
final int targetHeight = displayOrientation % 180 == 90 ? width : height;
final double targetRatio = (double) targetWidth / targetHeight;
Log.w(TAG, String.format("getPreferredPreviewSize(%d, %d, %d) -> target %dx%d, AR %.02f",
displayOrientation, width, height,
targetWidth, targetHeight, targetRatio));
List<Size> sizes = parameters.getSupportedPreviewSizes();
List<Size> ideals = new LinkedList<>();
List<Size> bigEnough = new LinkedList<>();
for (Size size : sizes) {
Log.w(TAG, String.format(" %dx%d (%.02f)", size.width, size.height, (float)size.width / size.height));
if (size.height == size.width * targetRatio && size.height >= targetHeight && size.width >= targetWidth) {
ideals.add(size);
Log.w(TAG, " (ideal ratio)");
} else if (size.width >= targetWidth && size.height >= targetHeight) {
bigEnough.add(size);
Log.w(TAG, " (good size, suboptimal ratio)");
}
}
if (!ideals.isEmpty()) return Collections.min(ideals, new AreaComparator());
else if (!bigEnough.isEmpty()) return Collections.min(bigEnough, new AspectRatioComparator(targetRatio));
else return Collections.max(sizes, new AreaComparator());
}
示例4: setCamera
import android.hardware.Camera.Parameters; //导入方法依赖的package包/类
public void setCamera(Camera camera) {
mCamera = camera;
if (mCamera != null) {
Parameters parameters = mCamera.getParameters();
mSupportedPreviewSizes = parameters.getSupportedPreviewSizes();
List<Integer> formatsList = parameters.getSupportedPreviewFormats(); //get supported preview formats
if(formatsList.contains(ImageFormat.NV21)) { // formatsList is always not null.
parameters.setPreviewFormat(ImageFormat.NV21); //set preview format is NV21,default is NV21 (yuv420sp)
}
// Set Focus mode depending on what is supported. MODE_AUTO is
// preferred mode.
// need not to test supported mode coz it has been tested in main activity.
if (msnFocusMode == 2) {
parameters.setFocusMode( Camera.Parameters.FOCUS_MODE_INFINITY );
} else if (msnFocusMode == 1) {
parameters.setFocusMode( Camera.Parameters.FOCUS_MODE_FIXED );
} else {
// set to auto focus by default
parameters.setFocusMode( Camera.Parameters.FOCUS_MODE_AUTO);
}
/*if ((parameters.getMaxExposureCompensation() != 0 || parameters.getMinExposureCompensation() != 0)
&& ActivitySettings.msnPhotoTakenFrom == 1) { // screen mode.
parameters.setExposureCompensation(parameters.getMaxExposureCompensation());
} */
parameters.setExposureCompensation(0); // exposure is not adjusted. Seems that screen mode does not bring much benefit.
List<String> scenesList = parameters.getSupportedSceneModes();
if (scenesList != null && scenesList.contains(Camera.Parameters.SCENE_MODE_STEADYPHOTO)) {
parameters.setSceneMode(Camera.Parameters.SCENE_MODE_STEADYPHOTO); // this may crash in some devices.
}
boolean bSuccessful = setCameraParams(mCamera, parameters);
requestLayout();
}
}
示例5: run
import android.hardware.Camera.Parameters; //导入方法依赖的package包/类
@Override
public void run() {
if (mCamera == null) {
return;
}
mCamera.stopPreview();
Parameters params = mCamera.getParameters();
zoomRatios = params.getZoomRatios();
zoomIndex = minZoomIndex = 0;
maxZoomIndex = params.getMaxZoom();
List<Camera.Size> sizes = params.getSupportedPreviewSizes();
List<Camera.Size> vSize = params.getSupportedVideoSizes();
Camera.Size size = CameraHelper.getOptimalPreviewSize(sizes, vSize);
if(size != null)
{
params.setPreviewSize(size.width, size.height);
mCamera.setParameters(params);
resolutionSize = size;
}else {
resolutionSize = null;
}
try {
mCamera.setPreviewDisplay(mHolder);
cameraDisplayOrientation = CameraHelper.getCameraDisplayOrientation(
(Activity)mContext, currentCamera);
mCamera.setDisplayOrientation(cameraDisplayOrientation);
mCamera.startPreview();
} catch (Exception e) {
e.printStackTrace();
}
}
示例6: setupCaptureParams
import android.hardware.Camera.Parameters; //导入方法依赖的package包/类
private void setupCaptureParams(Parameters parameters) {
List<Size> supportedSizes = parameters.getSupportedPreviewSizes();
if (!findBestPreviewSize(supportedSizes, true, true)) {
Log.w(TAG, "No 4:3 ratio preview size supported.");
if (!findBestPreviewSize(supportedSizes, false, true)) {
Log.w(TAG, "Can't find a supported preview size smaller than 960x720.");
findBestPreviewSize(supportedSizes, false, false);
}
}
Log.d(TAG, "camera preview h = "
+ mCameraPreviewHeight + " , w = " + mCameraPreviewWidth);
parameters.setPreviewSize(mCameraPreviewWidth, mCameraPreviewHeight);
List<int[]> frameRates = parameters.getSupportedPreviewFpsRange();
int last = frameRates.size() - 1;
int minFps = (frameRates.get(last))[Parameters.PREVIEW_FPS_MIN_INDEX];
int maxFps = (frameRates.get(last))[Parameters.PREVIEW_FPS_MAX_INDEX];
parameters.setPreviewFpsRange(minFps, maxFps);
Log.d(TAG, "preview fps: " + minFps + ", " + maxFps);
List<String> supportedFocusModes = parameters.getSupportedFocusModes();
if (supportedFocusModes.indexOf(mTargetFocusMode) >= 0) {
parameters.setFocusMode(mTargetFocusMode);
} else {
// Use the default focus mode and log a message
Log.w(TAG, "Cannot set the focus mode to " + mTargetFocusMode +
" becuase the mode is not supported.");
}
parameters.set(CameraUtil.RECORDING_HINT, CameraUtil.FALSE);
mHorizontalViewAngle = parameters.getHorizontalViewAngle();
mVerticalViewAngle = parameters.getVerticalViewAngle();
}
示例7: getResolutionList
import android.hardware.Camera.Parameters; //导入方法依赖的package包/类
public static List<Camera.Size> getResolutionList(Camera camera)
{
Parameters parameters = camera.getParameters();
List<Camera.Size> previewSizes = parameters.getSupportedPreviewSizes();
return previewSizes;
}
示例8: getResolutionList
import android.hardware.Camera.Parameters; //导入方法依赖的package包/类
public static List<Size> getResolutionList(Camera camera) {
Parameters parameters = camera.getParameters();
List<Size> previewSizes = parameters.getSupportedPreviewSizes();
return previewSizes;
}
示例9: getResolutionList
import android.hardware.Camera.Parameters; //导入方法依赖的package包/类
public static List<Camera.Size> getResolutionList(Camera camera)
{
Parameters parameters = camera.getParameters();
return parameters.getSupportedPreviewSizes();
}
示例10: getResolutionList
import android.hardware.Camera.Parameters; //导入方法依赖的package包/类
public static List<Size> getResolutionList(Camera camera) {
Parameters parameters = camera.getParameters();
return parameters.getSupportedPreviewSizes();
}
示例11: getResolutionList
import android.hardware.Camera.Parameters; //导入方法依赖的package包/类
public static List<Camera.Size> getResolutionList(Camera camera)
{
Parameters parameters = camera.getParameters();
List<Camera.Size> previewSizes = parameters.getSupportedPreviewSizes();
return previewSizes;
}
示例12: getResolutionList
import android.hardware.Camera.Parameters; //导入方法依赖的package包/类
public static List<Size> getResolutionList(Camera camera)
{
Parameters parameters = camera.getParameters();
List<Size> previewSizes = parameters.getSupportedPreviewSizes();
return previewSizes;
}
示例13: getResolutionList
import android.hardware.Camera.Parameters; //导入方法依赖的package包/类
public static List<Camera.Size> getResolutionList(Camera camera) {
Parameters parameters = camera.getParameters();
List<Camera.Size> previewSizes = parameters.getSupportedPreviewSizes();
return previewSizes;
}