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

Zoom in / Zoom out / Pan #32

Open
kleysonr opened this issue May 13, 2019 · 3 comments
Open

Zoom in / Zoom out / Pan #32

kleysonr opened this issue May 13, 2019 · 3 comments

Comments

@kleysonr
Copy link

Is it possible Zoom and Pan the image when drawing ?

I need to draw on top the images details that is not possible without zooming the image.

So, I am wondering if it's possible, somehow, we be able to do zoom the image as well as pan the zoomed image during the drawing (Pencil option).

The draw layer should be updated like the original image layer.

Best Regards.
Kleyson Rios.

@kleysonr
Copy link
Author

I found this library ( https://github.com/natario1/ZoomLayout ) that could bring those capabilities for the photo-editor.

I am trying to integrate the ZoomLayout on the https://github.com/eventtus/photo-editor-android/blob/master/app/src/main/res/layout/activity_photo_editor.xml , but I am getting some errors.

I did wrap (the code below) with the ZoomLayout, but when I click on the Pencil button I get the error :

2019-05-14 09:30:30.179 4856-4856/com.example.takepictureeditor E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.takepictureeditor, PID: 4856
    java.lang.IllegalArgumentException: width and height must be > 0
        at android.graphics.Bitmap.createBitmap(Bitmap.java:877)
        at android.graphics.Bitmap.createBitmap(Bitmap.java:856)
        at android.graphics.Bitmap.createBitmap(Bitmap.java:823)
        at com.ahmedadeltito.photoeditorsdk.BrushDrawingView.onSizeChanged(BrushDrawingView.java:132)
            <RelativeLayout
                android:id="@+id/parent_image_rl"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_centerInParent="true">

                <ImageView
                    android:id="@+id/photo_edit_iv"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_centerInParent="true"
                    android:adjustViewBounds="true"
                    android:contentDescription="@string/app_name"
                    android:scaleType="centerCrop" />

                <com.ahmedadeltito.photoeditorsdk.BrushDrawingView
                    android:id="@+id/drawing_view"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_alignBottom="@+id/photo_edit_iv"
                    android:layout_alignTop="@+id/photo_edit_iv"
                    android:layout_centerInParent="true"
                    android:visibility="gone" />

            </RelativeLayout>

Can the photo-editor-android do zoom and pan out-of-the-box or do you see a way to integrate it with the ZoomLayout plugin ?

@sanved77
Copy link

Would like this feature.

@MinaSamirCap
Copy link

MinaSamirCap commented Dec 2, 2019

I used the same library and I got the same crash as @kleysonr
but I made the following to prevent crash ... Also, I did not fully test my code.. but I add my suggestion because it may help someone to enhance.

1- I used ZoomLayout from Library https://github.com/natario1/ZoomLayout.
2- Wrapped the PhotoEditorView in LinearLayout to measure the width and height.
3- Wrapped the LinearLayout in the ZoomLayout.
4- when press the brush to enable Drawing mode in PhotoEditorView I disable the Zoom feature
5- Also, I added a zoom button to enable zoom and disable drawing mode.
6- do not forget to set ...
app:oneFingerScrollEnabled to false,
app:hasClickableChildren to true,
app:verticalPanEnabled to false, and
app:horizontalPanEnabled="false"
all of that enable the zoom for me..

kindly check the code below

<com.otaliastudios.zoom.ZoomLayout
android:id="@+id/zoom_layout"
android:layout_width="0dp"
android:layout_height="0dp"
android:scrollbars="vertical|horizontal"
app:alignment="center"
app:animationDuration="280"
app:flingEnabled="true"
app:hasClickableChildren="true"
app:horizontalPanEnabled="false"
app:layout_constraintBottom_toTopOf="@+id/rvConstraintTools"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:maxZoom="2.5"
app:maxZoomType="zoom"
app:minZoom="0.7"
app:minZoomType="zoom"
app:oneFingerScrollEnabled="false"
app:overPinchable="true"
app:overScrollHorizontal="true"
app:overScrollVertical="true"
app:scrollEnabled="true"
app:threeFingersScrollEnabled="true"
app:transformation="centerInside"
app:transformationGravity="auto"
app:twoFingersScrollEnabled="true"
app:verticalPanEnabled="false"
app:zoomEnabled="true">

	<LinearLayout
		android:layout_width="match_parent"
		android:layout_height="match_parent">

		<ja.burhanrashid52.photoeditor.PhotoEditorView
			android:id="@+id/photoEditorView"
			android:layout_width="match_parent"
			android:layout_height="match_parent"
			app:photo_src="@drawable/img3" />

	</LinearLayout>

</com.otaliastudios.zoom.ZoomLayout>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants