【发布时间】:2017-08-05 05:33:47
【问题描述】:
我不是要配置自定义相机,我只需要用它拍照。
我的 xml 中有一个 SurfaceView 和一个拍照按钮。我找到这个方法来拍照:
mCamera.takePicture(null, null, mPicture);
mPicture 定义如下:
Camera.PictureCallback mPicture = new Camera.PictureCallback() {
@Override
public void onPictureTaken(byte[] data, Camera camera) {
pictureFile = getOutputMediaFile();
if (pictureFile == null) {
return;
}
try {
FileOutputStream fos = new FileOutputStream(pictureFile);
fos.write(data);
fos.close();
} catch (FileNotFoundException e) {
} catch (IOException e) {
}
}
};
我需要一张拍摄图像的位图,以便在另一个 Activity 中使用它。 提前致谢!
【问题讨论】:
-
为什么要显示所有代码!无关紧要。您的设备中有一个 jpg 文件,并且您想要它的位图就是您想要的。就这样。究竟是什么问题?告诉其他活动该文件的路径。