I am trying to load a Bitmap with the Glide library but there is no method to load it and in the documentation I did not find it either.
I've been looking for more sites like English EO and I found several posts but I did not get to understand well what they do. Let's see if you can help me.
I put you in situation: I need to load a Bitmap because the images I want to load in the ImageView I modify them to round them and put them as avatar and of course, when they are modified they remain as bitmap and I do not want to save them modified in the device.
All this is in a RecyclerView and I had planned to do it with Glide because if I do it normally with: ImageView.setImageBitmap()
the RecyclerView is a bit lagged.
If someone has a solution other than to do it with Glide, it is also heard ^^
EDITED !!
This is what I do to assign the image and what I would like to change and do it with Glide
Bitmap bmp = BitmapFactory.decodeFile(ruta_imagen);
if (bmp != null) {
viewHolder.imageAvatar.setImageBitmap(UtilidadesImagenes.getCircleBitmap(bmp);
}
This is the ViewHolder
public class ViewHolder extends RecyclerView.ViewHolder{
public ImageView imageAvatar;
public ViewHolder(View v) {
super(v);
imageAvatar = (ImageView) v.findViewById(R.id.ivAvatar);
}
}
public static Bitmap getCircleBitmap(Bitmap bitmap) {
if(bitmap!=null){
final Bitmap output = Bitmap.createBitmap(bitmap.getWidth(),
bitmap.getHeight(), Bitmap.Config.ARGB_8888);
final Canvas canvas = new Canvas(output);
final int color = Color.RED;
final Paint paint = new Paint();
final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
final RectF rectF = new RectF(rect);
paint.setAntiAlias(true);
canvas.drawARGB(0, 0, 0, 0);
paint.setColor(color);
canvas.drawOval(rectF, paint);
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
canvas.drawBitmap(bitmap, rect, rect, paint);
bitmap.recycle();
return output;
}else{
return null;
}
}
The images that are loaded sometimes reach the 200KB that is when it begins to stay lagueado