title: Can't draw canvas into android bitmap
body: <p>Hi guys I'm struggling with bitmaps and canvas. What I'm trying to do is to take a photo with the camera and then allow the user to create two rectangles (by sliding the finger) and mark them in the image (the rectangles should be marked until a button is pressed, the photo is not saved, it is always on memory). So based in a camera example I've made a layout with a SurfaceView to contain the camera preview, and then I've added the code to draw the rectangles in the onPictureTaken method. I've searched some examples about how to implement it but of course is not working. So far, I have this code (inside of onPictureTaken):</p>
  
  <pre><code>        final Bitmap bitmapPicture = BitmapFactory.decodeByteArray(arg0, 0,
                  arg0.length);
          surfaceView.setOnTouchListener(new OnTouchListener() {
              @Override
              public boolean onTouch(View arg0, MotionEvent arg1) {
                  switch (arg1.getAction()) {
                  case MotionEvent.ACTION_DOWN:
                      if (source coordinates of rect1 are not set) {
                          setSourceCoordinatesForRect1FromArg1();
                      } else {
                          setSourceCoordinatesForRect2FromArg1();
                      }
                      break;
                  case MotionEvent.ACTION_UP:
                      if (end coordinates of rect1 are not set) {
                          setEndCoordinatesForRect1FromArg1();
                      } else {
                          setEndCoordinatesForRect2FromArg1();
                      }
                      break;
                  default:
                      break;
                  }
                  if (coordinates for rect1 are set) {
                      Paint paint = new Paint();
                      Bitmap bmOverlay = Bitmap.createBitmap(bitmapPicture.getWidth(), bitmapPicture.getHeight(), bitmapPicture.getConfig());
                      Canvas canvas = new Canvas(bmOverlay);
                      paint.setColor(Color.GREEN);
                      paint.setStrokeWidth(3);
                      canvas.drawRect(/*all of my source coordinates*/, paint);
                  } else {
                      if (coordinates for rect2 are set) {
                          Paint paint = new Paint();
                          Bitmap bmOverlay = Bitmap.createBitmap(bitmapPicture.getWidth(), bitmapPicture.getHeight(), bitmapPicture.getConfig());
                          Canvas canvas = new Canvas(bmOverlay);
                          paint.setColor(Color.YELLOW);
                          paint.setStrokeWidth(3);
                          canvas.drawRect(/*all of my end coordinates*/, paint);
                      }
                  }
                  return true;
              }
          });
  </code></pre>
  
  <p>I don't have any exception, but the rectangles are not drawn, so I'll really appreciate if someone can tell me what I'm doing wrong. Also, for my particular scenario, would be suitable to use GestureDetector instead of create a custom OnTouchListener?
  Thanks in advance.</p>