Android Canvas.DrawBitmap 没有模糊/抗锯齿?

发布于 2024-10-10 01:40:47 字数 294 浏览 0 评论 0原文

我正在尝试使用精灵(或非常像素化的角色、背景等)制作一个Android游戏。我像这样在画布上绘制它们...

matrix.preScale(xrat,yrat);

canvas.drawBitmap(img, matrix, null);

其中 img 是位图xrat 和 yrat 是音阶。

我的问题是,当我测试时,位图模糊或抗锯齿,有办法防止这种情况吗?如果方块模糊的话,游戏僵硬的块状美术风格就会被破坏。

任何(任何)帮助表示赞赏!

I'm trying to make an android game using sprites, (or very pixelated characters, backgrounds etc.). I draw them on the canvas like so...

matrix.preScale(xrat,yrat);

canvas.drawBitmap(img, matrix, null);

Where img is the Bitmap and the xrat and yrat are the scales.

My problem is that when I test, the Bitmap is blurry or anti-aliased, is there a way to prevent this? The rigid-blocky art style of the game will be ruined if the blocks are blurry.

Any (ANY) help appreciated!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浴红衣 2024-10-17 01:40:47

创建一个新的画图,以便在使用以下设置绘制位图时使用:

Paint drawPaint = new Paint();
drawPaint.setAntiAlias(false);
drawPaint.setFilterBitmap(false);

过滤我相信默认情况下处于启用状态,并且在按比例绘制时会尝试平滑位图。

Create a new Paint to use when drawing the bitmaps with the settings:

Paint drawPaint = new Paint();
drawPaint.setAntiAlias(false);
drawPaint.setFilterBitmap(false);

Filtering I believe is on by default and will attempt to smooth out bitmaps when drawn scaled up.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文