Can't seem to disable anti-aliasing in Android

蓝咒 提交于 2020-01-05 07:27:10

问题


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.

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.

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

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.


回答1:


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.

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.



来源:https://stackoverflow.com/questions/13502548/cant-seem-to-disable-anti-aliasing-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!