當前位置: 首頁>>代碼示例>>Java>>正文


Java BitmapTransformation類代碼示例

本文整理匯總了Java中com.bumptech.glide.load.resource.bitmap.BitmapTransformation的典型用法代碼示例。如果您正苦於以下問題:Java BitmapTransformation類的具體用法?Java BitmapTransformation怎麽用?Java BitmapTransformation使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


BitmapTransformation類屬於com.bumptech.glide.load.resource.bitmap包,在下文中一共展示了BitmapTransformation類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: display

import com.bumptech.glide.load.resource.bitmap.BitmapTransformation; //導入依賴的package包/類
/**
 * 顯示圖片
 * @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);
}
 
開發者ID:hcw2175,項目名稱:GankEssence,代碼行數:25,代碼來源:ImagesUtil.java

示例2: loadImage

import com.bumptech.glide.load.resource.bitmap.BitmapTransformation; //導入依賴的package包/類
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);
    }
 
開發者ID:XinRan5312,項目名稱:QxGradleConfig,代碼行數:27,代碼來源:MainActivity.java

示例3: handleUserAvatar

import com.bumptech.glide.load.resource.bitmap.BitmapTransformation; //導入依賴的package包/類
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);
}
 
開發者ID:ymback,項目名稱:NGA-CLIENT-VER-OPEN-SOURCE,代碼行數:27,代碼來源:BoardFragment.java

示例4: setProfileImage

import com.bumptech.glide.load.resource.bitmap.BitmapTransformation; //導入依賴的package包/類
@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);
}
 
開發者ID:plusCubed,項目名稱:plusTimer,代碼行數:21,代碼來源:DrawerActivity.java

示例5: into

import com.bumptech.glide.load.resource.bitmap.BitmapTransformation; //導入依賴的package包/類
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);
    }
}
 
開發者ID:wzc25151,項目名稱:lrs_android,代碼行數:14,代碼來源:GlideUtil.java

示例6: load

import com.bumptech.glide.load.resource.bitmap.BitmapTransformation; //導入依賴的package包/類
@Override
public void load(ImageView imageView, Object imageUrl, Object transformation) {
    Glide.with(mContext)
            .load(imageUrl)
            .crossFade()
            .transform((BitmapTransformation) transformation)
            .into(imageView);
}
 
開發者ID:youth5201314,項目名稱:XFrame,代碼行數:9,代碼來源:GlideImageLoader.java

示例7: displayImage

import com.bumptech.glide.load.resource.bitmap.BitmapTransformation; //導入依賴的package包/類
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);
}
 
開發者ID:Sherchen,項目名稱:LikeWechatPhotoViewer,代碼行數:12,代碼來源:GlideUtils.java

示例8: loadResourceImage

import com.bumptech.glide.load.resource.bitmap.BitmapTransformation; //導入依賴的package包/類
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);
}
 
開發者ID:WangDaYeeeeee,項目名稱:Mysplash,代碼行數:13,代碼來源:ImageHelper.java

示例9: loadImage

import com.bumptech.glide.load.resource.bitmap.BitmapTransformation; //導入依賴的package包/類
@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);
}
 
開發者ID:shelajev,項目名稱:Retrofit2SampleApp,代碼行數:36,代碼來源:ImageLoader.java

示例10: getTransformation

import com.bumptech.glide.load.resource.bitmap.BitmapTransformation; //導入依賴的package包/類
public BitmapTransformation getTransformation() {
    return transformation;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:4,代碼來源:GlideImageConfig.java

示例11: getTransformation

import com.bumptech.glide.load.resource.bitmap.BitmapTransformation; //導入依賴的package包/類
public BitmapTransformation[] getTransformation() {
    return transformation;
}
 
開發者ID:BaoBaoJianqiang,項目名稱:CustomListView,代碼行數:4,代碼來源:GlideImageConfig.java

示例12: getTransformation

import com.bumptech.glide.load.resource.bitmap.BitmapTransformation; //導入依賴的package包/類
/**
 * glide用它來改變圖形的形狀
 */
public BitmapTransformation getTransformation() {
    return transformation;
}
 
開發者ID:wzx54321,項目名稱:XinFramework,代碼行數:7,代碼來源:GlideImageConfig.java

示例13: loadRoundRect

import com.bumptech.glide.load.resource.bitmap.BitmapTransformation; //導入依賴的package包/類
public static void loadRoundRect(
        Context context, String url,
        BitmapTransformation transformation, ImageView view) {
    Glide.with(context).load(url)
            .into(view);
}
 
開發者ID:yinyiliang,項目名稱:RabbitCloud,代碼行數:7,代碼來源:LoaderImage.java

示例14: loadImageRotated

import com.bumptech.glide.load.resource.bitmap.BitmapTransformation; //導入依賴的package包/類
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);
}
 
開發者ID:dscn,項目名稱:ktball,代碼行數:7,代碼來源:GlideHelper.java

示例15: load

import com.bumptech.glide.load.resource.bitmap.BitmapTransformation; //導入依賴的package包/類
public static void load(Context context, ImageView view, String url, BitmapTransformation transformation, int placeHolder) {
    getDrawableTypeRequest(context, url).placeholder(placeHolder)
            .transform(transformation)
            .crossFade()
            .into(view);
}
 
開發者ID:850759383,項目名稱:ZhihuDailyNews,代碼行數:7,代碼來源:ImageLoader.java


注:本文中的com.bumptech.glide.load.resource.bitmap.BitmapTransformation類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。