【发布时间】:2012-02-06 12:37:38
【问题描述】:
我正在尝试使用 Android Camera API,但是当我拍照时,它的分辨率与我的 Camera 对象 previewSize 分辨率相同。
一些解释代码:
private Camera mCamera;
private Camera.PictureCallback mPictureCallback;
...
public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
...
Camera.Parameters p = mCamera.getParameters();
p.setPreviewSize(mPreviewWidth, mPreviewHeight);
p.setPictureSize(mPictureWidth,mPictureHeight);
mCamera.setParameters(p);
...
}
public void onPictureTaken(byte[] imageData, Camera c) {
Bitmap bitmapPicture = BitmapFactory.decodeByteArray(imageData, 0, imageData.length);
bitmapPicture.getWidth(); //At this point the width is the same as mPreviewWidth and I want it to be mPictureWidth
}
/**
* This function is called when the user touches the surfaceview
*/
public void clickCamera(View v){
mCamera.takePicture(null, mPictureCallback, mPictureCallback);
}
我在评论行怎么说,而不是 previewSize 我想用配置到我的相机的pictureSize 拍照
【问题讨论】:
-
可能是您在此处设置的宽度和高度的 bcoz,p.setPictureSize(mPictureWidth,mPictureHeight);
-
@AndroSelva 这些值是正确的,它们都代表我要配置的分辨率。调试了一段时间发现哪里出了问题,我会尽快把答案写在这里。