title: ImageView subclass to make Rounded Right Corner
body: <p>I am trying to take an image like these </p>
  
  <p><img src="https://i.stack.imgur.com/CiIAx.jpg" alt="enter image description here"> <img src="https://i.stack.imgur.com/SjQD5.png" alt="enter image description here"></p>
  
  <p>and turn them into the top right 1/4 of the image.  The image below is an example of what I need. </p>
  
  <p><img src="https://i.stack.imgur.com/to0ED.png" alt="enter image description here"></p>
  
  <p>**UPDATE: **</p>
  
  <p>I have it (sort of) working, but scaling the image creates an unacceptable amount of distortion my code seems terribly inefficient.  Any ideas on how to improve this code or a possible better approach?</p>
  
  <p><img src="https://i.stack.imgur.com/sstSS.png" alt="enter image description here"></p>
  
  <p>I am subclassing Volley's NetworkImageView.</p>
  
  <p>Here is my code </p>
  
  <pre><code>&lt;com.RoundedNetworkImageView
      android:id="@+id/smallProductImage"
      android:layout_width="56dp"
      android:layout_height="56dp"
      android:layout_centerVertical="true"
      android:layout_margin="5dp"
      android:adjustViewBounds="true"
      android:background="@android:color/white "
      android:scaleType="fitCenter" /&gt;
  
  public static Bitmap getCroppedBitmap(Bitmap bmp, int radius) {
      Bitmap sbmp;
  
      if (bmp.getWidth() != radius || bmp.getHeight() != radius) {
          float smallest = Math.min(bmp.getWidth(), bmp.getHeight());
          float factor = smallest / radius;
          sbmp = Bitmap.createScaledBitmap(bmp, (int) (bmp.getWidth() / factor), (int) (bmp.getHeight() / factor),
                  false);
      } else {
          sbmp = bmp;
      }
  
      Bitmap output = Bitmap.createBitmap(radius, radius, Config.ARGB_8888);
      Canvas canvas = new Canvas(output);
  
      final int color = 0xffa19774;
      final Paint paint = new Paint();
      final Rect rect = new Rect(0, 0, radius, radius);
  
      paint.setAntiAlias(true);
      paint.setFilterBitmap(true);
      paint.setDither(true);
      canvas.drawARGB(0, 0, 0, 0);
      paint.setColor(Color.parseColor("#BAB399"));
      canvas.drawCircle(radius / 2 + 0.7f, radius / 2 + 0.7f, radius / 2 + 0.1f, paint);
      paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
      canvas.drawBitmap(sbmp, rect, rect, paint);
  
      Bitmap bitmap = Bitmap.createBitmap(output, output.getWidth() / 2, 0, output.getWidth() / 2,
              output.getHeight() / 2);
      Bitmap scaledBmp = Bitmap.createScaledBitmap(bitmap, radius, radius, true);
  
      return scaledBmp;
  }
  </code></pre>