本文整理匯總了Java中android.hardware.Camera.Parameters.setPictureSize方法的典型用法代碼示例。如果您正苦於以下問題:Java Parameters.setPictureSize方法的具體用法?Java Parameters.setPictureSize怎麽用?Java Parameters.setPictureSize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.hardware.Camera.Parameters
的用法示例。
在下文中一共展示了Parameters.setPictureSize方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: prepare
import android.hardware.Camera.Parameters; //導入方法依賴的package包/類
public boolean prepare() {
try {
f = new SurfaceTexture(0);
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
// f.setDefaultBufferSize(10000, 10000);
// }
// SurfaceHolder h = new SurfaceView(JCL_ApplicationContext.getContext()).getHolder();
//mCamera.setPreviewDisplay(h);
mCamera.setPreviewTexture(f);
} catch (IOException e1) {
Log.e("JCLCAMERA", e1.getMessage());
return false;
}
Parameters params = mCamera.getParameters();
params.setPreviewSize(width, height);
params.setPictureSize(width, height);
params.setJpegQuality(50);
params.setFlashMode(Parameters.FLASH_MODE_OFF);
params.setPictureFormat(ImageFormat.JPEG);
mCamera.setParameters(params);
return true;
}
示例2: startPreview
import android.hardware.Camera.Parameters; //導入方法依賴的package包/類
private void startPreview(SurfaceHolder holder) {
try {
Parameters params = camera.getParameters();
if (params.getSupportedFocusModes().contains(
Camera.Parameters.FOCUS_MODE_AUTO)) {
params.setFocusMode(Camera.Parameters.FOCUS_MODE_AUTO);
}
List<Size> previewSizes = camera.getParameters().getSupportedPreviewSizes();
List<Size> pictureSizes = camera.getParameters().getSupportedPictureSizes();
params.setPreviewSize(previewSizes.get(previewSizes.size()-2).width,previewSizes.get(previewSizes.size()-2).height);
params.setPictureSize(pictureSizes.get(pictureSizes.size()-2).width,pictureSizes.get(pictureSizes.size()-2).height);
camera.setParameters(params);
camera.setPreviewDisplay(holder);
camera.startPreview();
previewConsumer.start(camera);
} catch(IOException e) {
Log.e(TAG, "Error starting camera preview", e);
}
}
示例3: setDefaultParameters
import android.hardware.Camera.Parameters; //導入方法依賴的package包/類
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);
}
示例4: setDefaultParameters
import android.hardware.Camera.Parameters; //導入方法依賴的package包/類
private static void setDefaultParameters(){
Parameters parameters = camera.getParameters();
if (parameters.getSupportedFocusModes().contains(
Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE)) {
parameters.setFocusMode(Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);
}
Size previewSize = CameraUtils.getLargePreviewSize(camera);
parameters.setPreviewSize(previewSize.width, previewSize.height);
Size pictureSize = CameraUtils.getLargePictureSize(camera);
parameters.setPictureSize(pictureSize.width, pictureSize.height);
parameters.setRotation(90);
camera.setParameters(parameters);
}
示例5: setCameraPictureSize
import android.hardware.Camera.Parameters; //導入方法依賴的package包/類
public static boolean setCameraPictureSize(
String candidate, List<Size> supported, Parameters parameters) {
int index = candidate.indexOf('x');
if (index == NOT_FOUND) return false;
int width = Integer.parseInt(candidate.substring(0, index));
int height = Integer.parseInt(candidate.substring(index + 1));
for (Size size : supported) {
if (size.width == width && size.height == height) {
parameters.setPictureSize(width, height);
return true;
}
}
return false;
}
示例6: setCamera
import android.hardware.Camera.Parameters; //導入方法依賴的package包/類
void setCamera() {
myCamera = getCameraInstance();
Parameters params = myCamera.getParameters();
List<Camera.Size> sizes = params.getSupportedPictureSizes();
int minWidth = Integer.MAX_VALUE, minHeight = Integer.MAX_VALUE;
for (int i = 0; i < sizes.size(); i++) {
Log.i("PictureSize", "Supported Size: " + sizes.get(i).width
+ " height : " + sizes.get(i).height);
if (sizes.get(i).width < minWidth) {
minWidth = sizes.get(i).width;
minHeight = sizes.get(i).height;
}
}
Log.i("PictureSize", "Min Size: " + minWidth + " height : " + minHeight);
List<int[]> fpsRanges = params.getSupportedPreviewFpsRange();
for (int i = 0; i < fpsRanges.size(); i++) {
Log.i("Fps ranges:", String.valueOf(fpsRanges.get(i)[0] / 1000)
+ ' ' + String.valueOf(fpsRanges.get(i)[1] / 1000));
}
params.setPictureSize(minWidth, minHeight);
params.setPreviewSize(minWidth, minHeight);
myCamera.setParameters(params);
camHeight = myCamera.getParameters().getPreviewSize().height;
camWidth = myCamera.getParameters().getPreviewSize().width;
Log.i("SavedPictureSize", "Size: " + camWidth + " height : "
+ camHeight);
mCallbackBuf = new byte[camHeight * camWidth * 3 / 2]; // 用於previewcallback
hbeg = (camHeight - hnum) / 2;
wbeg = (camWidth - wnum) / 2;
myCamera.setPreviewCallbackWithBuffer(new MyPreview());
myCamera.addCallbackBuffer(mCallbackBuf);
sv_hidden.removeAllViews(); // 是不是應該先清空
myCameraSurfaceView = new MyCameraSurfaceView(getApplicationContext(),
myCamera);
sv_hidden.addView(myCameraSurfaceView);
// sv_hidden.setVisibility(View.INVISIBLE);
}
示例7: openCamera
import android.hardware.Camera.Parameters; //導入方法依賴的package包/類
/**
* 初始化攝像頭
*/
private void openCamera(SurfaceView surfaceView, int width, int height) {
if (!isPreview) {
camera = Camera.open();
}
if (camera != null && !isPreview) {
try {
Parameters parameters = camera.getParameters();
// 設置閃光燈為自動狀態
parameters.setFlashMode(Parameters.FLASH_MODE_AUTO);
camera.setParameters(parameters);
// 設置預覽照片的大小
parameters.setPreviewSize(width, height);
// 設置每秒顯示4幀
parameters.setPreviewFrameRate(4);
// 設置圖片格式
parameters.setPictureFormat(ImageFormat.JPEG);
// 設置JPG照片的質量
parameters.set("jpeg-quality", 100);
// 設置照片大小
parameters.setPictureSize(width, height);
// 通過SurfaceView顯示取景畫麵
camera.setPreviewDisplay(surfaceView.getHolder());
// 如果是豎屏
if (surfaceView.getContext().getResources().getConfiguration().orientation != Configuration.ORIENTATION_LANDSCAPE) {
camera.setDisplayOrientation(90);
} else {
camera.setDisplayOrientation(0);
}
// 開始預覽
camera.startPreview();
// 自動對焦
camera.autoFocus(null);
isPreview = true;
} catch (Exception e) {
e.printStackTrace();
}
}
}
示例8: set_picture_resolution
import android.hardware.Camera.Parameters; //導入方法依賴的package包/類
public void set_picture_resolution(Size new_resolution)
{
Parameters params = mCamera.getParameters();
params.setPictureSize(new_resolution.width, new_resolution.height);
mCamera.setParameters(params);
}