我是靠谱客的博主 炙热黄蜂,最近开发中收集的这篇文章主要介绍聊天平台源码,通过MediaStore获取缩略图模糊,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

聊天平台源码,通过MediaStore获取缩略图模糊实现的方法
获取缩略图的方法

Bitmap thumbnail = Images.Thumbnails.getThumbnail(mContext.getContentResolver(), id, Images.Thumbnails.MICRO_KIND, null);

该方法为系统方法getThumbnail

/**
 * Return thumbnail representing a specific image item. If a
 * thumbnail doesn't exist, this method will block until it's
 * generated. Callers are responsible for their own in-memory
 * caching of returned values.
 *
 * As of {@link android.os.Build.VERSION_CODES#Q}, this output
 * of the thumbnail has correct rotation, don't need to rotate
 * it again.
 *
 * @param imageId the image item to obtain a thumbnail for.
 * @param kind optimal thumbnail size desired.
 * @return decoded thumbnail, or {@code null} if problem was
 *         encountered.
 * @deprecated Callers should migrate to using
 *             {@link ContentResolver#loadThumbnail}, since it
 *             offers richer control over requested thumbnail sizes
 *             and cancellation behavior.
 */
@Deprecated
public static Bitmap getThumbnail(ContentResolver cr, long imageId, int kind,
        BitmapFactory.Options options) {
    final Uri uri = ContentUris.withAppendedId(
            Images.Media.EXTERNAL_CONTENT_URI, imageId);
    return InternalThumbnails.getThumbnail(cr, uri, kind, options);
}

观察到参数@param kind optimal thumbnail size desired

packages/providers/MediaProvider/apex/framework/java/android/provider/MediaStore.java

public static class ThumbnailConstants {
    public static final int MINI_KIND = 1;
    public static final int FULL_SCREEN_KIND = 2;
    public static final int MICRO_KIND = 3;

    public static final Size MINI_SIZE = new Size(512, 384);
    public static final Size FULL_SCREEN_SIZE = new Size(1024, 786);
    public static final Size MICRO_SIZE = new Size(96, 96);

    public static @NonNull Size getKindSize(int kind) {
        if (kind == ThumbnailConstants.MICRO_KIND) {
            return ThumbnailConstants.MICRO_SIZE;
        } else if (kind == ThumbnailConstants.FULL_SCREEN_KIND) {
            return ThumbnailConstants.FULL_SCREEN_SIZE;
        } else if (kind == ThumbnailConstants.MINI_KIND) {
            return ThumbnailConstants.MINI_SIZE;
        } else {
            throw new IllegalArgumentException("Unsupported kind: " + 
        }
    }
}

因此,如要修改缩略图清晰度,可以修改第三个参数为MINI_KIND或FULL_SCREEN_KIND即可。
以上就是聊天平台源码,通过MediaStore获取缩略图模糊实现的方法, 更多内容欢迎关注之后的文章

最后

以上就是炙热黄蜂为你收集整理的聊天平台源码,通过MediaStore获取缩略图模糊的全部内容,希望文章能够帮你解决聊天平台源码,通过MediaStore获取缩略图模糊所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(36)

评论列表共有 0 条评论

立即
投稿
返回
顶部