Skip to content

Commit

Permalink
add noOutputImage option for crop image activity
Browse files Browse the repository at this point in the history
  • Loading branch information
Arthur committed May 9, 2016
1 parent a6cf40f commit 73d7c22
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,15 @@ public ActivityBuilder setRequestedSize(int reqWidth, int reqHeight) {
return this;
}

/**
* if the result of crop image activity should not save the cropped image bitmap.<br>
* Used if you want to crop the image manually and need only the crop rectangle and rotation data.
*/
public ActivityBuilder setNoOutputImage(boolean noOutputImage) {
mOptions.noOutputImage = noOutputImage;
return this;
}

/**
* the initial rectangle to set on the cropping image after loading
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,16 @@ public void onSaveCroppedImageComplete(CropImageView view, Uri uri, Exception er
* Execute crop image and save the result tou output uri.
*/
protected void cropImage() {
Uri outputUri = getOutputUri();
mCropImageView.saveCroppedImageAsync(outputUri,
mOptions.outputCompressFormat,
mOptions.outputCompressQuality,
mOptions.outputRequestWidth,
mOptions.outputRequestHeight);
if (mOptions.noOutputImage) {
setResult(null, null);
} else {
Uri outputUri = getOutputUri();
mCropImageView.saveCroppedImageAsync(outputUri,
mOptions.outputCompressFormat,
mOptions.outputCompressQuality,
mOptions.outputRequestWidth,
mOptions.outputRequestHeight);
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,11 @@ public CropImageOptions[] newArray(int size) {
*/
public int outputRequestHeight;

/**
* if the result of crop image activity should not save the cropped image bitmap
*/
public boolean noOutputImage;

/**
* the initial rectangle to set on the cropping image after loading
*/
Expand Down Expand Up @@ -285,6 +290,7 @@ public CropImageOptions() {
outputCompressQuality = 90;
outputRequestWidth = 0;
outputRequestHeight = 0;
noOutputImage = false;

initialCropWindowRectangle = null;
initialRotation = -1;
Expand Down Expand Up @@ -330,6 +336,7 @@ protected CropImageOptions(Parcel in) {
outputCompressQuality = in.readInt();
outputRequestWidth = in.readInt();
outputRequestHeight = in.readInt();
noOutputImage = in.readByte() != 0;
initialCropWindowRectangle = in.readParcelable(Rect.class.getClassLoader());
initialRotation = in.readInt();
allowRotation = in.readByte() != 0;
Expand Down Expand Up @@ -372,6 +379,7 @@ public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(outputCompressQuality);
dest.writeInt(outputRequestWidth);
dest.writeInt(outputRequestHeight);
dest.writeInt(noOutputImage ? 1 : 0);
dest.writeParcelable(initialCropWindowRectangle, flags);
dest.writeInt(initialRotation);
dest.writeByte((byte) (allowRotation ? 1 : 0));
Expand Down

0 comments on commit 73d7c22

Please sign in to comment.