Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

兼容BASE64图片内容 #159

Open
RavenGluttonous opened this issue Oct 21, 2022 · 0 comments
Open

兼容BASE64图片内容 #159

RavenGluttonous opened this issue Oct 21, 2022 · 0 comments

Comments

@RavenGluttonous
Copy link

想要兼容BASE64需要改动这两个文件,Html.class,以及AreImageGetter.class。

在AreImageGetter.class文件找到getDrawable(),加入判断:
else if (source.startsWith("data:image")){
// data:image/jpg;base64
AreUrlDrawable areUrlDrawable = new AreUrlDrawable(mContext);
BitmapTarget bitmapTarget = new BitmapTarget(areUrlDrawable, mTextView);
try {
//ImageUtil.INSTANCE.str2Bitmap(source);
//此方法为转bitmap方法,source为base64字符串
Bitmap s = ImageUtil.INSTANCE.str2Bitmap(source);
sGlideRequests.asBitmap().load(s).into(bitmapTarget);
return areUrlDrawable;
} catch (Exception ignored) {
ignored.printStackTrace();
}
}

在Html.class文件找到startImg(),加入判断:
else if (src.startsWith("data:image")){
imageSpan = new AreImageSpan(sContext, d, src);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant