Android:从图像获取缩略图信息

发布于 2024-10-08 16:28:50 字数 283 浏览 0 评论 0原文

如何从给定的文件路径获取图像缩略图?这是我在“onActivityResult”上所做的

    Intent cameraIntent = new Intent("android.media.action.IMAGE_CAPTURE");
    startActivityForResult(cameraIntent, CAMERA_PIC_REQUEST);

,我在意图数据中获取图像。

我想从此图像中提取缩略图信息。我如何提取它,以便我可以将该缩略图显示为预览

How do i get image thumbnail from the given file path? Here what i am doing

    Intent cameraIntent = new Intent("android.media.action.IMAGE_CAPTURE");
    startActivityForResult(cameraIntent, CAMERA_PIC_REQUEST);

On "onActivityResult", i get the image in Intent data.

I want to extract thumbnail info from this image. How do i extract it, so that i can show that thumbnail as preview

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

过去的过去 2024-10-15 16:28:50

获得位图后,您可以将其转换为缩略图
使用 createScaledBitmap (Bitmap src, int dstWidth, int dstHeight, boolean filter) 或者,对于 Android2.2 及更高版本,
使用 位图提取缩略图(位图源,int 宽度,int 高度)

Once you have the bitmap, you can convert it to a thumbnail
using createScaledBitmap (Bitmap src, int dstWidth, int dstHeight, boolean filter) or, for Android2.2 and up,
using Bitmap extractThumbnail (Bitmap source, int width, int height).

羁〃客ぐ 2024-10-15 16:28:50

查看媒体提供商的缩略图生成例程:
http://developer.android.com/reference/android/media/ThumbnailUtils.html

Bitmap thumbBitmap = ThumbnailUtils.extractThumbnail(BitmapFactory.decodeFile(filePath), thumbWidth, thumbHeight);

Check out the thumbnail generation routines for media provider:
http://developer.android.com/reference/android/media/ThumbnailUtils.html

Bitmap thumbBitmap = ThumbnailUtils.extractThumbnail(BitmapFactory.decodeFile(filePath), thumbWidth, thumbHeight);
虐人心 2024-10-15 16:28:50

我认为您必须获取完整图像并缩放它,或者在 BitmapFactory.Options 中指定 inSampleSize>1 对其进行解码。

I think you'll have to get the full image and either scale it, or decode it specifying inSampleSize>1 in BitmapFactory.Options.

孤云独去闲 2024-10-15 16:28:50

查看 Android 本身内部的缩略图生成类 - http://developer.android.com /reference/android/media/ThumbnailUtils.html

自 API 级别 8 起可用。

Check out the thumbnail generation class inside Android itself - http://developer.android.com/reference/android/media/ThumbnailUtils.html

It's available since API level 8.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文