animation - in android canvas why the matrix is too slow and sluggish -


i wanted rotate image in android app around center pivot , following code..

package com.android.maddy.canvs;  import android.content.context; import android.graphics.bitmap; import android.graphics.bitmapfactory; import android.graphics.canvas; import android.graphics.color; import android.graphics.matrix; import android.graphics.paint; import android.graphics.rect; import android.graphics.drawable.drawable;  import android.os.handler; import android.provider.openablecolumns; import android.view.motionevent; import android.view.view;  public class drawview extends view {     private drawable d[]=new drawable[2];      boolean done=false;     handler h;     float th=0;     public drawview(context context) {         super(context);         d[0]=context.getresources().getdrawable(r.drawable.appdatabk);         d[1]=context.getresources().getdrawable(r.drawable.appdata);         h = new handler();     }      runnable r =new runnable() {          @override         public void run() {             // todo auto-generated method stub              th++;             invalidate();         }     };      public void ondraw(canvas c){         super.ondraw(c);         paint p =new paint();         rect imagebounds = c.getclipbounds();  // background         d[0].setbounds(imagebounds);          d[0].draw(c);          matrix m = new matrix();         m.settranslate(getwidth()/2, getheight()/2);                 m.prerotate(th,43,160); //my image 86x320          bitmap b =     bitmapfactory.decoderesource(getresources(),r.drawable.appdata);//image of bottle want rotate         c.drawbitmap(b,m, p);         p.setcolor(color.blue);         h.postdelayed(r,1);       }        } 

what happens here matrix calculation slows down speed of rotation , gives ugly sluggish output.. if have method rotate image around center pivot without using matrix or there other method please me out.. removed matrix , checked rotation in drawbitmap() function using x+r*(math.cos(th)) , y+r*(math.sin(th)) works fine image doesn't rotate around pivot.. please help.. thanks

matrix quite fast. slowing down create classes , load bitmaps in ondraw. create paint , matrix 1 in class, , load bitmap once


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -