Draw smoothly scaled bitmaps on Canvas
Both Paint paint = new Paint(Paint.FILTER_BITMAP_FLAG);
or paint.setFilterBitmap(true);
worked for me but be very careful, on my game it cut down the FPS from 30FPS
to 17FPS
only. So if it is a mission critical drawing like in a game you better scale the image at loading time. Which I did in the following manner:
public Bitmap getImage (int id, int width, int height) {
Bitmap bmp = BitmapFactory.decodeResource( getResources(), id );
Bitmap img = Bitmap.createScaledBitmap( bmp, width, height, true );
bmp.recycle();
return img;
}
Try this:
Paint paint = new Paint();
paint.setAntiAlias(true);
paint.setFilterBitmap(true);
paint.setDither(true);
canvas.drawBitmap(bitmap, x, y, paint);
Have you tried creating a Paint
object, calling setAntiAlias(true)
on it and passing it to the drawBitmap
method as the 4th parameter? If this does not work I guess you should scale down the drawBitmap
call instead of scaling the Canvas, e.g. by using drawBitmap(Bitmap bitmap, Rect src, Rect dst, Paint paint)
.