android.media.ThumbnailUtils提供了三个对外的静态接口,使用此类进行缩略图大小调整非常方便,省去了自己缩放。而且非常节省内存资源。
1. public static Bitmap createVideoThumbnail (String filePath, int kind)
Create a video thumbnail for a video. May return null if the video is corrupt or the format is not supported.
filePath the path of video file(视频文件路径)
source original bitmap source(原始Bitmap源文件)
width targeted width(指定宽度)
height targeted height(指定高度)
options options used during thumbnail extraction(输出选项)
1. public static Bitmap createVideoThumbnail (String filePath, int kind)
Create a video thumbnail for a video. May return null if the video is corrupt or the format is not supported.
译:返回视频缩略图,如果视频损坏或格式不被支持那么都将返回为空
ParametersfilePath the path of video file(视频文件路径)
kind could be MINI_KIND or MICRO_KIND
(缩略图类型 MINI_KIND: 512 x 384 thumbnail , MICRO_KIND: 96 x 96 thumbnail)
2. public static Bitmap extractThumbnail (Bitmap source, int width, int height, int options)
Creates a centered bitmap of the desired size.
译:创建一个指定大小居中的缩略图,如果options定义为OPTIONS_RECYCLE_INPUT,则回收资源
source original bitmap source(原始Bitmap源文件)
width targeted width(指定宽度)
height targeted height(指定高度)
options options used during thumbnail extraction(输出选项)
3. public static Bitmap extractThumbnail (Bitmap source, int width, int height)
Creates a centered bitmap of the desired size.
译:创建一个指定大小居中的缩略图
source original bitmap source(原始Bitmap源文件)
width targeted width(指定宽度)
height targeted height(指定高度)
ThumbnailUtils类是API Level从8或更高才开始支持的,不向下兼容