i am trying to convert imageview into 60px circular image but its not happening ...
the way i am trying is...
File imgFile = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES),
"MyCameraApp" + File.separator + "profile_" + userId + ".jpg");
if(imgFile.exists()){
Bitmap correctBmp=null;
ExifInterface exif;
try {
exif = new ExifInterface(imgFile.getPath());
int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
int angle = 0;
if (orientation == ExifInterface.ORIENTATION_ROTATE_90) {
angle = 90;
}
else if (orientation == ExifInterface.ORIENTATION_ROTATE_180) {
angle = 180;
}
else if (orientation == ExifInterface.ORIENTATION_ROTATE_270) {
angle = 270;
}
Matrix mat = new Matrix();
mat.postRotate(90);
Bitmap bmp1 = BitmapFactory.decodeStream(new FileInputStream(imgFile), null, null);
/* correctBmp = Bitmap.createBitmap(bmp1, 0, 0, bmp1.getWidth(), bmp1.getHeight(), mat, true);*/
correctBmp = Bitmap.createBitmap(bmp1.getWidth(), bmp1.getHeight(), bmp1.getConfig());
Canvas canvas = new Canvas(correctBmp);
Paint paint = new Paint();
paint.setAntiAlias(true);
paint.setShader(new BitmapShader(bmp1, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP));
canvas.drawRoundRect((new RectF(0.0f, 0.0f, bmp1.getWidth(), bmp1.getHeight())), 10, 10, paint);
profileImage.setImageBitmap(correctBmp);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
it is loading rectangle shape image so what should i do ?
Please help...