@Override
  public void onRestoreInstanceState(Parcelable state) {

    if (state instanceof Bundle) {
      Bundle bundle = (Bundle) state;

      // prevent restoring state if already set by outside code
      if (mBitmapLoadingWorkerTask == null
          && mLoadedImageUri == null
          && mBitmap == null
          && mImageResource == 0) {

        Uri uri = bundle.getParcelable("LOADED_IMAGE_URI");
        if (uri != null) {
          String key = bundle.getString("LOADED_IMAGE_STATE_BITMAP_KEY");
          if (key != null) {
            Bitmap stateBitmap =
                BitmapUtils.mStateBitmap != null && BitmapUtils.mStateBitmap.first.equals(key)
                    ? BitmapUtils.mStateBitmap.second.get()
                    : null;
            BitmapUtils.mStateBitmap = null;
            if (stateBitmap != null && !stateBitmap.isRecycled()) {
              setBitmap(stateBitmap, 0, uri, bundle.getInt("LOADED_SAMPLE_SIZE"), 0);
            }
          }
          if (mLoadedImageUri == null) {
            setImageUriAsync(uri);
          }
        } else {
          int resId = bundle.getInt("LOADED_IMAGE_RESOURCE");
          if (resId > 0) {
            setImageResource(resId);
          } else {
            uri = bundle.getParcelable("LOADING_IMAGE_URI");
            if (uri != null) {
              setImageUriAsync(uri);
            }
          }
        }

        mDegreesRotated = mRestoreDegreesRotated = bundle.getInt("DEGREES_ROTATED");

        Rect initialCropRect = bundle.getParcelable("INITIAL_CROP_RECT");
        if (initialCropRect != null
            && (initialCropRect.width() > 0 || initialCropRect.height() > 0)) {
          mCropOverlayView.setInitialCropWindowRect(initialCropRect);
        }

        RectF cropWindowRect = bundle.getParcelable("CROP_WINDOW_RECT");
        if (cropWindowRect != null && (cropWindowRect.width() > 0 || cropWindowRect.height() > 0)) {
          mRestoreCropWindowRect = cropWindowRect;
        }

        mCropOverlayView.setCropShape(CropShape.valueOf(bundle.getString("CROP_SHAPE")));

        mAutoZoomEnabled = bundle.getBoolean("CROP_AUTO_ZOOM_ENABLED");
        mMaxZoom = bundle.getInt("CROP_MAX_ZOOM");

        mFlipHorizontally = bundle.getBoolean("CROP_FLIP_HORIZONTALLY");
        mFlipVertically = bundle.getBoolean("CROP_FLIP_VERTICALLY");
      }

      super.onRestoreInstanceState(bundle.getParcelable("instanceState"));
    } else {
      super.onRestoreInstanceState(state);
    }
  }
Gets the cropped image based on the current crop window.<br>
If (reqWidth,reqHeight) is given AND image is loaded from URI cropping will try to use sample
size to fit in the requested width and height down-sampling if possible - optimization to get
best size to quality.<br>
The result will be invoked to listener set by {@link
#setOnCropImageCompleteListener(OnCropImageCompleteListener)}.

@param reqWidth the width to resize the cropped image to (see options)
@param reqHeight the height to resize the cropped image to (see options)
@param options the resize method to use on the cropped bitmap
@param saveUri optional: to save the cropped image to
@param saveCompressFormat if saveUri is given, the given compression will be used for saving
    the image
@param saveCompressQuality if saveUri is given, the given quality will be used for the
    compression.
core/src/main/java/com/theartofdev/edmodo/cropper/CropImageView.java