我的程序有两个问题: 1.拍照后,onActivityResult()是这样的:
pictureTaken = (Bitmap) data.getExtras().get("data");
ImageView im = (ImageView) findViewById(R.id.view);
im.setImageBitmap(pictureTaken);
这仅显示缩略图(显示时质量差),当我将其保存到 SD 卡时,它也是一个小图像。我需要的是以全分辨率/质量保存/显示它。我要改变什么来实现这一目标?
检索和显示用户选择的图像工作:
selectedImage = data.getData(); ImageView im = (ImageView) findViewById(R.id.view); im.setImageURI(selectedImage);
但是当保存用户选择的图像时,它会在这里崩溃(由调试器找到):
...
File externalStorageFile = new File(dir, finalName);
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
//Error
resourceImage.compress(Bitmap.CompressFormat.JPEG, 100, bytes);
byte b[] = bytes.toByteArray();
try {
...
此外,位图是您在 Android 中保存图像的唯一方法吗?