當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。