55 lines
1.8 KiB
Java
55 lines
1.8 KiB
Java
package com.ubt.jimu.utils;
|
|
|
|
import android.content.Context;
|
|
import android.content.res.Resources;
|
|
import android.graphics.Bitmap;
|
|
import android.graphics.BitmapShader;
|
|
import android.graphics.Canvas;
|
|
import android.graphics.Paint;
|
|
import android.graphics.RectF;
|
|
import android.graphics.Shader;
|
|
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
|
|
import com.bumptech.glide.load.resource.bitmap.BitmapTransformation;
|
|
import java.security.MessageDigest;
|
|
|
|
/* loaded from: classes2.dex */
|
|
public class GlideRoundTransform extends BitmapTransformation {
|
|
private static float b;
|
|
|
|
public GlideRoundTransform(Context context) {
|
|
this(context, 0.0f);
|
|
}
|
|
|
|
@Override // com.bumptech.glide.load.resource.bitmap.BitmapTransformation
|
|
public Bitmap a(BitmapPool bitmapPool, Bitmap bitmap, int i, int i2) {
|
|
return a(bitmapPool, bitmap);
|
|
}
|
|
|
|
@Override // com.bumptech.glide.load.Key
|
|
public void a(MessageDigest messageDigest) {
|
|
}
|
|
|
|
public GlideRoundTransform(Context context, float f) {
|
|
b = Resources.getSystem().getDisplayMetrics().density * f;
|
|
}
|
|
|
|
private static Bitmap a(BitmapPool bitmapPool, Bitmap bitmap) {
|
|
if (bitmap == null) {
|
|
return null;
|
|
}
|
|
Bitmap a = bitmapPool.a(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888);
|
|
if (a == null) {
|
|
a = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888);
|
|
}
|
|
Canvas canvas = new Canvas(a);
|
|
Paint paint = new Paint();
|
|
Shader.TileMode tileMode = Shader.TileMode.CLAMP;
|
|
paint.setShader(new BitmapShader(bitmap, tileMode, tileMode));
|
|
paint.setAntiAlias(true);
|
|
RectF rectF = new RectF(0.0f, 0.0f, bitmap.getWidth(), bitmap.getHeight());
|
|
float f = b;
|
|
canvas.drawRoundRect(rectF, f, f, paint);
|
|
return a;
|
|
}
|
|
}
|