I have a canvas which does behave not the way I'd expect it to.
Here's my problem: My two Bitmaps are 700kb and 1.4mb in size.
Here I load my bitmaps
mBitmap = BitmapFactory.decodeResource(mContext.getResources(),
drawable, mOptions);
Afterwards, I rescale it to the size I need it:
mBitmap = Bitmap.createScaledBitmap(mBitmap, width, height, false);
Then I draw it:
canvas.drawBitmap(mBitmap, x, y, myPaint);
The performance overall is really bad, I'm not sure why?
And here is the strange behavior: When I load the Bitmaps with low quality (RGB_565), I get around 12(?!) FPS and it's reaally laggy. When I load them with higher quality (ARGB_8888) though, I get around 25 FPS (still too less).
In my manifest I set android:hardwareAccelerated="true", but this does not do any difference either, CPU usage is always the same.
The images are placed in the drawable-nodpi folder.
I thought, maybe my images are too big, I tried to optimize them and made them half the size, and then again the performance drops.
Also, the performance is worse on my tablet, which has higher hardware specs though, so this seems to be a problem with the way I load/scale the images?
What can I do to get better performance?
Thanks in advance!
createScaledBitmap
, usedrawBitmap
withMatrix
param instead – pskink