Hai bob thanks for your reply.......

I made the change as you said...  *

 Y = (int) (screenH /2) - (arrowH / 2) ;*

But still the same results.

And here is some  screen shot of my results at central position left and 
right....

 
Centre<https://lh3.googleusercontent.com/-gmk0bpPFRaA/UFQTgNViVXI/AAAAAAAAAJk/L8aKeWbyfyY/s1600/centre.jpg>
 
Left<https://lh5.googleusercontent.com/--1s1WMp6JWs/UFQUKYdzHDI/AAAAAAAAAJs/2p77As5VGY0/s1600/left.jpg>
 
Right<https://lh6.googleusercontent.com/-Gopc01ZOM94/UFQUoJ0d76I/AAAAAAAAAJ0/OxShY4rktZ4/s1600/right.jpg>

Thanks......



On Monday, 10 September 2012 18:48:32 UTC+5:30, Haris wrote:
>
> Hai all
>
>  I am trying an application like rotating image with motion sensor....My 
> problem is that the image does not rotate about centre properly....And my 
> angle range is 0 to 90 and 0 to -90..
> And below is my code.....
>
>       public void onDraw(Canvas canvas) {
>         super.onDraw(canvas);
>      Bitmap arrow = 
> BitmapFactory.decodeResource(getResources(),R.drawable.arrow);
>      int arrowW = arrow.getWidth();
>      int arrowH = arrow.getHeight();
>      float scaleWidth = 1;
>      float scaleHeight = 1;
>      int centrex = arrowW/2;
>      int centrey = arrowH/2;
>      int X=108;
>      int Y=100;
>      int angle=0;
>
>        Matrix matrix = new Matrix();
>        matrix.postScale(scaleWidth, scaleHeight);
>
>        matrix.postRotate(angle, X+centrex , Y+centrey );
>        Bitmap resizedBitmap = Bitmap.createBitmap(arrow, 0, 0, 
> arrow.getWidth(), arrow.getHeight(), matrix, true);
>       canvas.save();
>       canvas.drawBitmap(resizedBitmap, X, Y, null);
>       invalidate();
>      }
>
> I am getting the angle values from onCreate method.....Using orientation 
> sensor(roll values)..
> But When I rotate the screen my  image is  rotating but not exactly around 
> the image centre.....
>
> Thanks......
>

-- 
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