Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New API: CropImageView#expectedImageSize which returns the expected image size, if cropping the image right now. #496

Merged
merged 1 commit into from
Oct 24, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions cropper/src/main/kotlin/com/canhub/cropper/CropImageView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import android.os.Parcelable
import android.provider.MediaStore
import android.util.AttributeSet
import android.util.Pair
import android.util.Size
import android.view.LayoutInflater
import android.widget.FrameLayout
import android.widget.ImageView
Expand Down Expand Up @@ -501,6 +502,17 @@ class CropImageView @JvmOverloads constructor(
mCropOverlayView!!.initialCropWindowRect = rect
}

/** This returns the expected image size, if cropping the image right now. */
fun expectedImageSize(): Size? {
val rect = cropRect ?: return null

return if (rotatedDegrees == 0 || rotatedDegrees == 180) {
Size(rect.width(), rect.height())
} else {
Size(rect.height(), rect.width())
}
}

/**
* Gets the crop window's position relative to the parent's view at screen.
*
Expand Down