title: Rounded curve rectangle bitmap
body: <p>I am trying to add a round white curve border but unlikely it's not rendered in bitmap.</p>
  
  <p>Here it is what I have done so far.</p>
  
  <pre><code>public static Bitmap getRoundedCornerBitmap(Bitmap bitmap, int pixels) {
      Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888);
      Canvas canvas = new Canvas(output);
      final int color = 0xff424242;
      final Paint paint = new Paint();
      final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
      final RectF rectF = new RectF(rect);
      final float roundPx = pixels;
  
      paint.setAntiAlias(true);
      canvas.drawARGB(0, 0, 0, 0);
      paint.setColor(Color.WHITE);
      canvas.drawRoundRect(rectF, roundPx, roundPx, paint);
  
      paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
      canvas.drawBitmap(bitmap, rect, rect, paint);
  
      return output;
  }
  </code></pre>
  
  <p>And it's well rounded bitmap rendered with this code. </p>
  
  <p><a href="https://i.stack.imgur.com/pH1xp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pH1xp.png" alt="enter image description here"></a></p>
  
  <p>What I actually want to achieve it's should be look like this with white border bitmap images.</p>
  
  <p><a href="https://i.stack.imgur.com/FXtmE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FXtmE.png" alt="enter image description here"></a></p>
  
  <p>Any help or suggestion highly appreciate. It would be great if someone points out to me where I am going wrong.</p>