【发布时间】:2011-06-22 10:52:57
【问题描述】:
我的程序有两个问题: 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 中保存图像的唯一方法吗?
【问题讨论】:
-
堆栈跟踪说明了什么?请发帖。
标签: android image android-camera android-sdcard image-size