To rotate the image, you can get the following code:
Bitmap bMap = BitmapFactory.decodeResource(getResources(),R.drawable.test); Matrix mat = new Matrix(); mat.postRotate(90); Bitmap bMapRotate = Bitmap.createBitmap(bMap, 0, 0, bMap.getWidth(), bMap.getHeight(), mat, true); BitmapDrawable bmd = new BitmapDrawable(bMapRotate); image.setImageBitmap(bMapRotate); image.setImageDrawable(bmd);
and to crop the image taken from the gallery, use the following code snippet:
Intent viewMediaIntent = new Intent(); viewMediaIntent.setAction(android.content.Intent.ACTION_VIEW); File file = new File("/image/*"); viewMediaIntent.setDataAndType(Uri.fromFile(file), "image/*"); viewMediaIntent.putExtra("crop","true"); viewMediaIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP); startActivityForResult(viewMediaIntent,1);
Hope this will be helpful for you.
Nikki source share