A thumbnail ThumbnailUtils class has been added in the system since Android 2.2, which is located in the android. media. the location of ThumbnailUtils can help us obtain thumbnails of video or image files in the system from mediaprovider. This class provides three static methods that can be called directly.
1. extractThumbnail (source, width, height ):
Java code
/**
*
* Create a thumbnail of the specified size
* @ Param source file (Bitmap type)
* @ Param width: the width of the compressed string.
* @ Param height refers to the height compressed
*/
ThumbnailUtils. extractThumbnail (source, width, height );
2. extractThumbnail (source, width, height, options ):
Java code
/**
* Create a thumbnail with a specified center size
*
* @ Param source file (Bitmap type)
* @ Param width: width of the thumbnail output
* @ Param height: output the height of the thumbnail.
* @ Param options if options is defined as OPTIONS_RECYCLE_INPUT, the resource file @ param source will be recycled.
* (Unless the thumbnail is equal to @ param source)
*
*/
ThumbnailUtils. extractThumbnail (source, width, height, options );
3. createVideoThumbnail (filePath, kind ):
Java code
/**
* Create a thumbnail of a video.
* If the video is damaged or the video format is not supported, null may be returned.
*
* @ Param filePath: Specifies the video file path, for example,/sdcard/android.3gp.
* @ Param kind can be MINI_KIND or MICRO_KIND
*
*/
ThumbnailUtils. createVideoThumbnail (filePath, kind );