title: Drawing Oval on canvas with PAINT object in Android
body: <p>In the following code, I'm trying to draw an oval which be enlarged with time.</p>
  
  <pre><code>Bitmap currBitmap = null;
  Canvas currCanvas = null;
  
  //Config Paint Case2
  final Paint currPaint = new Paint();
  List BlocksList = null;
  boolean bSet = false;
  
  public void DrawOval(Bitmap src, int nRadiusprct) 
  {
      // image size
      int width = src.getWidth();
      int height = src.getHeight();
  
      //create bitmap output
      if(currBitmap  == null)
          currBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
  
      // set canvas for painting
      if(currCanvas == null)
      {
          currCanvas = new Canvas(currBitmap);
          currCanvas.drawARGB(0, 0, 0, 0);
          MainActivity.imgMain.setImageBitmap(currBitmap);
      }
  
      // config paint Case1
      /*final Paint currPaint = new Paint();
      currPaint.setAntiAlias(true);
      currPaint.setColor(Color.BLACK);*/
  
      // config paint Case2
      if(!bSet)
      {
          currPaint.setAntiAlias(true);
          currPaint.setColor(Color.BLACK);
          // create Xfer mode
           currPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
          bSet = true;
      }
  
      // config rectangle for embedding
      int nMidWidth = width/2;
      int nMidHeight = height/2;
      float fPercent = (nRadiusprct / 100.0f);
  
      float fLeft = nMidWidth * (1 - fPercent);  
      float fRight = nMidWidth * (1 + fPercent);
      float fTop = nMidHeight * (1 - fPercent);
      float fBottom = nMidHeight * (1 + fPercent);
  
      final Rect rect = new Rect(0, 0, width, height);
      final RectF rectF = new RectF(fLeft, fTop, fRight, fBottom);
  
      currCanvas.drawOval(rectF, currPaint);
  
      // create Xfer mode, Config Paint Case1
      //currPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
  
      currCanvas.drawBitmap(src, rect, rect, currPaint);
  
      MainActivity.imgMain.invalidate();
  }
  </code></pre>
  
  <p>Now, As you can see write a comment "Config Paint Case1" or "Config Paint Case2", case1 represents the case where I create a paint instance each time the method is called, while case 2 represents where I define a member object in the class so I can use it whenever I need, the problem that when I'm using the first case everything is working perfectly and accurate, while when I'm using the second case nothing happened, The main thing that in my opinion I don't need to create a paint object each time so I need to optimize my code more and more, but why this happened here.....</p>