生成缩略图

来源:互联网 发布:建筑光照分析软件 编辑:程序博客网 时间:2024/05/19 02:18
一、结构
public class ThumbnailUtils extends Object
java.lang.Object
android.media.ThumbnailUtils
  二、概述
    为媒体生成常规缩略图。(Android123:该类为Android2.2新增类,可以帮助我们从mediaprovider中获取系统中的视频或图片文件的缩略图)
  三、常量
  public static final int OPTIONS_RECYCLE_INPUT
  常量用于表示应该回收extractThumbnail(Bitmap, int, int, int)输入源图片(第一个参数),除非输出图片就是输入图片。
           常量值:2 (0x00000002)
  四、公共方法
  public static Bitmap createVideoThumbnail (String filePath, int kind)
  创建一张视频的缩略图。如果视频已损坏或者格式不支持可能返回null。
  参数
  filePath  视频文件路径
  kind          可以为MINI_KIND 或MICRO_KIND
  public static Bitmap extractThumbnail (Bitmap source, int width, int height, int options)
  创建所需尺寸居中缩放的位图。
  参数
  source     原始位图源
  width       目标宽
  height     目标高
options  在缩略图抽取时提供的选项
  public static Bitmap extractThumbnail (Bitmap source, int width, int height)
  创建所需尺寸居中缩放的位图。
  参数
  source     原始位图源
  width       目标宽
  height     目标高