Java 类com.bumptech.glide.load.resource.bitmap.BitmapTransformation 实例源码

项目:GankEssence    文件:ImagesUtil.java   
/**
 * 显示图片
 * @param context     上下文
 * @param imageView   图片view
 * @param uri         图片路径
 * @param bitmapTransformation bitmap转换器
 */
private static void display(Context context, final ImageView imageView, String uri, BitmapTransformation bitmapTransformation, boolean isAvatar){
    DrawableTypeRequest<String> drawableTypeRequest = Glide.with(context).load(uri);
    drawableTypeRequest
            .centerCrop()
            .placeholder(ERROR_IMAGE)
            .error(isAvatar ? AVATAR_IMAGE : ERROR_IMAGE)
            .diskCacheStrategy(DiskCacheStrategy.ALL)
            .dontAnimate();

    // 添加转换器
    if(null != bitmapTransformation){
        drawableTypeRequest.bitmapTransform(bitmapTransformation);
    }

    // 设置图片
    drawableTypeRequest.into(imageView);
}
项目:QxGradleConfig    文件:MainActivity.java   
private void loadImage(ImageView iv, int resid) {
        Glide
                .with(this)
//                .load(url)
                .load(resid)
//                .fitCenter() //缩放在view中,图的中心点与view的中心点匹配  全图可见
                .centerCrop()  //缩放,一边贴view的边,就停止
                .placeholder(R.mipmap.ic_launcher) //占位图
//                .error(resid)  //错误图
                .crossFade() //淡入
                .override(1000, 800) //图片尺寸
                .transform(new BitmapTransformation(this) {
                    @Override
                    protected Bitmap transform(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) {
                        Bitmap bitmap = Bitmap.createBitmap(toTransform, 0, 300, outWidth, outHeight-300);
                        return bitmap;
                    }

                    @Override
                    public String getId() {
                        return "aa";
                    }
                })
                .diskCacheStrategy(DiskCacheStrategy.RESULT) //ALL=SOURCE+RESULT  SOURCE原图尺寸 RESULT所以转化后的尺寸 NONE不缓存
                .into(iv);
    }
项目:NGA-CLIENT-VER-OPEN-SOURCE    文件:BoardFragment.java   
public void handleUserAvatar(ImageView avatarIV, String url) {
    if (mDefaultAvatar == null) {
        Bitmap defaultAvatar = BitmapFactory.decodeResource(getResources(), R.drawable.default_avatar);
        mDefaultAvatar = new BitmapDrawable(getResources(), ImageUtil.toRoundCorner(defaultAvatar, 2));
    }

    avatarIV.setImageTintList(null);
    GlideApp.with(this)
            .load(url)
            .placeholder(mDefaultAvatar)
            .diskCacheStrategy(DiskCacheStrategy.RESOURCE)
            .transforms(new BitmapTransformation() {
                @Override
                protected Bitmap transform(@NonNull BitmapPool bitmapPool, @NonNull Bitmap bitmap, int i, int i1) {
                    Bitmap roundBitmap = ImageUtil.toRoundCorner(bitmap, 2);
                    bitmapPool.put(roundBitmap);
                    return roundBitmap;
                }

                @Override
                public void updateDiskCacheKey(MessageDigest messageDigest) {

                }
            })
            .into(avatarIV);
}
项目:plusTimer    文件:DrawerActivity.java   
@Override
public void setProfileImage(String url){
    Glide.with(this)
            .load(url)
            .asBitmap()
            .centerCrop()
            .placeholder(R.drawable.profile_placeholder)
            .transform(new BitmapTransformation(this) {
                @Override
                protected Bitmap transform(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) {
                    return getCircleBitmap(toTransform);
                }

                @Override
                public String getId() {
                    return "circle";
                }
            })
            .into(mHeaderProfileImage);
}
项目:lrs_android    文件:GlideUtil.java   
public static void into(Activity activity, Object resPath, ImageView iv, BitmapTransformation bt) {
    if (!AppUtil.isSafe(activity)) {
        return;
    }
    if (resPath == null) {
        return;
    }
    if (bt == null) {
        Glide.with(activity).load(resPath).into(iv);
    } else {
        Glide.with(activity).load(resPath).transform(bt).into(iv);
    }
}
项目:XFrame    文件:GlideImageLoader.java   
@Override
public void load(ImageView imageView, Object imageUrl, Object transformation) {
    Glide.with(mContext)
            .load(imageUrl)
            .crossFade()
            .transform((BitmapTransformation) transformation)
            .into(imageView);
}
项目:LikeWechatPhotoViewer    文件:GlideUtils.java   
public static void displayImage(Context context, ImageView imageView, String url, int placeHolder, BitmapTransformation transformation){
    test(url);
    Glide
            .with(context)
            .load(url)
            .diskCacheStrategy(DiskCacheStrategy.SOURCE)
            .transform(transformation)
            .placeholder(placeHolder)
            .dontAnimate()
            .into(imageView);
}
项目:LikeWechatPhotoViewer    文件:GlideUtils.java   
public static void displayImage(Context context, ImageView imageView, Uri uri, BitmapTransformation transformation){
    KLog.d(uri);
    Glide
            .with(context)
            .load(uri)
            .transform(transformation)
            .into(imageView);
}
项目:LikeWechatPhotoViewer    文件:GlideUtils.java   
public static void displayImage(Fragment fragment, ImageView imageView, String url, int placeholder, BitmapTransformation transformation){
    test(url);
    Glide
            .with(fragment)
            .fromUri()
            .load(Uri.parse(url))
            .transform(transformation)
            .placeholder(placeholder)
            .dontAnimate()
            .into(imageView);
}
项目:AnimationsDemo    文件:GlideUtils.java   
public static void displayImage(Context context, ImageView imageView, String url, int placeHolder, BitmapTransformation transformation){
    test(url);
    Glide
            .with(context)
            .load(url)
            .diskCacheStrategy(DiskCacheStrategy.SOURCE)
            .transform(transformation)
            .placeholder(placeHolder)
            .dontAnimate()
            .into(imageView);
}
项目:AnimationsDemo    文件:GlideUtils.java   
public static void displayImage(Context context, ImageView imageView, Uri uri, BitmapTransformation transformation){
    KLog.d(uri);
    Glide
            .with(context)
            .load(uri)
            .transform(transformation)
            .into(imageView);
}
项目:AnimationsDemo    文件:GlideUtils.java   
public static void displayImage(Fragment fragment, ImageView imageView, String url, int placeholder, BitmapTransformation transformation){
    test(url);
    Glide
            .with(fragment)
            .fromUri()
            .load(Uri.parse(url))
            .transform(transformation)
            .placeholder(placeholder)
            .dontAnimate()
            .into(imageView);
}
项目:Mysplash    文件:ImageHelper.java   
public static void loadResourceImage(Context context, ImageView view, int resId,
                                     @Nullable BitmapTransformation transformation) {
    DrawableRequestBuilder<Integer> request = Glide
            .with(context)
            .load(resId)
            .dontAnimate()
            .diskCacheStrategy(DiskCacheStrategy.SOURCE);
    if (transformation != null) {
        request.transform(transformation);
    }
    request.into(view);
}
项目:Retrofit2SampleApp    文件:ImageLoader.java   
@Override
public void loadImage(String url, final ImageView imageView) {
    Glide.with(imageView.getContext()).load(url).transform(new BitmapTransformation(imageView.getContext()) {
        @Override
        protected Bitmap transform(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) {
            BlurTransformation blurTransformation = new BlurTransformation(imageView.getContext());
            Resource<Bitmap> blurredBitmapResource = blurTransformation.transform(BitmapResource.obtain(toTransform, pool), 10, 1);

            Bitmap combinedBitmap;
            Bitmap bottom = blurredBitmapResource.get();

            if ((combinedBitmap = pool.get(toTransform.getWidth(), bottom.getHeight() / 3 + toTransform.getHeight(), Bitmap.Config.ARGB_8888)) == null) {
                combinedBitmap = Bitmap.createBitmap(toTransform.getWidth(), bottom.getHeight() / 3 + toTransform.getHeight(), toTransform.getConfig());
            }

            Canvas comboImage = new Canvas(combinedBitmap);
            comboImage.drawBitmap(toTransform, 0f, 0f, null);

            Matrix matrix = new Matrix();
            matrix.postRotate(180);
            matrix.preScale(-1 , 1);
            matrix.postTranslate(0, toTransform.getHeight() * 2);

            comboImage.setMatrix(matrix);
            comboImage.drawBitmap(bottom, 0f, 0f, null);

            return BitmapResource.obtain(combinedBitmap, pool).get();
        }

        @Override
        public String getId() {
            return ImageLoader.class.getName() + ".Transformation";
        }
    }).into(imageView);
}
项目:GitHub    文件:GlideImageConfig.java   
public BitmapTransformation getTransformation() {
    return transformation;
}
项目:CustomListView    文件:GlideImageConfig.java   
public BitmapTransformation[] getTransformation() {
    return transformation;
}
项目:CustomListView    文件:FrescoImageConfig.java   
public BitmapTransformation[] getTransformation() {
    return transformation;
}
项目:yyox    文件:GlideImageConfig.java   
public BitmapTransformation getTransformation() {
    return transformation;
}
项目:MVVMFrames    文件:GlideImageConfig.java   
public BitmapTransformation getTransformation() {
    return transformation;
}
项目:AppCommonFrame    文件:GlideImageConfig.java   
public BitmapTransformation getTransformation() {
    return transformation;
}
项目:MVPArms_Fragment-fragment    文件:GlideImageConfig.java   
public BitmapTransformation getTransformation() {
    return transformation;
}
项目:MoligyMvpArms    文件:ImageConfigImpl.java   
public BitmapTransformation getTransformation() {
    return transformation;
}
项目:XinFramework    文件:GlideImageConfig.java   
/**
 * glide用它来改变图形的形状
 */
public BitmapTransformation getTransformation() {
    return transformation;
}
项目:Aurora    文件:ImageConfigImpl.java   
public BitmapTransformation getTransformation() {
    return transformation;
}
项目:PicShow-zhaipin    文件:GlideImageConfig.java   
public BitmapTransformation getTransformation() {
    return transformation;
}
项目:RabbitCloud    文件:LoaderImage.java   
public static void loadRoundRect(
        Context context, String url,
        BitmapTransformation transformation, ImageView view) {
    Glide.with(context).load(url)
            .into(view);
}
项目:mvparms    文件:GlideImageConfig.java   
public BitmapTransformation getTransformation() {
    return transformation;
}
项目:NeiHanDuanZiTV    文件:ImageConfigImpl.java   
public BitmapTransformation getTransformation() {
    return transformation;
}
项目:GmArchMvvm    文件:ImageConfigImpl.java   
public BitmapTransformation getTransformation() {
    return transformation;
}
项目:GmArchMvvm    文件:ImageConfigImpl.java   
public BitmapTransformation getTransformation() {
    return transformation;
}
项目:MVPArmsTest1    文件:GlideImageConfig.java   
public BitmapTransformation getTransformation() {
    return transformation;
}
项目:MVVMArms    文件:ImageConfigImpl.java   
public BitmapTransformation getTransformation() {
    return transformation;
}
项目:ktball    文件:GlideHelper.java   
public static void loadImageRotated(Context context, ImageView view, String url, int placeHolder, BitmapTransformation... transformations) {
    Glide.with(context)
            .load(url)
            .transform(transformations).placeholder(placeHolder)
            .into(view);
}
项目:ktball    文件:GlideHelper.java   
public static void loadImageRotated(Context context, ImageView view, String url, BitmapTransformation... transformations) {
    Glide.with(context)
            .load(url)
            .transform(transformations)
            .into(view);
}
项目:ZhihuDailyNews    文件:ImageLoader.java   
public static void load(Context context, ImageView view, String url, BitmapTransformation transformation, int placeHolder) {
    getDrawableTypeRequest(context, url).placeholder(placeHolder)
            .transform(transformation)
            .crossFade()
            .into(view);
}
项目:MVPFrames    文件:GlideImageConfig.java   
public BitmapTransformation getTransformation() {
    return transformation;
}
项目:MVPArms    文件:ImageConfigImpl.java   
public BitmapTransformation getTransformation() {
    return transformation;
}
项目:Integration    文件:ImageLoaderHelper.java   
public static void loadImage(@NotNull Context mContext, @NotNull int resource, @NotNull ImageView view, BitmapTransformation transformation) {
    Glide.with(mContext).load(resource).transform(transformation).into(view);
}
项目:scissors    文件:GlideBitmapLoader.java   
public GlideBitmapLoader(@NonNull RequestManager requestManager, @NonNull BitmapTransformation transformation) {
    this.requestManager = requestManager;
    this.transformation = transformation;
}
项目:scissors    文件:GlideFillViewportTransformation.java   
public static BitmapTransformation createUsing(int viewportWidth, int viewportHeight) {
    return new GlideFillViewportTransformation(viewportWidth, viewportHeight);
}