android - Grainy Markers with rotation in GoogleMaps -
i've create maps images using code:
icon_pin = bitmapfactory.decoderesource(getapplicationcontext().getresources(), r.drawable.arrow); int w = icon_pin.getwidth(); int h = icon_pin.getheight(); bitmap.config conf = bitmap.config.argb_8888; bitmap bmp = bitmap.createbitmap(w, h, conf); final float centerx = w / 2.0f; final float centery = h / 2.0f; canvas canvas = new canvas(bmp); canvas.rotate(m.getdirection(), centerx, centery); canvas.drawbitmap(icon_pin, new matrix(), null);
but when rotated image, result grainy (like green arrow in example: http://img837.imageshack.us/img837/4624/screenshot2013052111381.png)
i've wrong something? it's possibile bettering definition?
it looks need draw anti-aliasing enabled. in line:
canvas.drawbitmap(icon_pin, new matrix(), null);
you can specify paint
object use drawing. above, use null
. can add these lines before call canvas.drawbitmap()
:
paint mypaint = new paint(paint.anti_alias_flag); mypaint.setfilterbitmap(true);
then change last line to:
canvas.drawbitmap(icon_pin, new matrix(), mypaint);
this code creates new paint
object anti-aliasing enabled, take out jagged edges on markers.
note: can use paint
apply colors, alpha shading , other cool effects drawing. see android documentation here.
Comments
Post a Comment