Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Canvas antialiasing with hardware acceleration (Android API 11 and Later)

I have a simple bitmap that I draw within a canvas & that I rotate using a matrix.

The problem I bump into is that using hardware acceleration the edges are not anti-aliased when rotated (this is working perfectly with Hardware acceleration turning off). And of course things like “setDrawFilter” are useless as they are ignored when hardware acceleration is turned on!

canvas.setDrawFilter(new PaintFlagsDrawFilter(1, Paint.ANTI_ALIAS_FLAG));

Am I missing something or is it just a limitation of the hardware rendering method ? Is there any alternative?

like image 709
VeV Avatar asked Mar 16 '12 00:03

VeV


1 Answers

Setting the antialias flag on the paint would not help anyway. To get antialiased borders on bitmap when rotating them you should add a 1px transparent border around them.

like image 135
Romain Guy Avatar answered Sep 30 '22 05:09

Romain Guy