Guest User

Untitled

a guest
Nov 23rd, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. private void setCircleImageViews() {
  2. Picasso.with(getApplicationContext()).load(Uri.parse(UserData.getMatchTrioPicsUrls().get(0))).transform(new CropCircleTransformation()).into(commonFriendProfile);
  3. Picasso.with(getApplicationContext()).load(Uri.parse(UserData.getMatchTrioPicsUrls().get(1))).transform(new CropCircleTransformation()).into(leftFriendProfile);
  4. Picasso.with(getApplicationContext()).load(Uri.parse(UserData.getMatchTrioPicsUrls().get(2))).transform(new CropCircleTransformation()).into(rightFriendProfile);
  5. }
  6.  
  7. @Override public Bitmap transform(Bitmap source) {
  8. int size = Math.min(source.getWidth(), source.getHeight());
  9.  
  10. int width = (source.getWidth() - size) / 2;
  11. int height = (source.getHeight() - size) / 2;
  12.  
  13. Bitmap bitmap = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888);
  14.  
  15. Canvas canvas = new Canvas(bitmap);
  16. Paint paint = new Paint();
  17. BitmapShader shader =
  18. new BitmapShader(source, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP);
  19. if (width != 0 || height != 0) {
  20. // source isn't square, move viewport to center
  21. Matrix matrix = new Matrix();
  22. matrix.setTranslate(-width, -height);
  23. shader.setLocalMatrix(matrix);
  24. }
  25. paint.setShader(shader);
  26. paint.setAntiAlias(true);
  27.  
  28. float r = size / 2f;
  29. canvas.drawCircle(r, r, r, paint);
  30.  
  31. source.recycle();
  32.  
  33. return bitmap;
  34.  
  35. Called getConfig() on a recycle()'d bitmap! This is undefined behavior!
Add Comment
Please, Sign In to add comment