Recently, I had an Android problem : rotating the image around the center , which was resolved using Unconn.
However, it turns out that the solution โ and how it works โ has much worse performance than RotateAnimation.
What I still have: 1) FrameLayout with two ImageViews, on top of each other 2) SensorEventHandler, which moves the bottom view around according to the measured title. It works if I use RotateAnimation
I wanted to speed it up and smooth the animation a bit, but it failed dramatically. Here is the current solution: 1) SurfaceView with a separate thread controlling the drawing of layers 2) Without executing the code below, the stream can reach 50 frames per second. 3) When using the code below, the frame rate decreases to 5ps or less, so this is no longer something very smooth ...
Here is the code:
mRadar: raster image with the image of a โradarโ downloaded from ressource previously mHeading: current title taken from sensors in degrees mRadarW, mRadarH: The initial width / height of the image determined when creating
Matrix m = new Matrix(); m.setRotate(mHeading, mRadarW/2, mRadarH/2); Bitmap rotated_radar = Bitmap.createBitmap(mRadar, 0, 0, mRadarW, mRadarH, m, true); canvas.drawBitmap(rotated_radar, (mRadarW - rotated_radar.getWidth())/2, (mRadarH - rotated_radar.getHeight())/2, null); canvas.drawBitmap(mRadar, 0, 0, null);
Is it known that Matrix / drawBitmap does not work as well, is it actually worse than RotateAnimation? If itโs not possible to use this: what options could you offer? Although RotateAnimation will now work, I will need to compose a much more complex image before I have to go to RotateAnimation, so I am afraid that I will lose drawBitmap and friends again ...
Oh, I missed CALayers :)