这是我的代码。我在android上运行它。三星S4手机。你能帮忙吗?谢谢。
public void onPreviewFrame(byte[] data, Camera mCamera) {
String root = Environment.getExternalStorageDirectory().toString();
Random generator = new Random();
int n = 10000;
n = generator.nextInt(n);
String fname = " " + n;
Camera.Parameters parameters = mCamera.getParameters();
Size size = parameters.getPreviewSize();
YuvImage image = new YuvImage(data, parameters.getPreviewFormat(),
mPreviewSize.width, mPreviewSize.height, null);
File file = new File(Environment.getExternalStorageDirectory()
.getPath() + fname + "out.jpg");
FileOutputStream filecon = null;
try {
filecon = new FileOutputStream(file);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
image.compressToJpeg(
new Rect(0, 0, image.getWidth(), image.getHeight()), 90,
filecon);
}