这样
Intent i = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(i, REQUEST_CODE);
通过这种方式,我在 onActivityResult 中获得了位图表单 Intent ,而不是路径!
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, mImageUri);
startActivityForResult(intent, REQUEST_CODE);
我可以从 Intent 中获取路径,而不是位图!!,我如何从android相机中获取位图(缩略图)和路径?
最佳答案
从中您可以获取图像路径,并使用该路径创建像这样的缩略图
/**
*
* Returns the given size of the bitmap
*
* @param path
* @return {@link Bitmap}
*/
private Bitmap getThumbnailBitmap(String path, int thumbnailSize) {
BitmapFactory.Options bounds = new BitmapFactory.Options();
bounds.inJustDecodeBounds = true;
BitmapFactory.decodeFile(path, bounds);
if ((bounds.outWidth == -1) || (bounds.outHeight == -1)) {
return null;
}
int originalSize = (bounds.outHeight > bounds.outWidth) ? bounds.outHeight
: bounds.outWidth;
BitmapFactory.Options opts = new BitmapFactory.Options();
opts.inSampleSize = originalSize / thumbnailSize;
return BitmapFactory.decodeFile(path, opts);
}
给出您想要的尺寸
关于android - 如何从Android相机获取缩略图和图像路径?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18183490/