This is my code in onPreviewFrame Method.
The frame that shows on the surfaceHolder is fine.
I Already set the resolution with this code at first
mCameraParameter = mCamera.getParameters();
mCameraParameter.setPreviewSize(100,150);
mCameraParameter.setPreviewFrameRate(20);
mCameraParameter.setPreviewFormat(PixelFormat.JPEG);
mCamera.setParameters(mCameraParameter);
but the picture that image get is 640 * 480
I wonder why i can't change the preview resolution.
public void onPreviewFrame(byte[] data, Camera camera) {
Log.e("PreviewCallBack", "Preview");
Camera.Parameters parameters = camera.getParameters();
Log.e("Picture Size", "width : " + parameters.getPreviewSize().width);
Log.e("Picture Size", "height : " + parameters.getPreviewSize().height);
Log.e("Array Size", "data.length : " + data.length);
YuvImage image = new YuvImage(data, parameters.getPreviewFormat(),
parameters.getPreviewSize().width,parameters.getPreviewSize().height, null);
File file = new File(Environment.getExternalStorageDirectory()
.getPath() + "/"+/*System.currentTimeMillis()*/"out.jpg");
FileOutputStream filecon = null;
try {
filecon = new FileOutputStream(file);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
image.compressToJpeg(
new Rect(0, 0, image.getWidth(), image.getHeight()), 90,
filecon);
}
};
Maybe you are trying to set an unsupported preview size. Better call " getSupportedPreviewSizes() " and check if the preview size you want to set is supported by your device before calling setPreviewSize() .
我认为您应该调用setPictureSize()
来设置图片本身的大小(而不是预览)。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.