title: Rotating image in File for Android
body: <p>I'm having problems with trying to rotate an image before cropping it. I have tried calling <code>setRotation</code> on the Image View I want to rotate and it rotates the imageView successfully. I realized this wasn't a solution because when I call CropImageIntentBuilder it passes in the original Image View without any rotation. </p>
  
  <p>In the code below I have tried a different approach by saving the image to a File and passing that file to CropImageIntentBuilder but I am still having the same problem. Please let me know if there is any advice you can offer on this or if I'm approaching this the wrong way. Also if I need to post more of the code from the app please let me know.</p>
  
  <pre><code>public static Bitmap rotateBitmap (Bitmap source, float angle){
      Matrix matrix = new Matrix();
      matrix.postRotate(angle);
          return  Bitmap.createBitmap(source, 0, 0, source.getWidth(), source.getHeight(),matrix,true);
  }
  
  
  private void executeCropImageIntent() {
      //This is the cropIntent that is called using nexuss 10
      try{
           bitmap = MediaStore.Images.Media.getBitmap(this.getContentResolver(), Uri.parse(mSingleton.mCropFileTemp.toURI().toString()));
          //mSelectedImage.setImageBitmap(rotateBitmap(bitmap, 90));
          rotateBitmap(bitmap, 90);
          try{
  
              FileOutputStream fOut = new FileOutputStream(mSingleton.mCropFileTemp);
              bitmap.compress(Bitmap.CompressFormat.PNG, 85, fOut);
              fOut.flush();
              fOut.close();}
          catch (Exception e) {
              e.printStackTrace();
              Log.i(null, "Save file error!");
      //      Toast.makeText(this, getResources().getString(R.string.messageMissingGPS), Toast.LENGTH_LONG).show();
          }
  
          }
  
      catch (IOException e) {
          Log.d("JudgeMainFragment", "cannot take picture", e);
      }
  
              CropImageIntentBuilder intentBuilder = new CropImageIntentBuilder(0, 0, 0, 0, Uri.parse(mSingleton.mCropFileTemp.toURI().toString()));
              //  intentBuilder.setSourceImage(Uri.parse(mData.getImage()));
              intentBuilder.setSourceImage(Uri.parse(mSingleton.mCropFileTemp.toURI().toString()));
              startActivityForResult(intentBuilder.getIntent(this), IJudgeSingleton.REQUEST_CODE_CROP_IMAGE);
  
  
      }
  </code></pre>