Hi:

Thanks your reply.
Your suggestion is good, I've optimized these in my real code. The
above is just simple example.
The source bitmap is preloaded before, but for solution 1, the
rotation bitmap always be created as need. This is performance key in
my codes.
I don't want to create it every time.
For solution 2, the creating step is avoid, but the rotation bitmap's
quality is not good as solution 1, it is distorted. this is also not I
wanted.
So I hope someone can give another solution to solve my problem.
I'm not sure the GL surfaceview is better or not. But I don't want to
use GL in my app since there is no any 3D requirement.
Thanks a lot!

On Sep 24, 7:50 pm, Andreas <andreas.k...@googlemail.com> wrote:
> 1) You should avoid to creat a new Matrix every time you call the draw
> funktion. You can to this by passing a static Matrix Reference to your
> draw function.
>
> 2) Creating bitmaps on a draw Method is not good performance wise.
> Preload the Images you want up in front.
>
> 3) On Canvas drawing you have a special draw Method you should use in
> combination with a Bitmap and a Matrix:
>
> void android.graphics.Canvas.drawBitmap(Bitmap bitmap, Matrix matrix,
> Paint paint)
>
> 4) The Coords of your Bitmap should be set in the Matrix by calling:
>
> boolean android.graphics.Matrix.postTranslate(float dx, float dy)
> boolean android.graphics.Matrix.postRotate(float degrees, float px,
> float py)
>
> Hope this helps
>
> Greetings
>
> On 24 Sep., 13:22, chaozh <chao...@gmail.com> wrote:
>
>
>
>
>
>
>
> > As we know, we can rotate a bitmap through 2 ways.
> > The 1st way is:
> > Matrix mt = new Matrix();
> > mt.postRotate(degree);
> > Bitmap bitmap = CreateBitmap(src, 0, 0, w, h, mt, true);
> > canvs.drawBitmap(bitmap, 0, 0, paint);
>
> > In this way, we always need create new bitmap for every rotation, it
> > is not good way for high performance game or app.
>
> > The 2nd way is:
> > canvas.save();
> > canvas.rotate(degree);
> > canvas.drawBitmap(bitmap, 0, 0, paint);
> > canvas.restore();
>
> > In this way, we avoid creating new bitmap frequently, but the rotation
> > bitmap is distortion, the bitmap quality is worse than first way.
>
> > So, Is there 3rd way to rotate bitmap with high performance and good
> > quality?
> > Your any comments are really appreciated!

-- 
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+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to