我有一个应用程序,可以拍摄照片以及显示像帧一样的图像视图。我想要做的是将imageview与PictureCallback中的数据合并,我已经阅读了多个教程,但我发现它们很难。是否可以在下面的代码中合并并保存图像?一些样本会有所帮助!
private Camera.PictureCallback mPicJpgListener = new Camera.PictureCallback() {
public void onPictureTaken(byte[] data, Camera camera) {
if (data == null) {
return;
}
String saveDir = Environment.getExternalStorageDirectory().getPath() + "/test";
// retrieve the folder
File file = new File(saveDir);
// creating a folder
if (!file.exists()) {
if (!file.mkdir()) {
Log.e("Debug", "Make Dir Error");
}
}
// saving the Path
Calendar cal = Calendar.getInstance();
SimpleDateFormat sf = new SimpleDateFormat("yyyyMMdd_HHmmss");
String imgPath = saveDir + "/" + sf.format(cal.getTime()) + ".jpg";
// ファイル保存
FileOutputStream fos;
try {
fos = new FileOutputStream(imgPath, true);
//我想合并ImageView
fos.write(data); //writing the data
fos.close();
registAndroidDB(imgPath);
} catch (Exception e) {
Log.e("Debug", e.getMessage());
}
fos = null;
mCam.startPreview();
mIsTake = false;
}
};