本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例10: getTransformation
import com.bumptech.glide.load.resource.bitmap.BitmapTransformation; //导入依赖的package包/类
public BitmapTransformation getTransformation() {
return transformation;
}
示例11: getTransformation
import com.bumptech.glide.load.resource.bitmap.BitmapTransformation; //导入依赖的package包/类
public BitmapTransformation[] getTransformation() {
return transformation;
}
示例12: getTransformation
import com.bumptech.glide.load.resource.bitmap.BitmapTransformation; //导入依赖的package包/类
/**
* glide用它来改变图形的形状
*/
public BitmapTransformation getTransformation() {
return transformation;
}
示例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);
}
示例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);
}
示例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);
}