public class GlideBitmapFetcher implements IBitmapFetcher { private Context mContext; public GlideBitmapFetcher(Context context) { mContext = context; } @Override public Bitmap fetchBitmapByFilePath(String path) { Bitmap bmp = null; try { bmp = Glide.with(mContext).asBitmap().load(path).submit().get(); } catch (InterruptedException e) { e.printStackTrace(); } catch (ExecutionException e) { e.printStackTrace(); } return bmp; } @Override public Bitmap fetchBitmapByUrl(String url) { Bitmap bmp = null; try { bmp = Glide.with(mContext).asBitmap().load(url).submit().get(); } catch (InterruptedException e) { e.printStackTrace(); } catch (ExecutionException e) { e.printStackTrace(); } return bmp; } @Override public Bitmap fetchBitmapByBase64(String encoded) { byte[] decode; encoded = encoded.split(",")[1]; decode = Base64.decode(encoded, Base64.DEFAULT); Bitmap bmp = null; try { bmp = Glide.with(mContext).asBitmap().load(decode).submit().get(); } catch (InterruptedException e) { e.printStackTrace(); } catch (ExecutionException e) { e.printStackTrace(); } return bmp; } }
glide获取bitmap(url,file,base64)
最新推荐文章于 2025-04-29 16:57:47 发布