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

Software rendering doesn't support hardware bitmaps #41

Closed
w576258809 opened this issue Sep 17, 2019 · 5 comments
Closed

Software rendering doesn't support hardware bitmaps #41

w576258809 opened this issue Sep 17, 2019 · 5 comments

Comments

@w576258809
Copy link

w576258809 commented Sep 17, 2019

java.lang.IllegalArgumentException: Software rendering doesn't support hardware bitmaps
at android.graphics.BaseCanvas.onHwBitmapInSwMode(BaseCanvas.java:550)
at android.graphics.BaseCanvas.throwIfHwBitmapInSwMode(BaseCanvas.java:557)
at android.graphics.BaseCanvas.throwIfCannotDraw(BaseCanvas.java:69)
at android.graphics.BaseCanvas.drawBitmap(BaseCanvas.java:127)
at android.graphics.Canvas.drawBitmap(Canvas.java:1504)
at android.graphics.drawable.BitmapDrawable.draw(BitmapDrawable.java:545)
at com.ruffian.library.widget.helper.RImageViewHelper.drawBitmapSrc(RImageViewHelper.java:351)
at com.ruffian.library.widget.helper.RImageViewHelper.drawBitmap(RImageViewHelper.java:243)
at com.ruffian.library.widget.helper.RImageViewHelper.onDraw(RImageViewHelper.java:209)
at com.ruffian.library.widget.RImageView.onDraw(RImageView.java:34)

米8 crash
设置android:scaleType="fitXY" 引起的
设置centerCrop无问题

@RuffianZhong
Copy link
Owner

@w576258809
运行demo出错的吗?还是使用Glide加载图片出错?无法复现这个bug,可以提供多一点信息吗?

@w576258809
Copy link
Author

w576258809 commented Sep 17, 2019

<com.ruffian.library.widget.RImageView
android:id="@+id/mIvEvaluateImg"
android:layout_width="@dimen/x222"
android:layout_height="@dimen/x222"
android:scaleType="centerCrop"
app:corner_radius="@dimen/x15" />
正常使用
RImageView mIvEvaluateImg = helper.getView(R.id.mIvEvaluateImg);
GlideUtils.loadNormal(mContext, item, mIvEvaluateImg);
public static void loadNormal(Context mContext, String path, ImageView mImageView) {
Glide.with(mContext)
.load(path)
.apply(getDefaultNoCenterOptions())
.into(mImageView);
}
public static RequestOptions getDefaultNoCenterOptions() {
RequestOptions options = new RequestOptions();
options.placeholder(R.drawable.pro_placeholder)
.error(R.drawable.pro_placeholder);
return options;
}
问题在.into(mImageView);

public static void loadRImageView(Context mContext, String path, final RImageView mImageView) {
SimpleTarget simpleTarget = new SimpleTarget() {
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)
@OverRide
public void onResourceReady(Drawable resource, Transition<? super Drawable> transition) {
mImageView.setBackground(resource);
}
};
Glide.with(mContext)
.load(path)
.into(simpleTarget);
}
这样写设置fitXY没有问题

@RuffianZhong
Copy link
Owner

@w576258809 你Glide是什么版本呢?会不会是Glide引起的问题?我查了一下有资料显示是Glide引起的报错,暂时还不能确定

@w576258809
Copy link
Author

w576258809 commented Sep 17, 2019

@w576258809 你Glide是什么版本呢?会不会是Glide引起的问题?我查了一下有资料显示是Glide引起的报错,暂时还不能确定
api 'com.github.bumptech.glide:glide:4.6.1'
Android6.0.1无此问题,米8是9.0,米6是8.0

@RuffianZhong
Copy link
Owner

@w576258809
基本上确认是因为使用硬件位图导致的问题。
Glide 参考文档:http://bumptech.github.io/glide/doc/hardwarebitmaps.html
使用Glide时默认是开启的,你可以禁用它。使用: disallowHardwareConfig()

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

2 participants