0

I have retrieved my profile picture from Facebook and displayed it in the ImageView. But before displaying it I cropped the image to a circular form. The circular image is saved in the sdcard. Now what I want to do is display this image in a square form in another ImageView which is in another activity. So is it possible to change the circular image back to square? If yes please tell me how should I do it. I have cropped the image to circle using the following codes.

 Bitmap circleBitmap = Bitmap.createBitmap(bm.getWidth(), bm.getHeight(), Bitmap.Config.ARGB_8888);

 BitmapShader shader = new BitmapShader (bm,  TileMode.CLAMP, TileMode.CLAMP);

 Paint paint = new Paint();
 paint.setShader(shader);
 Canvas c = new Canvas(circleBitmap);

 c.drawCircle(bm.getWidth()/2, bm.getHeight()/2, bm.getWidth()/2, paint);
 paint.setAntiAlias(true);
 paint.setShadowLayer(10, 10, 5,Color.RED);
 paint.setShadowLayer(40,100 , 100,Color.RED);
 myImageView1.setImageBitmap(circleBitmap);
anu_r
  • 1,602
  • 7
  • 30
  • 61
  • your Bitmap bm is the square one, you can reuse that bitmap unless you are overwriting this variable – xgc1986 Apr 28 '14 at 07:28
  • @blackbelt I am cropping the Image to circle and displaying on a ImageView and from there i am saving it in the sdcard. And I need to display the other image in another activity so bm is not gonna work. – anu_r Apr 28 '14 at 07:29
  • How to save the Bitmap in the sdcard? – anu_r Apr 28 '14 at 07:35
  • this is how to save your bitmap, you will have to modify slightly de correct answer to your purposes http://stackoverflow.com/questions/15428975/save-bitmap-into-file-and-return-file-having-bitmap-image – xgc1986 Apr 28 '14 at 07:53

0 Answers0