Android 使位图使用相机的意图大
我的相机目标位图只有160x120,我想我怎样才能实现全尺寸位图 顺便说一句,我尝试了额外的输出,但我不知道如何使用它 我有两节课 我的主要课堂活动结果是Android 使位图使用相机的意图大,android,uri,android-camera-intent,onactivityresult,Android,Uri,Android Camera Intent,Onactivityresult,我的相机目标位图只有160x120,我想我怎样才能实现全尺寸位图 顺便说一句,我尝试了额外的输出,但我不知道如何使用它 我有两节课 我的主要课堂活动结果是 case CAMERA_REQUEST_CODE: if (resultCode == RESULT_OK) { Bitmap image1 = (Bitmap) data.getExtras().get("data"); if (currentView == 0) {
case CAMERA_REQUEST_CODE:
if (resultCode == RESULT_OK) {
Bitmap image1 = (Bitmap) data.getExtras().get("data");
if (currentView == 0) {
frontView.setScaleType(ScaleType.CENTER);
frontView.setImageBitmap(image1);
isFrontActive = true;
} else if (currentView == 1) {
rearView.setScaleType(ScaleType.CENTER);
rearView.setImageBitmap(camera.getImage());
isRearActive = true;
}
}
break;
这是photo.class代码
public void openCamera() {
File file = new File(Environment.getExternalStorageDirectory(),
"Sample.jpg");
Uri imgUri = Uri.fromFile(file);
imagepath = file.getAbsolutePath();
Intent cameraIntent = new Intent(
android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, imagepath);
mActivity.startActivityForResult(cameraIntent, CAMERA_REQUEST_CODE);
}
因此,他们是在一个单独的类,我不知道如何使用额外的输出请帮助我,谢谢你
编辑:
我叫photo.class
利用
photo.openCamera();在Main类上,当您使用从extra读取位图时,您将获得图像的缩略图
我通过将Uri转换为位图来工作
bitmap = MediaStore.Images.Media.getBitmap(
this.getContentResolver(), imageUri);
然后我使用
MediaStore.Images.Media.insertImage(
getContentResolver(), bitmap, "Title",
"Desc");
这是我在Main.class上为onActivityResult编写的代码
case 2:
if (resultCode == RESULT_OK) {
Bitmap bitmap = null;
Uri imageUri = camera.getImageUri();
try {
bitmap = MediaStore.Images.Media.getBitmap(
this.getContentResolver(), imageUri);
bitmap = camera.setImage(bitmap);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
if (currentView == 0) {
frontView.setImageBitmap(bitmap);
isFrontActive = true;
MediaStore.Images.Media.insertImage(
getContentResolver(), bitmap, "Title",
"Desc");
} else if (currentView == 1) {
rearView.setImageBitmap(bitmap);
isRearActive = true;
}
}
}
break;
and this is my Photo.class
私有Uri imageUri;//全球的
public void openCamera() {
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
File file = new File(Environment.getExternalStorageDirectory(),
"Cloudstaff_Ron.jpg");
Uri imgUri = Uri.fromFile(file);
intent.putExtra(MediaStore.EXTRA_OUTPUT, imgUri);
this.imageUri = imgUri;
mActivity.startActivityForResult(intent, 2);
}
谢谢你的链接,有没有一个更简单的版本,或者是它?这是最好的方法。由于您有两个类,例如,您可以将方法
storeImage
放在Photo中。类
您可以将您的代码放在其他人正在寻找的情况下吗?答案部分已经有了:)谢谢Renan的参考