├── .gitignore ├── README.md ├── build.gradle ├── demo ├── .classpath ├── .project ├── AndroidManifest.xml ├── build.gradle ├── libs │ └── android-support-v4.jar ├── proguard-project.txt ├── project.properties ├── res │ ├── drawable-hdpi │ │ ├── drawer_shadow.9.png │ │ ├── ic_drawer_am.png │ │ └── ic_launcher.png │ ├── drawable-ldpi │ │ └── ic_launcher.png │ ├── drawable-mdpi │ │ └── ic_launcher.png │ ├── drawable-xhdpi │ │ └── ic_launcher.png │ ├── drawable │ │ ├── ic_drawer.xml │ │ └── shadow.xml │ ├── layout │ │ ├── activity_main.xml │ │ └── list_content.xml │ ├── menu │ │ └── activity_main.xml │ ├── values-v11 │ │ └── styles.xml │ ├── values-v14 │ │ └── styles.xml │ └── values │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml └── src │ └── com │ └── example │ └── androidimagefilterdemo │ ├── Constant.java │ └── MainActivity.java ├── gradle └── wrapper │ └── gradle-wrapper.properties ├── library ├── .classpath ├── .cproject ├── .project ├── AndroidManifest.xml ├── build.gradle ├── jni │ ├── Android.mk │ ├── AndroidImageFilter.cpp │ ├── Application.mk │ ├── AverageSmoothFilter.cpp │ ├── AverageSmoothFilter.h │ ├── BlockFilter.cpp │ ├── BlockFilter.h │ ├── BrightContrastFilter.cpp │ ├── BrightContrastFilter.h │ ├── ColorGetter.h │ ├── ColorTranslator.cpp │ ├── ColorTranslator.h │ ├── GammaCorrectionFilter.cpp │ ├── GammaCorrectionFilter.h │ ├── GaussianBlurFilter.cpp │ ├── GaussianBlurFilter.h │ ├── GothamFilter.cpp │ ├── GothamFilter.h │ ├── HDRFilter.cpp │ ├── HDRFilter.h │ ├── HueSaturationFilter.cpp │ ├── HueSaturationFilter.h │ ├── ImageFilter.h │ ├── LightFilter.cpp │ ├── LightFilter.h │ ├── LomoAddBlackRound.cpp │ ├── LomoAddBlackRound.h │ ├── MotionBlurFilter.cpp │ ├── MotionBlurFilter.h │ ├── NeonFilter.cpp │ ├── NeonFilter.h │ ├── OilFilter.cpp │ ├── OilFilter.h │ ├── PixelateFilter.cpp │ ├── PixelateFilter.h │ ├── ReliefFilter.cpp │ ├── ReliefFilter.h │ ├── SharpenFilter.cpp │ ├── SharpenFilter.h │ ├── SketchFilter.cpp │ ├── SketchFilter.h │ ├── SoftGlowFilter.cpp │ ├── SoftGlowFilter.h │ ├── TvFilter.cpp │ ├── TvFilter.h │ ├── Util.h │ ├── cn_Ragnarok_NativeFilterFunc.cpp │ └── cn_Ragnarok_NativeFilterFunc.h ├── libs │ ├── armeabi-v7a │ │ └── libAndroidImageFilter.so │ ├── armeabi │ │ └── libAndroidImageFilter.so │ ├── mips │ │ └── libAndroidImageFilter.so │ └── x86 │ │ └── libAndroidImageFilter.so ├── proguard.cfg ├── project.properties ├── res │ └── values │ │ └── strings.xml └── src │ └── cn │ └── Ragnarok │ ├── BitmapFilter.java │ ├── BlockFilter.java │ ├── BlurFilter.java │ ├── GaussianBlurFilter.java │ ├── GothamFilter.java │ ├── GrayFilter.java │ ├── HDRFilter.java │ ├── InvertFilter.java │ ├── LightFilter.java │ ├── LomoFilter.java │ ├── MotionBlurFilter.java │ ├── NativeFilterFunc.java │ ├── NeonFilter.java │ ├── OilFilter.java │ ├── OldFilter.java │ ├── PixelateFilter.java │ ├── ReliefFilter.java │ ├── SharpenFilter.java │ ├── SketchFilter.java │ ├── SoftGlowFilter.java │ └── TvFilter.java ├── local.properties ├── screenshot └── img1.png └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .settings/ 3 | genJniHeader 4 | library/bin 5 | library/gen 6 | library/obj 7 | demo/bin 8 | demo/gen 9 | demoKey 10 | AndroidImageFilterDemo.apk 11 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | android-image-filter 2 | ==================== 3 | 4 | some android image filters 5 | 6 | in some filter, I use NDK to implement to make it more efficient 7 | 8 | # Setup 9 | 10 | - Install Android NDK and properly configure it: [http://goo.gl/koTCb](http://goo.gl/koTCb) 11 | - Get a clean clone of this project, import the library in Android Studio 12 | - then Clean and Build the hold project to regenerate the library 13 | - Then just add library module as a dependency to your existing project. 14 | 15 | # How to Use it 16 | It is dead simple, you can see magic in the following code: 17 | 18 | ```Java 19 | Bitmap newBitmap = BitmapFilter.changeStyle(originBitmap, BitmapFilter.BLUR_STYLE); 20 | imageView.setImageBitmap(newBitmap); 21 | ``` 22 | 23 | and there are some options for the filter, you can go to see the demo to see how to use this options to customize your filter effect 24 | 25 | You can see all filters in file [BitmapFilter.java][3], currently contains totally 19 kinds of filters now, here is the list of filters and their options(show by code): 26 | 27 | * Grayscale 28 | * Relief 29 | * Blur(Average Smooth) 30 | 31 | ```Java 32 | BitmapFilter.changeStyle(originBitmap, BitmapFilter.BLUR_STYLE, maskSize); 33 | ``` 34 | 35 | ``maskSize`` is a integer, to indicate the average blur mask's size 36 | 37 | * Oil Painting 38 | * Neon 39 | 40 | ```Java 41 | BitmapFilter.changeStyle(originBitmap, BitmapFilter.NEON_STYLE, 42 | neon_color_R, neon_color_G, neon_color_B); 43 | ``` 44 | 45 | ``neon_color_R``, ``neon_color_G``, ``neon_color_B`` are the R,G,B component are integer 46 | 47 | * Pixelate 48 | 49 | ```Java 50 | BitmapFilter.changeStyle(originBitmap, BitmapFilter.PIXELATE_STYLE, pixelSize); 51 | ``` 52 | 53 | ``pixelSize`` is a integer, the pixel size for this filter 54 | 55 | * Old TV 56 | * Invert Color 57 | * Block 58 | * Old Photo 59 | * Sharpen(By Laplacian) 60 | * Light 61 | 62 | ```Java 63 | BitmapFilter.changeStyle(originBitmap, BitmapFilter.LIGHT_STYLE, light_center_x, light_center_y, light_radius); 64 | ``` 65 | 66 | ``light_center_x``, ``light_center_y`` are integer, indicate the center of the light spot, the origin in the left-upper side, and the ``light_radius`` is indicate the radius of light spot, in pixel 67 | 68 | * Lomo 69 | 70 | ```Java 71 | BitmapFilter.changeStyle(originBitmap, BitmapFilter.LOMO_STYLE, roundRadius); 72 | ``` 73 | 74 | ``roundRadius`` is a double, the black round's radius in the effect 75 | 76 | * HDR 77 | * Gaussian Blur 78 | 79 | ```Java 80 | BitmapFilter.changeStyle(originBitmap, BitmapFilter.GAUSSIAN_BLUR_STYLE, sigma); 81 | ``` 82 | 83 | ``sigma`` is a double, the sigma value in Gaussian Blur, the bigger of sigma, the smoother in the result image 84 | 85 | * Soft Glow 86 | 87 | ```Java 88 | BitmapFilter.changeStyle(originBitmap, BitmapFilter.SOFT_GLOW_STYLE, sigma); 89 | ``` 90 | 91 | ``sigma`` is a double, the same as ``sigma`` in Gaussian Blur, indicate the sigma value in the process of Gaussian Blur for Soft Glow 92 | 93 | * Sketch 94 | * Motion Blur 95 | 96 | ```Java 97 | BitmapFilter.changeStyle(originBitmap, BitmapFilter.SOFT_GLOW_STYLE, xSpeed, ySpeed); 98 | ``` 99 | ``xSpeed`` and ``ySpeed`` are both integer, indicate the speed in x-axis and y-axis, the origin in the left-upper side 100 | 101 | * Gotham 102 | 103 | PS: all options have defalut values, so you can just select the effect and pass nothing, like this: 104 | 105 | ```Java 106 | BitmapFilter.changeStyle(originBitmap, BitmapFilter.MOTION_BLUR_STYLE); 107 | ``` 108 | 109 | 110 | If you have any question, please open an [issue][4] and show your code and the program ouput, thanks! 111 | 112 | ![][2] 113 | 114 | # The MIT License (MIT) 115 | 116 | Copyright (c) \<2012-2016\> \ 117 | 118 | Permission is hereby granted, free of charge, to any person obtaining a copy 119 | of this software and associated documentation files (the "Software"), to deal 120 | in the Software without restriction, including without limitation the rights 121 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 122 | copies of the Software, and to permit persons to whom the Software is 123 | furnished to do so, subject to the following conditions: 124 | 125 | The above copyright notice and this permission notice shall be included in 126 | all copies or substantial portions of the Software. 127 | 128 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 129 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 130 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 131 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 132 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 133 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 134 | THE SOFTWARE. 135 | 136 | [1]: http://1drv.ms/1i10uuX 137 | [2]: screenshot/img1.png 138 | [3]: library/src/cn/Ragnarok/BitmapFilter.java 139 | [4]: https://github.com/ragnraok/android-image-filter/issues?state=open 140 | 141 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | jcenter() 4 | } 5 | dependencies { 6 | classpath 'com.android.tools.build:gradle:2.1.0' 7 | 8 | 9 | } 10 | } 11 | 12 | allprojects { 13 | repositories { 14 | jcenter() 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /demo/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /demo/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | AndroidImageFilterDemo 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder 10 | 11 | 12 | ?children? 13 | ?children?=?name?=entry\\\\\\\|\\\|?name?=entry\\\\\\\|\\\|\|?name?=outputEntries\|| 14 | 15 | 16 | ?name? 17 | 18 | 19 | 20 | org.eclipse.cdt.make.core.append_environment 21 | true 22 | 23 | 24 | org.eclipse.cdt.make.core.buildArguments 25 | 26 | 27 | 28 | org.eclipse.cdt.make.core.buildCommand 29 | /Users/ragnarok/android-ndk-r9d/ndk-build 30 | 31 | 32 | org.eclipse.cdt.make.core.cleanBuildTarget 33 | clean 34 | 35 | 36 | org.eclipse.cdt.make.core.contents 37 | org.eclipse.cdt.make.core.activeConfigSettings 38 | 39 | 40 | org.eclipse.cdt.make.core.enableAutoBuild 41 | false 42 | 43 | 44 | org.eclipse.cdt.make.core.enableCleanBuild 45 | true 46 | 47 | 48 | org.eclipse.cdt.make.core.enableFullBuild 49 | true 50 | 51 | 52 | org.eclipse.cdt.make.core.stopOnError 53 | true 54 | 55 | 56 | org.eclipse.cdt.make.core.useDefaultBuildCmd 57 | false 58 | 59 | 60 | 61 | 62 | com.android.ide.eclipse.adt.ResourceManagerBuilder 63 | 64 | 65 | 66 | 67 | com.android.ide.eclipse.adt.PreCompilerBuilder 68 | 69 | 70 | 71 | 72 | org.eclipse.jdt.core.javabuilder 73 | 74 | 75 | 76 | 77 | com.android.ide.eclipse.adt.ApkBuilder 78 | 79 | 80 | 81 | 82 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder 83 | full,incremental, 84 | 85 | 86 | 87 | 88 | 89 | com.android.ide.eclipse.adt.AndroidNature 90 | org.eclipse.jdt.core.javanature 91 | org.eclipse.cdt.core.cnature 92 | org.eclipse.cdt.core.ccnature 93 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 94 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 95 | 96 | 97 | -------------------------------------------------------------------------------- /demo/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 10 | 11 | 12 | 13 | 18 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /demo/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | buildToolsVersion "22.0.1" 5 | compileSdkVersion "android-22" 6 | sourceSets { 7 | main { 8 | java.srcDirs 'src' 9 | 10 | res.srcDirs 'res' 11 | manifest.srcFile 'AndroidManifest.xml' 12 | } 13 | } 14 | 15 | buildTypes { 16 | release { 17 | minifyEnabled false 18 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 19 | } 20 | debug { 21 | debuggable true 22 | jniDebuggable true 23 | } 24 | } 25 | } 26 | 27 | dependencies { 28 | compile project(':library') 29 | compile files('libs/android-support-v4.jar') 30 | } -------------------------------------------------------------------------------- /demo/libs/android-support-v4.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ragnraok/android-image-filter/30e229db675586fb6d024577883dd8a56f69d047/demo/libs/android-support-v4.jar -------------------------------------------------------------------------------- /demo/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 | -------------------------------------------------------------------------------- /demo/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=android-19 15 | android.library.reference.1=../library 16 | -------------------------------------------------------------------------------- /demo/res/drawable-hdpi/drawer_shadow.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ragnraok/android-image-filter/30e229db675586fb6d024577883dd8a56f69d047/demo/res/drawable-hdpi/drawer_shadow.9.png -------------------------------------------------------------------------------- /demo/res/drawable-hdpi/ic_drawer_am.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ragnraok/android-image-filter/30e229db675586fb6d024577883dd8a56f69d047/demo/res/drawable-hdpi/ic_drawer_am.png -------------------------------------------------------------------------------- /demo/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ragnraok/android-image-filter/30e229db675586fb6d024577883dd8a56f69d047/demo/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /demo/res/drawable-ldpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ragnraok/android-image-filter/30e229db675586fb6d024577883dd8a56f69d047/demo/res/drawable-ldpi/ic_launcher.png -------------------------------------------------------------------------------- /demo/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ragnraok/android-image-filter/30e229db675586fb6d024577883dd8a56f69d047/demo/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /demo/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ragnraok/android-image-filter/30e229db675586fb6d024577883dd8a56f69d047/demo/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /demo/res/drawable/ic_drawer.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /demo/res/drawable/shadow.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | -------------------------------------------------------------------------------- /demo/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 10 | 11 | 17 | 18 |