Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Crop and Zoom Image without Moving Overlay View Instead Move Image in ImageView

Hi I want to crop Image without moving Overlay view instead move Image. enter image description here

The image can be moved all around. I would like to crop and save the highlighted area as shown below inside the black border.

I have ImageView with android:scaleType="matrix"

Here's my layout code

<RelativeLayout
    android:id="@+imageEdit/rl_ScaleImage"
    android:layout_width="match_parent"
    android:layout_height="fill_parent"
    android:layout_below="@+imageEdit/Topbar"
    android:visibility="visible" >

    <ImageView
        android:id="@+imageEdit/imageView1"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_alignParentLeft="true"
        android:scaleType="matrix" />

    <View
        android:id="@+imageEdit/viewTop"
        android:layout_width="fill_parent"
        android:layout_height="50dp"
        android:layout_alignParentTop="true"
        android:background="#99000000" />

    <View
        android:id="@+imageEdit/view_scaledImage"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_above="@+imageEdit/viewBottom"
        android:layout_below="@+imageEdit/viewTop"
        android:background="@drawable/rounded_corner_small" />

    <View
        android:id="@+imageEdit/viewBottom"
        android:layout_width="fill_parent"
        android:layout_height="150dp"
        android:layout_alignParentBottom="true"
        android:background="#99000000" />
</RelativeLayout>

ImageView has OnTouchListener. Image can be zoomed in or zoomed out and is also movable in ImageView1. View view_scaledImage is the area which I want to crop and save. How do I do this?

like image 683
Raj Avatar asked Sep 30 '22 03:09

Raj


1 Answers

Finally I got the solution by combining Cropper library and PhotoView libraries.

https://github.com/rameshkec85/AndroidCropMoveScaleImage

like image 164
Ramesh Akula Avatar answered Oct 02 '22 16:10

Ramesh Akula