【发布时间】:2016-03-18 09:48:07
【问题描述】:
【问题讨论】:
标签: android android-studio directory save android-camera
【问题讨论】:
标签: android android-studio directory save android-camera
用于将捕获的图像[从相机]设置为图像视图:
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);
}
}
【讨论】: