Disable anti-aliasing on Android Imageview

ساخت وبلاگ

I'm showing 96x96 pixel art sprites in imageviews and can't get it to display without applying anti-aliasing, which ruins the sharp edge of the sprites.

How can this be done? I've tried the following methods I've picked up from around the internet, but none work.

METHOD ONE

creating an xml resource file with a bitmap, and setting the anti-alias flag to false. Didn't work at all

METHOD TWO

creating a bitmap object from the resource, and setting the anti-alias flag to false. Didn't work at all.

 Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.dryad_back_large); BitmapDrawable drawable = new BitmapDrawable(getResources(), bitmap); drawable.setAntiAlias(false); playerMonsterImageView.setImageDrawable(drawable);

METHOD THREE Using sprites which are large enough so that they will never need to be scaled down, only up (512x512 worked for me)

So this third method WORKS, but it seems really ham-fisted, and I was hoping there was a better way of going about this.

Maybe there's something other than anti-aliasing going on here that I've missed?

back soft...
ما را در سایت back soft دنبال می کنید

برچسب : نویسنده : استخدام کار backsoft بازدید : 228 تاريخ : دوشنبه 13 شهريور 1396 ساعت: 16:28