I find that DrawBitMap takes 50-60 ms to draw only three raster images, one of which is a rectangle occupying the entire screen, one is a circle, and the other is a path. My bitmaps are created using Canvas.drawPath, drawRect and drawCircle on an empty bitmap with Bitmap.Config as ARGB_8888. I use ARGB_8888 to make the background visible to get a layering effect. I was shocked when I found a time of about 50 ms, since I thought drawBitmap would be a very simple operation. Can someone explain if there is any fundamental mistake that I am making. Below is my code
Create blank bitmaps
Rectangle = Bitmap.createBitmap(320,480,Bitmap.Config.ARGB_8888); Circle = Bitmap.createBitmap(70,70,Bitmap.Config.ARGB_8888); Leaf1 = Bitmap.createBitmap(20,30,Bitmap.Config.ARGB_8888);
Drawing figures on the corresponding bitmap
Canvas c = new Canvas(Rectangle); Paint p = new Paint(); p.setAntiAlias(true); p.setColor(0xff6e8b3e); c.drawRect(0,0,320,480,p); Canvas c = new Canvas(Circle); Paint p = new Paint(); CirclePath = new Path(); p.setAntiAlias(true); p.setColor(0xffcd661d); System.out.println("x = "+x+" y = "+y); CirclePath.addCircle(50,50,10,Path.Direction.CW); c.drawPath(CirclePath,p); Canvas c = new Canvas(Leaf1); Paint paint = new Paint(); Path path = new Path(); paint.setAntiAlias(true); path.moveTo((float)184.37,(float)219.15); path.cubicTo((float)188.32,(float)219.15,(float)192.88,(float)220.44,(float)195.62,(float)223.54); path.cubicTo((float)197.84,(float)226.05,(float)203.2,(float)229.84,(float)198.18,(float)245.98);
Drawing BitMap in OnDraw
canvas.drawBitmap(Rectangle,0,0,p); canvas.translate(x,y);
Now, when I record the time spent on these three drawBitMap, I find that it takes about 50 ms. There is something big in the code. Changing Bitmap.Config to RGB_565 reduces the time to 8 ms, but then the background is not displayed, and I get a black box around the path