本文整理匯總了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;
}