I’m trying to make an android game using sprites, (or very pixelated characters, backgrounds etc.). I draw them on the canvas like so…
matrix.preScale(xrat,yrat);
canvas.drawBitmap(img, matrix, null);
Where img is the Bitmap and the xrat and yrat are the scales.
My problem is that when I test, the Bitmap is blurry or anti-aliased, is there a way to prevent this? The rigid-blocky art style of the game will be ruined if the blocks are blurry.
Any (ANY) help appreciated!
Answer
Create a new Paint to use when drawing the bitmaps with the settings:
Paint drawPaint = new Paint(); drawPaint.setAntiAlias(false); drawPaint.setFilterBitmap(false);
Filtering I believe is on by default and will attempt to smooth out bitmaps when drawn scaled up.