Hi,
I'm porting an iOS app to Android. The app uses a compass view in
order to show the current heading/bearing. The compass rotation
(bitmap) works great in iOS, using CALayer CoreAnimation. But I'm
appearing difficulties under Android.

Basically I'm getting the sensor information and I'm sure to have at
least the heading (with reference to magnetic north) correctly and
with a reasonable frequency. But if I try to apply the heading value
to a bitmap in order to rotate the image, the framerate is 1 per
minute and the drawing is... strange. Here is the code, which is used
if a new heading value is available (heading in degrees, iv is an
ImageView) :

                Bitmap bmp = BitmapFactory.decodeResource(getResources(),
R.drawable.compass_background);
                int w = bmp.getWidth();
                int h = bmp.getHeight();
                Matrix mtx = new Matrix();
                mtx.postRotate(-heading);
                Bitmap rotatedBMP = Bitmap.createBitmap(bmp, 0, 0, w, h, mtx, 
true);
                BitmapDrawable bmd = new BitmapDrawable(rotatedBMP);
                iv.setImageDrawable(bmd);

It seems, this is not the way to go. What other opportunities do I
have?
Kind regards

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