示例#1
0
  /**
   * Resets the crop overlay view.
   *
   * @param bitmap the Bitmap to set
   */
  public void resetCropOverlayView() {

    if (initializedCropWindow) {
      initCropWindow(mBitmapRect);
      invalidate();
    }
  }
示例#2
0
  @Override
  protected void onSizeChanged(int w, int h, int oldw, int oldh) {

    // Initialize the crop window here because we need the size of the view
    // to have been determined.
    initCropWindow(mBitmapRect);
  }
示例#3
0
  /**
   * Sets whether the aspect ratio is fixed or not; true fixes the aspect ratio, while false allows
   * it to be changed.
   *
   * @param fixAspectRatio Boolean that signals whether the aspect ratio should be maintained.
   */
  public void setFixedAspectRatio(boolean fixAspectRatio) {
    mFixAspectRatio = fixAspectRatio;

    if (initializedCropWindow) {
      initCropWindow(mBitmapRect);
      invalidate();
    }
  }
示例#4
0
  /**
   * Sets the guidelines for the CropOverlayView to be either on, off, or to show when resizing the
   * application.
   *
   * @param guidelines Integer that signals whether the guidelines should be on, off, or only
   *     showing when resizing.
   */
  public void setGuidelines(int guidelines) {
    if (guidelines < 0 || guidelines > 2)
      throw new IllegalArgumentException(
          "Guideline value must be set between 0 and 2. See documentation.");
    else {
      mGuidelines = guidelines;

      if (initializedCropWindow) {
        initCropWindow(mBitmapRect);
        invalidate();
      }
    }
  }
示例#5
0
  /**
   * Sets the Y value of the aspect ratio; is defaulted to 1.
   *
   * @param aspectRatioY int that specifies the new Y value of the aspect ratio
   */
  public void setAspectRatioY(int aspectRatioY) {
    if (aspectRatioY <= 0)
      throw new IllegalArgumentException(
          "Cannot set aspect ratio value to a number less than or equal to 0.");
    else {
      mAspectRatioY = aspectRatioY;
      mTargetAspectRatio = ((float) mAspectRatioX) / mAspectRatioY;

      if (initializedCropWindow) {
        initCropWindow(mBitmapRect);
        invalidate();
      }
    }
  }
示例#6
0
 /**
  * Informs the CropOverlayView of the image's position relative to the ImageView. This is
  * necessary to call in order to draw the crop window.
  *
  * @param bitmapRect the image's bounding box
  */
 public void setBitmapRect(Rect bitmapRect) {
   mBitmapRect = bitmapRect;
   initCropWindow(mBitmapRect);
 }