Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid: canvas.drawBitmap performance issue
    primarykey
    data
    text
    <p>I had an issue lately <a href="https://stackoverflow.com/questions/5182861/android-rotation-of-image-around-the-center">Android: Rotation of image around the center</a> which was solved by the help of Unconn.</p> <p>However, it turns out, that the solution - as well as it is working - does have a much worse performance, than the RotateAnimation stuff.</p> <p>What I have so far: 1) FrameLayout with two ImageViews, on on top of each other 2) SensorEventHandler, which moves the lower view around according to the heading measured. This works acceptable if I use RotateAnimation</p> <p>I wanted to speed it up and to smooth the animation a bit, but failed dramatically. Here is the current solution: 1) SurfaceView with separate thread, controlling the drawing of the layers 2) Without performing the code below, the thread could reach around 50 fps. 3) With the code below the frame rate goes down to 5ps and less, so it is no longer something very smooth...</p> <p>Here is the code:</p> <p>mRadar: Bitmap showing a "radar", loaded from ressource earlier mHeading: The current heading taken from the sensors in degrees mRadarW,mRadarH: Initial width/height of the image, determined on creation</p> <pre><code> 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); </code></pre> <p>Is the Matrix/drawBitmap stuff known to perform not that good, in fact worse than the RotateAnimation? If there is no chance to use this: What options could you propose? Although the RotateAnimation would work for now, I would need to compose a much more complex image, <em>before</em> I would have to go for RotateAnimation, so I fear, I will loose again with drawBitmap and friends...</p> <p>Oh, I miss CALayers :)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload