如何将捕获的图像保存到另一个目录中的图像视图?
How to save captured image to a imageview in andother directory?
我的应用程序基于 android studio,
非常感谢您的帮助和考虑:)
谢谢:)
要将捕获的图像[从相机]设置为图像视图:
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);
}
}
我的应用程序基于 android studio, 非常感谢您的帮助和考虑:) 谢谢:)
要将捕获的图像[从相机]设置为图像视图:
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);
}
}