三星设备上缩放画布drawBitmap上的模糊像素画 [英] Blurry pixel paint on scaled canvas drawBitmap on Samsung devices

查看:95
本文介绍了三星设备上缩放画布drawBitmap上的模糊像素画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

某些用户在Samsung设备上遇到像素模糊的问题.我没有要检查的三星设备,但是我的手机没有问题.

Some users encountered blurry pixels issue on Samsung devices. I don't have any Samsung device to check, but there is no problems with phones I have.

我无法理解三星的不同之处以及为什么其他设备没有问题!如果有人可以帮助我理解,那就太好了!

I can't understand what is different on Samsung and why there is no issue with other devices! It will be very nice if someone could help me to understand!

谢谢!

它在三星上的外观

我的代码:

protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);

    canvas.save();
    canvas.translate(imagePosition.getX(), imagePosition.getY());
    canvas.scale(mScaleFactor, mScaleFactor);

    boolean hasBackground = backgroundImage != null;

    if (hasBackground) {

        canvas.drawBitmap(backgroundImage, 0, 0, backgroundPaint);

        if (currentMode != ColoringModeEnum.NONE && activity.getAppSettings().highlightActiveSquares) {
            canvas.drawBitmap(hintBitmap, 0, 0, paint);
        }
    }

    canvas.drawBitmap(coloringBitmap, 0, 0, paint);
    canvas.restore();
}


private final Paint paint = new Paint();

推荐答案

您的位图看起来已过滤.要解决此问题,您可以致电:

Your bitmap looks filtered. To fix this, you can call:

backgroundPaint.setFilterBitmap(false)

问题就变成了,为什么它似乎只在三星设备上做到这一点?显然,应用程序程序员必须能够预测其 Paint 对象处于哪种状态,否则他们的应用程序将崩溃(就像您的应用程序一样).

The question then becomes, why does it only appear to do this on Samsung devices? Obviously, app programmers must be able to predict which state their Paint objects are in, otherwise their apps will break (as yours did).

因此,我在测试实验室中使用了一些设备.似乎在API 29上更改了默认的 isFilterBitmap()设置( FILTER_BITMAP_FLAG ),尽管我无法在源代码中找到它(如果有人可以找到它,或有更多的见解,请添加评论,或提出修改建议!)

So, I ran this past a few devices in my test lab. It appears that the default isFilterBitmap() setting (FILTER_BITMAP_FLAG) changed on API 29, although I'm unable to find it in the source code (if anyone can find it, or has more insight, please add a comment, or suggest an edit!)

Device                API level     isFilterBitmap() default
---------------------------------------------------------------------
Pixel 3 XL            29            true
Pixel 2 XL emulator   29            true
Pixel 2 XL emulator   28            false
Pixel 2 emulator      26            false
Samsung S6            25            false
Samsung S4            21            false
Droid RAZR            16            false

这篇关于三星设备上缩放画布drawBitmap上的模糊像素画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆