cancelAnimationFrame no limpia mi canvas

Dentro de este canvas

<canvas id="canvas" class="canvas" width="300" height="300"></canvas> 

Tenga esta función

var estado = false; var canvas = document.getElementById('canvas'); var ctx = canvas.getContext("2d"); function frame(){   actualizar();   coliciones();   dibujar();   bucle = requestAnimationFrame(frame);  }  function startStop(){   if (!estado) {     estado = true;     frame();       console.log('game init :'+estado);   }else {     estado = false;     cancelAnimationFrame(bucle);     console.log('game estatus :'+estado);   } 

pero cancelAnimationFrame no borra o no hace un clear a mi canvas. Pero si estoy recibiendo los log’s de mi consola, alguien podrìa decime si hago algo mal?

I want to overlay two bitmaps on a canvas and produce a single bitmap. But the second image is much smaller than its original size

I want to overlay two bitmaps on a canvas and produce a single bitmap in android. but second image is much small as its original size. But second image or small image is looking more small on canvas as compare to original bitmap image. I have implemented following code to overlay image and give the left and top align to second image.

public Bitmap overlay(Bitmap bmp1, final Bitmap bmp2, int x, int y) { final Bitmap bmOverlay = Bitmap.createBitmap(bmp1.getWidth(), bmp1.getHeight(), bmp1.getConfig()); Canvas canvas = new Canvas(bmOverlay); canvas.drawBitmap(bmp1, 0f, 0f, null); float density = PdfActivity.this.getResources().getDisplayMetrics().density; canvas.drawBitmap(bmp2, x * density, y * density, null); return bmOverlay;} 

In above code bmp2 is used to draw the second image or small image ,while bmp1 is big image draw on canvas. Please have a look at both screens:- Below is showing image after drawing on canvas.

enter image description here

Please help me to find out what is the issue so image is drawing in small format.

Below is showing original image inside the rectangle after drawing on image view.

enter image description here