Android 如何将捕获的图像保存到和其他目录中的imageview?
我的应用程序基于android studio, 我非常感谢您的帮助和考虑:)Android 如何将捕获的图像保存到和其他目录中的imageview?,android,android-studio,directory,save,android-camera,Android,Android Studio,Directory,Save,Android Camera,我的应用程序基于android studio, 我非常感谢您的帮助和考虑:) 谢谢:)将捕获的图像[从照相机]设置为图像视图: Intent getImageIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); startActivityForResult(getImageIntent, 1); @Override protected void onActivityResult(int reques
谢谢:)将捕获的图像[从照相机]设置为图像视图:
Intent getImageIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(getImageIntent, 1);
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == 1) {
if (resultCode == Activity.RESULT_OK) {
imageCounter++;
takePicture(data);
} else if (resultCode == Activity.RESULT_CANCELED) {
}
}
}
protected void takePicture(Intent data) {
Bundle b = data.getExtras();
Bitmap pic = (Bitmap) b.get("data");
if (pic != null) {
ImageView img = new ImageView(this);
((LinearLayout) findViewById(R.id.captured_image_layout))
.addView(img);
img.setLayoutParams(new LinearLayout.LayoutParams(0,
LinearLayout.LayoutParams.WRAP_CONTENT, 0.33f));
img.setPadding(5, 5, 5, 5);
img.setImageBitmap(pic);
}
}
用于将捕获图像[从照相机]设置为图像视图:
Intent getImageIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(getImageIntent, 1);
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == 1) {
if (resultCode == Activity.RESULT_OK) {
imageCounter++;
takePicture(data);
} else if (resultCode == Activity.RESULT_CANCELED) {
}
}
}
protected void takePicture(Intent data) {
Bundle b = data.getExtras();
Bitmap pic = (Bitmap) b.get("data");
if (pic != null) {
ImageView img = new ImageView(this);
((LinearLayout) findViewById(R.id.captured_image_layout))
.addView(img);
img.setLayoutParams(new LinearLayout.LayoutParams(0,
LinearLayout.LayoutParams.WRAP_CONTENT, 0.33f));
img.setPadding(5, 5, 5, 5);
img.setImageBitmap(pic);
}
}
谢谢你,shubham:)我真的很感激!工作原理:D非常感谢:)谢谢你,舒巴姆:)我真的很感激!有效:D非常感谢:)