Wednesday, March 16, 2011

[android-developers] Re: rotating a bitmap

don't divide by two, multiply by .5 . multiplication is much faster
than division.

On Mar 15, 5:38 pm, Nicholas Johnson <metthejohn...@gmail.com> wrote:
> A couple things:
>
> This might help your pivot point that you have: instead of converting to
> float after the division, try doing it before the division. Like this:
> ((float)mBitmap.getHeight())/2f   -- I believe you are losing some accuracy
> by doing it the other way around. As in (float)(7/2) would equal 3, not 3.5.
>
> Secondly, if you're end goal is to just draw a rotated image to the canvas
> during the onDraw call (which I suspect that it is), then there's no reason
> to create a second bitmap. Something like this should work:
>
>    float px = ((float)mBitmap.getHeight())/2f;
>    float py = ((float)mBitmap.getWidth())/2f;
>    m.setRotate(mRotation, px, py);
>    canvas.drawBitmap(mBitmap, m, null);
>
> Also, if you're not doing anything funky with your paint (like ColorFilters,
> etc.), then just leave it null.
>
> --Nick

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate