Open usmanrana07 opened 5 years ago
Is these issue solved?
I googled this problem on the internet. There is a guy can do the zoom with this library: https://youtu.be/q7zPOtU4Mn8 But he just submitted the demo. If you resolve this problem, plz share
@ThuyKhanh Thanks for the link. I don't have the solution for this right now. Feel free to open a PR when you find one.
@burhanrashid52 this code is able to add zoom in and zoom out feature can you check please and implement this in library
import android.view.ScaleGestureDetector // Add this import
internal class PhotoEditorImpl @SuppressLint("ClickableViewAccessibility") constructor(
builder: PhotoEditor.Builder
) : PhotoEditor {
// Existing variables...
private val context: Context = builder.context
// Add variables for ScaleGestureDetector
private var scaleFactor = 1.0f
private val scaleGestureDetector: ScaleGestureDetector
init {
// Initialize the ScaleGestureDetector with a listener
scaleGestureDetector = ScaleGestureDetector(context, object : ScaleGestureDetector.SimpleOnScaleGestureListener() {
override fun onScale(detector: ScaleGestureDetector): Boolean {
// Scale the image
scaleFactor *= detector.scaleFactor
// Set limits to prevent infinite zoom-in/out
scaleFactor = scaleFactor.coerceIn(0.5f, 3.0f)
imageView?.scaleX = scaleFactor
imageView?.scaleY = scaleFactor
return true
}
})
// Existing GestureDetector setup
val mDetector = GestureDetector(
context,
PhotoEditorImageViewListener(
viewState,
object : OnSingleTapUpCallback {
override fun onSingleTapUp() {
clearHelperBox()
}
}
)
)
imageView?.setOnTouchListener { v, event ->
mOnPhotoEditorListener?.onTouchSourceImage(event)
// Pass touch events to both gesture detectors
scaleGestureDetector.onTouchEvent(event) || mDetector.onTouchEvent(event)
}
// Other initializations...
photoEditorView.setClipSourceImage(builder.clipSourceImage)
}
// Existing methods...
}
https://github.com/user-attachments/assets/42172fec-46b6-4027-bbe3-c65519846d81
@NavjotSinghSeraphic Does it scale up/down the drawing on zoomin/zoomout image ? What is the usecase for this feature ?
@burhanrashid52 If the user wants to zoom in or zoom out, they can easily do so, but it will only affect the image, not the drawing.
Image in PhotoEditorView should be zoomable, this feature is missing in current version.