如何从Android的摄像头的缩略图和图像路径? [英] How to get thumbnail and image path from android camera?
本文介绍了如何从Android的摄像头的缩略图和图像路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
通过这样的方式
Intent i = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(i, REQUEST_CODE);
我得到了一个的onActivityResult位表格式的意图,而不是路径!,通过这样的方式
i get a bitmap form intent in the onActivityResult, and not the path !, by this way
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, mImageUri);
startActivityForResult(intent, REQUEST_CODE);
我可以从意向的路径,而不是位图!!,我怎么能得到位图(缩略图)和Android的相机路径?
i can get the path from intent, and not the bitmap !!, how can i get the bitmap(thumbnail) and the path from android camera ?
推荐答案
这是你可以使用该路径创建一个这样的缩略图图像路径
From that you can get the image path with using that path create a thumbnail image like this
/**
*
* 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的摄像头的缩略图和图像路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文