本文介绍了似乎无法在Android中禁用抗锯齿功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Android的新手,我已经完成了一个以像素艺术为特色的游戏。我打算从小像素化的png文件中放大我的图像(图像视图和绘制到画布的位图)。问题是,我似乎无法禁用抗锯齿,无论我尝试什么方法。图像总是模糊不清。
我的所有图片都在一个'drawable'文件夹中。
我在xml的ImageView中尝试了android:antialias =false。

I'm new to Android, and I've finished a game which was meant to feature pixel art. I was going to scale up my images (imageviews and bitmaps drawn to canvas) from small pixelated png files. The thing is, I could not seem to disable anti-aliasing whatever method I tried. The image was always blurred.All my images are in one 'drawable' folder.I tried android:antialias="false" within the ImageView in the xml.

尝试了这里描述的方法:
\
在将位图绘制到画布上时尝试更改绘画(paint.setAntiAlias(false))。

Tried the method described here: http://www.41post.com/4241/programming/android-disabling-anti-aliasing-for-pixel-art\Tried changing the paint (paint.setAntiAlias(false)) when drawing the bitmap onto a canvas.

甚至尝试将ImageView链接到xml位图drawable with antialias =false

And even tried linking the ImageView to a xml bitmap drawable with antialias="false"

我错过了什么吗?最后,我不得不忍着留下一些模糊图像并将大图像作为大图像并且不在xml文件中调整大小。

Am I missing something? In the end I had to just settle with leaving some images blurry and having the big images as big images and not resizing in the xml file.

推荐答案

从中,看起来像 Paint#setFilterBitmap()始终处于启用状态,并且在启用硬件加速时无法禁用。尝试检查您的应用是否正在使用硬件加速。

From the Hardware Acceleration Guide, it looks like Paint#setFilterBitmap() is always enabled and cannot be disabled when hardware acceleration is enabled. Try checking to see if your app is using hardware acceleration.

我在启用使用主机GPU选项时在模拟器中看到了类似的行为,并发现可以通过使用 Paint#setFilterBitmap(true)强制没有抗锯齿行为的设备具有该行为。虽然没有禁用主机GPU选项,但我无法禁用模拟器中的行为。

I've seen similar behavior in the emulator when enabling the "Use host GPU" option, and found that a device that didn't have the anti-aliasing behavior could be forced to have that behavior by using Paint#setFilterBitmap(true). I was not able to disable the behavior in the emulator though without disabling the host GPU option.

这篇关于似乎无法在Android中禁用抗锯齿功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 09:19