Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: drawing bitmaps with sub-pixel coordinates

Tags:

android

bitmap

I've just noticed that despite Canvas.drawBitmap() taking float coordinates (some variants, at least), it performs no sub-pixel anti-aliasing when blitting. That is, the bitmap is always drawn at exact integer coordinates (in my code I use no scaling, canvas matrix is identity, done paint.setFilterBitmap(true)).

Can someone confirm this observation? If this is not supported, are there any known plans to include the anti-aliasing blitting feature?

like image 431
Code Painters Avatar asked Jan 23 '26 13:01

Code Painters


1 Answers

According to Romain Guy in a similar Google group question:

bitmaps (and other primitives) are always drawn pixel-aligned if the current transform is only a translation. Any other transform will perform sub-pixel positioning.

So an easy solution is

Canvas.scale(1.00001f, 1.00001f);
like image 154
bkDJ Avatar answered Jan 25 '26 02:01

bkDJ