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


Java Parameters.getSupportedPreviewSizes方法代码示例

本文整理汇总了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;
}
 
开发者ID:vitaviva,项目名称:QRCodeScanner,代码行数:25,代码来源:BarcodeCameraConfig.java

示例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;
}
 
开发者ID:linglongxin24,项目名称:VideoCamera,代码行数:18,代码来源:CameraWrapper.java

示例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());
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:33,代码来源:CameraUtils.java

示例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();
     } 
 }
 
开发者ID:woshiwpa,项目名称:SmartMath,代码行数:39,代码来源:CameraPreview.java

示例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();
	}
}
 
开发者ID:orangecoder,项目名称:VideoRecord,代码行数:38,代码来源:MyCameraManager.java

示例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();
}
 
开发者ID:asm-products,项目名称:nexus-camera,代码行数:35,代码来源:WideAnglePanoramaModule.java

示例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;
}
 
开发者ID:peirenlei,项目名称:FFmpegRecorder,代码行数:9,代码来源:Util.java

示例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;
}
 
开发者ID:liuyanggithub,项目名称:SuperSelector,代码行数:6,代码来源:Utils.java

示例9: getResolutionList

import android.hardware.Camera.Parameters; //导入方法依赖的package包/类
public static List<Camera.Size> getResolutionList(Camera camera)
{ 
	Parameters parameters = camera.getParameters();
	return parameters.getSupportedPreviewSizes();
}
 
开发者ID:feigxj,项目名称:VideoRecorder-master,代码行数:6,代码来源:Util.java

示例10: getResolutionList

import android.hardware.Camera.Parameters; //导入方法依赖的package包/类
public static List<Size> getResolutionList(Camera camera) {
    Parameters parameters = camera.getParameters();
    return parameters.getSupportedPreviewSizes();
}
 
开发者ID:mangestudio,项目名称:GCSApp,代码行数:5,代码来源:Utils.java

示例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;
}
 
开发者ID:macyuan,项目名称:TAG,代码行数:7,代码来源:Utils.java

示例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;
}
 
开发者ID:chenjunqian,项目名称:here,代码行数:7,代码来源:Utils.java

示例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;
}
 
开发者ID:nggirl,项目名称:EaseChatDemo,代码行数:6,代码来源:Utils.java


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