2

I am trying to scale DOWN a high resolution .png bitmap on my SurfaceView canvas like so:

Bitmap player = BitmapFactory.decodeResource(getResources(), R.drawable.player);
Paint paint;
paint.setAntiAlias(true);
paint.setDither(true);
paint.setFilterBitmap(true);
paint.setFlags(Paint.ANTI_ALIAS_FLAG);
//then in onDraw:
canvas.drawBitmap(player, null, frame, paint);

The problem is that the antialiasing works perfectly when I use a View, but it fails to work when I use a SurfaceView, and the quality looks horrible. I've tried everything. Some guy even posted this question 3 years ago on various sites (even here) and there was no resolution. Does anyone have any ideas?

Here is the original question the guy posted: Drawing scaled bitmaps on a SurfaceView -- no antialiasing

Community
  • 1
  • 1
user1951536
  • 23
  • 1
  • 2
  • Guess this doesn't help much but calling setFlags(ANTI_ALIAS_FLAG) will clear dither and filter bitmap flags set previously. Maybe comparing Canvas objects between View and SurfaceView you draw into gives best results though. Ie. are both HW accelerated etc. – harism Jun 25 '14 at 23:18
  • Yeah apparently SurfaceView can't be HW accelerated so I guess that's the problem. It's a nightmare developing for android - everything I try there's new problems. It's taking me 2+ weeks to develop a game for android which took me 2 days to develop for iOS (with no prior iOS experience). – user1951536 Jun 26 '14 at 11:09

0 Answers0