├── .gitignore ├── README.md ├── build.gradle ├── settings.gradle ├── simple-crop-image-example ├── AndroidManifest.xml ├── ant.properties ├── build.xml ├── local.properties ├── proguard-project.txt ├── project.properties ├── res │ ├── drawable-hdpi │ │ └── ic_launcher.png │ ├── drawable-ldpi │ │ └── ic_launcher.png │ ├── drawable-mdpi │ │ └── ic_launcher.png │ ├── drawable-xhdpi │ │ └── ic_launcher.png │ ├── layout │ │ └── main.xml │ └── values │ │ └── strings.xml └── src │ └── eu │ └── janmuller │ └── android │ └── simplecropimage │ └── example │ ├── InternalStorageContentProvider.java │ └── MainActivity.java └── simple-crop-image-lib ├── AndroidManifest.xml ├── ant.properties ├── build.gradle ├── build.xml ├── local.properties ├── proguard-project.txt ├── project.properties ├── res ├── drawable-xhdpi │ ├── btn_crop_operator.9.png │ ├── btn_crop_pressed.9.png │ ├── camera_crop_height.png │ ├── camera_crop_width.png │ ├── ic_rotate_left.png │ ├── ic_rotate_right.png │ └── indicator_autocrop.png ├── drawable │ └── selector_crop_button.xml ├── layout │ ├── cropimage.xml │ └── main.xml ├── values-cs │ └── strings.xml └── values │ ├── strings.xml │ └── styles.xml └── src └── eu └── janmuller └── android └── simplecropimage ├── BitmapManager.java ├── CropImage.java ├── CropImageView.java ├── HighlightView.java ├── ImageViewTouchBase.java ├── MonitoredActivity.java ├── RotateBitmap.java └── Util.java /.gitignore: -------------------------------------------------------------------------------- 1 | bin/ 2 | gen/ 3 | png/ 4 | target/ 5 | .settings/ 6 | .classpath 7 | *.class 8 | *.log 9 | *.iml 10 | .DS_Store 11 | 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2012 Jan Muller 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | Cropimage 23 | ========= 24 | 25 | - Added support for building with Gradle 26 | - Replacement for deprecated official Android crop image function 27 | - > 2.2 API 28 | - Easy to integrate to your app. 29 | - Enjoy ;-) 30 | 31 | 32 | Call this method to run CropImage activity 33 | ```java 34 | private void runCropImage() { 35 | 36 | // create explicit intent 37 | Intent intent = new Intent(this, CropImage.class); 38 | 39 | // tell CropImage activity to look for image to crop 40 | String filePath = ...; 41 | intent.putExtra(CropImage.IMAGE_PATH, filePath); 42 | 43 | // allow CropImage activity to rescale image 44 | intent.putExtra(CropImage.SCALE, true); 45 | 46 | // if the aspect ratio is fixed to ratio 3/2 47 | intent.putExtra(CropImage.ASPECT_X, 3); 48 | intent.putExtra(CropImage.ASPECT_Y, 2); 49 | 50 | // start activity CropImage with certain request code and listen 51 | // for result 52 | startActivityForResult(intent, REQUEST_CODE_CROP_IMAGE); 53 | } 54 | ``` 55 | 56 | Waiting for result 57 | ```java 58 | @Override 59 | protected void onActivityResult(int requestCode, int resultCode, Intent data) { 60 | 61 | if (resultCode != RESULT_OK) { 62 | 63 | return; 64 | } 65 | 66 | switch (requestCode) { 67 | 68 | case REQUEST_CODE_CROP_IMAGE: 69 | 70 | String path = data.getStringExtra(CropImage.IMAGE_PATH); 71 | 72 | // if nothing received 73 | if (path == null) { 74 | 75 | return; 76 | } 77 | 78 | // cropped bitmap 79 | Bitmap bitmap = BitmapFactory.decodeFile(mFileTemp.getPath()); 80 | 81 | break; 82 | } 83 | super.onActivityResult(requestCode, resultCode, data); 84 | } 85 | ``` 86 | 87 | Building with Gradle 88 | -------------------- 89 | 90 | To build with gradle, make sure you have installed the gradle wrapper in the top level directory. 91 | On my computer this is typically done (from the root of this project) with a: 92 | 93 | cp -Rv /opt/android-studio/sdk/tools/templates/gradle/wrapper/* . 94 | 95 | Make sure to adjust the path to whereever you installed Android Studio. 96 | 97 | After doing this, to build issue the following command (again from the root of this project): 98 | 99 | ./gradlew assembleDebug 100 | 101 | To install the example a running emulator or device, do a: 102 | 103 | adb install -r ./simple-crop-image-example/build/apk/simple-crop-image-example-debug-unaligned.apk 104 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/biokys/cropimage/64282e2634c03cfa377eb66b647722768d23372c/build.gradle -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':simple-crop-image-example', ':simple-crop-image-lib' 2 | 3 | -------------------------------------------------------------------------------- /simple-crop-image-example/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 15 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /simple-crop-image-example/ant.properties: -------------------------------------------------------------------------------- 1 | # This file is used to override default values used by the Ant build system. 2 | # 3 | # This file must be checked into Version Control Systems, as it is 4 | # integral to the build system of your project. 5 | 6 | # This file is only used by the Ant script. 7 | 8 | # You can use this to override default values such as 9 | # 'source.dir' for the location of your java source folder and 10 | # 'out.dir' for the location of your output folder. 11 | 12 | # You can also use it define how the release builds are signed by declaring 13 | # the following properties: 14 | # 'key.store' for the location of your keystore and 15 | # 'key.alias' for the name of the key to use. 16 | # The password will be asked during the build when you use the 'release' target. 17 | 18 | -------------------------------------------------------------------------------- /simple-crop-image-example/build.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | 29 | 30 | 31 | 35 | 36 | 37 | 38 | 39 | 40 | 49 | 50 | 51 | 52 | 56 | 57 | 69 | 70 | 71 | 89 | 90 | 91 | 92 | 93 | -------------------------------------------------------------------------------- /simple-crop-image-example/local.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must *NOT* be checked into Version Control Systems, 5 | # as it contains information specific to your local configuration. 6 | 7 | # location of the SDK. This is only used by Ant 8 | # For customization when using a Version Control System, please read the 9 | # header note. 10 | sdk.dir=/Users/muller10/Development/android-sdk-macosx 11 | -------------------------------------------------------------------------------- /simple-crop-image-example/proguard-project.txt: -------------------------------------------------------------------------------- 1 | # To enable ProGuard in your project, edit project.properties 2 | # to define the proguard.config property as described in that file. 3 | # 4 | # Add project specific ProGuard rules here. 5 | # By default, the flags in this file are appended to flags specified 6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt 7 | # You can edit the include path and order by changing the ProGuard 8 | # include property in project.properties. 9 | # 10 | # For more details, see 11 | # http://developer.android.com/guide/developing/tools/proguard.html 12 | 13 | # Add any project specific keep options here: 14 | 15 | # If your project uses WebView with JS, uncomment the following 16 | # and specify the fully qualified class name to the JavaScript interface 17 | # class: 18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 19 | # public *; 20 | #} 21 | -------------------------------------------------------------------------------- /simple-crop-image-example/project.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must be checked in Version Control Systems. 5 | # 6 | # To customize properties used by the Ant build system edit 7 | # "ant.properties", and override values to adapt the script to your 8 | # project structure. 9 | # 10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): 11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt 12 | 13 | # Project target. 14 | target=Google Inc.:Google APIs:16 15 | android.library.reference.1=../simple-crop-image-lib 16 | -------------------------------------------------------------------------------- /simple-crop-image-example/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/biokys/cropimage/64282e2634c03cfa377eb66b647722768d23372c/simple-crop-image-example/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /simple-crop-image-example/res/drawable-ldpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/biokys/cropimage/64282e2634c03cfa377eb66b647722768d23372c/simple-crop-image-example/res/drawable-ldpi/ic_launcher.png -------------------------------------------------------------------------------- /simple-crop-image-example/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/biokys/cropimage/64282e2634c03cfa377eb66b647722768d23372c/simple-crop-image-example/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /simple-crop-image-example/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/biokys/cropimage/64282e2634c03cfa377eb66b647722768d23372c/simple-crop-image-example/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /simple-crop-image-example/res/layout/main.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 13 | 14 |