title: I want to draw a random circle or oval shape on my image taken from camera
body: <p>My question is that I will take an image from camera and it will be sent to an image view in an activity. After that I need to draw a circle or rectangle on the image.it should be a free hand. I mean I want to draw at any size. Then that image should be saved. I tried to put the image to the view but I am unable to draw on it. I am new to android. Can anyone help me out of this?</p>
  
  <pre><code>  //This is camera Intent
  
          camera =(Button)findViewById(R.id.camera_button);
          camera.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  rl_main.setVisibility(View.GONE);
                  rl_image.setVisibility(View.VISIBLE);
  
                  Intent intent =new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
                  fileUri = getOutputMediaFileUri(REQUEST_IMAGE_CAPTURE);
  
                  intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);
                  // start the image capture Intent
                  startActivityForResult(intent, REQUEST_IMAGE_CAPTURE);
  
  
              }
  
  
          });
  
     @Override
      protected void onActivityResult(int requestCode, int resultCode, Intent data) {
          super.onActivityResult(requestCode, resultCode, data);
  
          switch (requestCode) {
              case SPEECH_RECOGNITION_CODE: {
                  if (resultCode == RESULT_OK &amp;&amp; null != data) {
  
                      ArrayList&lt;String&gt; result = data
                              .getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
                      String text = result.get(0);
                      description.setText(text);
                  }
                  break;
              }
  
              case REQUEST_IMAGE_CAPTURE:
              {
                  if (requestCode == REQUEST_IMAGE_CAPTURE &amp;&amp; resultCode == RESULT_OK) {
                      loadimage();
                  }
              }
  
  
          }
  
      }
  
      private void loadimage() {
  
          if (fileUri!=null){
  
              Bitmap myImg = BitmapFactory.decodeFile(fileUri.getPath());
  
              File file = new File(fileUri.getPath());
              BitmapFactory.Options bounds =new BitmapFactory.Options();
              bounds.inSampleSize = 4;
              bounds.inJustDecodeBounds = true;
              String path = file.getPath();
              BitmapFactory.decodeFile(path,bounds);
  
              BitmapFactory.Options opts =new BitmapFactory.Options();
              opts.inSampleSize = 4;
              Bitmap bm = BitmapFactory.decodeFile(path,opts);
              ExifInterface exif =null;
  
              try {
                  exif =new ExifInterface(path);
              } catch (IOException e) {
                  e.printStackTrace();
              }
              String orientString = exif.getAttribute(ExifInterface.TAG_ORIENTATION);
              int orientation = orientString != null ? Integer.parseInt(orientString) :  ExifInterface.ORIENTATION_NORMAL;
  
              int rotationAngle = 0;
              if (orientation == ExifInterface.ORIENTATION_ROTATE_90){
                  rotationAngle = 90;
              }
              if (orientation == ExifInterface.ORIENTATION_ROTATE_180){
                  rotationAngle = 180;
              }
              if (orientation == ExifInterface.ORIENTATION_ROTATE_270){
                  rotationAngle = 270;
              }
  
  
              final Matrix matrix = new Matrix();
              matrix.setRotate(rotationAngle, (float) bm.getWidth() / 2, (float) bm.getHeight() / 2);
              Bitmap rotatedBitmap = Bitmap.createBitmap(bm, 0, 0, bounds.outWidth,bounds.outHeight, matrix, true);
  
  
              /*    Matrix matrix = new Matrix();
                 matrix.postRotate(90);
                  Bitmap rotated = Bitmap.createBitmap(myImg, 0, 0, myImg.getWidth(), myImg.getHeight(),
                          matrix, true);*/
              Bitmap mutableBitmap = rotatedBitmap.copy(Bitmap.Config.ARGB_8888, true);
  
  
              camera_IV.setImageBitmap(mutableBitmap);
  
              DisplayMetrics displaymetrics =new DisplayMetrics();
              getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
              int height1 = displaymetrics.heightPixels;
              int width1 = displaymetrics.widthPixels;
              Log.e("MA", "Height= " + height1 + " " + width1);
              paint = new Paint();
              paint.setStyle(Paint.Style.STROKE);
              paint.setColor(Color.GREEN);
              paint.setStrokeWidth(3);
              //  paint.setTextSize(25);
              paint.setStrokeJoin(Paint.Join.ROUND);
              paint.setStrokeCap(Paint.Cap.ROUND);
              originalBitmap =Bitmap.createScaledBitmap(rotatedBitmap, camera_IV.getWidth(), camera_IV.getHeight(), false);
  
              imageBitmap = originalBitmap.copy(Bitmap.Config.RGB_565, true);
  
              camera_IV.setOnDragListener(new View.OnDragListener() {
                  @Override
                  public boolean onDrag(View view, DragEvent dragEvent) {
                      return false;
                  }
              });
              camera_IV.setOnTouchListener(new View.OnTouchListener() {
  
                  @Override
                  public boolean onTouch(View arg0, MotionEvent event) {
  
  
  
              });
  
  
  
              BitmapFactory.Options myOptions = new BitmapFactory.Options();
              myOptions.inDither = true;
              myOptions.inScaled = false;
              myOptions.inPreferredConfig = Bitmap.Config.ARGB_8888;// important
              myOptions.inPurgeable = true;
  
  
  
              mPaint = new Paint();
              mPaint.setAntiAlias(true);
              mPaint.setDither(true);
              mPaint.setColor(0xFFFF0000);
              mPaint.setStyle(Paint.Style.STROKE);
              mPaint.setStrokeJoin(Paint.Join.ROUND);
              // mPaint.setStrokeCap(Paint.Cap.ROUND);
              mPaint.setStrokeWidth(10);
  
          }
  
  
      }
  </code></pre>
  
  <p>`</p>