some android image filters

Overview

android-image-filter

some android image filters

in some filter, I use NDK to implement to make it more efficient

Setup

  • Install Android NDK and properly configure it: http://goo.gl/koTCb
  • Get a clean clone of this project, import the library in Android Studio
  • then Clean and Build the hold project to regenerate the library
  • Then just add library module as a dependency to your existing project.

How to Use it

It is dead simple, you can see magic in the following code:

  Bitmap newBitmap = BitmapFilter.changeStyle(originBitmap, BitmapFilter.BLUR_STYLE);
  imageView.setImageBitmap(newBitmap);        

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

You can see all filters in file BitmapFilter.java, currently contains totally 19 kinds of filters now, here is the list of filters and their options(show by code):

  • Grayscale

  • Relief

  • Blur(Average Smooth)

     BitmapFilter.changeStyle(originBitmap, BitmapFilter.BLUR_STYLE, maskSize);

maskSize is a integer, to indicate the average blur mask's size

  • Oil Painting

  • Neon

     BitmapFilter.changeStyle(originBitmap, BitmapFilter.NEON_STYLE, 
     neon_color_R, neon_color_G, neon_color_B);	

neon_color_R, neon_color_G, neon_color_B are the R,G,B component are integer

  • Pixelate

     BitmapFilter.changeStyle(originBitmap, BitmapFilter.PIXELATE_STYLE, pixelSize);

pixelSize is a integer, the pixel size for this filter

  • Old TV

  • Invert Color

  • Block

  • Old Photo

  • Sharpen(By Laplacian)

  • Light

     BitmapFilter.changeStyle(originBitmap, BitmapFilter.LIGHT_STYLE, light_center_x, light_center_y, light_radius);

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

  • Lomo

     BitmapFilter.changeStyle(originBitmap, BitmapFilter.LOMO_STYLE, roundRadius);

roundRadius is a double, the black round's radius in the effect

  • HDR

  • Gaussian Blur

     BitmapFilter.changeStyle(originBitmap, BitmapFilter.GAUSSIAN_BLUR_STYLE, sigma);

    sigma is a double, the sigma value in Gaussian Blur, the bigger of sigma, the smoother in the result image

  • Soft Glow

     BitmapFilter.changeStyle(originBitmap, BitmapFilter.SOFT_GLOW_STYLE, sigma);

    sigma is a double, the same as sigma in Gaussian Blur, indicate the sigma value in the process of Gaussian Blur for Soft Glow

  • Sketch

  • Motion Blur

     BitmapFilter.changeStyle(originBitmap, BitmapFilter.SOFT_GLOW_STYLE, xSpeed, ySpeed);

    xSpeed and ySpeed are both integer, indicate the speed in x-axis and y-axis, the origin in the left-upper side

  • Gotham

PS: all options have defalut values, so you can just select the effect and pass nothing, like this:

BitmapFilter.changeStyle(originBitmap, BitmapFilter.MOTION_BLUR_STYLE);

If you have any question, please open an issue and show your code and the program ouput, thanks!

The MIT License (MIT)

Copyright (c) <2012-2016> <ragnarok [email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Comments
  • filters leave a small border around an image untouched

    filters leave a small border around an image untouched

    Dear RagnarokStack,

    I have used your library android-image-filter. It is very helpful and good implemented. Thanks a lot!

    But filters leave a small border around an image untouched, how to solve this problem?

    Sincerely, Y.P.

    opened by pigovsky 7
  • Oil Style not applied fully

    Oil Style not applied fully

    When applying the oil style to a big image (ImageView of size of screen) it doesn't apply the effect to the whole picture as seen here: oil_style

    where you can see that the bottom of the image its still normal.

    opened by Raykud 7
  • About 'android-image-filter' can't show the image

    About 'android-image-filter' can't show the image

    I download your 'android-image-filter' file and it didn't show any error. But when I click 'Select an image' and choose one from my gallery, it can't show the image. It shows 'Please select an image' after I click a filter. And I install the apk, still can't show any image.

    opened by Hweiii 2
  • java.lang.UnsatisfiedLinkError: No implementation found

    java.lang.UnsatisfiedLinkError: No implementation found

    Caused by: java.lang.UnsatisfiedLinkError: No implementation found for int[] com.example.jigneshjc.portraphoto.portra_FILTER.NativeFilterFunc.oilFilter(int[], int, int, int) (tried Java_com_example_jigneshjc_portraphoto_portra_1FILTER_NativeFilterFunc_oilFilter and Java_com_example_jigneshjc_portraphoto_portra_1FILTER_NativeFilterFunc_oilFilter___3IIII) at com.example.jigneshjc.portraphoto.portra_FILTER.NativeFilterFunc.oilFilter(Native Method) at com.example.jigneshjc.portraphoto.portra_FILTER.OilFilter.changeToOil(OilFilter.java:21) at com.example.jigneshjc.portraphoto.portra_FILTER.BitmapFilter.changeStyle(BitmapFilter.java:36)

    opened by pateljc 1
  • Please make compatible library!

    Please make compatible library!

    Hi!

    Now Android Studio (1.5.1) supports very well NDK. I am able to import it, but I cannot found a way to import this project as a library or AAR file. I think it is not difficult to do it so you can add information about how to compile it. Thankyou!

    opened by EzequielAdrianM 1
  • Does this library support Bilateral Filter?

    Does this library support Bilateral Filter?

    Firstly, your work really helps a lot and thank you very much!

    I have checked all the filters, it seems that there is no related filter to Bilateral Filter. Is it because I didn't find the proper name or this library does not support bilateral filter?

    opened by zijing07 1
  • Alpha channel change to black in Gaussian Blur

    Alpha channel change to black in Gaussian Blur

    When I apply Gaussian Blur to a bitmap with alpha channel, the alpha channel changes to black. While the alpha channel is good if I use RenderScript. Is it possible to keep the alpha channel in the filtering process?

    opened by zijing07 1
  • Using SOFT_GLOW crashes app

    Using SOFT_GLOW crashes app

    attempting to use public static final int SOFT_GLOW_STYLE = 16; // soft glow as a filter makes the app crash returning this in the LogCat:

    07-19 19:40:42.149: E/AndroidRuntime(3871): FATAL EXCEPTION: main
    07-19 19:40:42.149: E/AndroidRuntime(3871): java.lang.UnsatisfiedLinkError: softGlow
    07-19 19:40:42.149: E/AndroidRuntime(3871):     at cn.Ragnarok.NativeFilterFunc.softGlow(Native Method)
    07-19 19:40:42.149: E/AndroidRuntime(3871):     at cn.Ragnarok.SoftGlowFilter.softGlowFilter(SoftGlowFilter.java:13)
    07-19 19:40:42.149: E/AndroidRuntime(3871):     at cn.Ragnarok.BitmapFilter.changeStyle(BitmapFilter.java:95)
    07-19 19:40:42.149: E/AndroidRuntime(3871):     at com.mytest.test.activity.PhotoTestActivity.onClick(PhotoTestActivity.java:107)
    07-19 19:40:42.149: E/AndroidRuntime(3871):     at android.view.View.performClick(View.java:2485)
    07-19 19:40:42.149: E/AndroidRuntime(3871):     at android.view.View$PerformClick.run(View.java:9080)
    07-19 19:40:42.149: E/AndroidRuntime(3871):     at android.os.Handler.handleCallback(Handler.java:587)
    07-19 19:40:42.149: E/AndroidRuntime(3871):     at android.os.Handler.dispatchMessage(Handler.java:92)
    07-19 19:40:42.149: E/AndroidRuntime(3871):     at android.os.Looper.loop(Looper.java:130)
    07-19 19:40:42.149: E/AndroidRuntime(3871):     at android.app.ActivityThread.main(ActivityThread.java:3687)
    07-19 19:40:42.149: E/AndroidRuntime(3871):     at java.lang.reflect.Method.invokeNative(Native Method)
    07-19 19:40:42.149: E/AndroidRuntime(3871):     at java.lang.reflect.Method.invoke(Method.java:507)
    07-19 19:40:42.149: E/AndroidRuntime(3871):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
    07-19 19:40:42.149: E/AndroidRuntime(3871):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
    07-19 19:40:42.149: E/AndroidRuntime(3871):     at dalvik.system.NativeStart.main(Native Method)
    

    This is beeing run on a Samsung Galaxy Ace (GT-S5830L) with Android Version 2.3.4 Gingerbread

    opened by Raykud 1
  • nit find any solution of it

    nit find any solution of it

    What went wrong: Execution failed for task ':library:transformNativeLibsWithStripDebugSymbolForDebug'.

    A problem occurred starting process 'command 'D:\androidStudio\sdk\ndk-bundle\toolchains\mips64el-linux-android-4.9\prebuilt\windows-x86_64\bin\mips64el-linux-android-strip''

    opened by silviaror 0
  • java.lang.UnsatisfiedLinkError:  Issues

    java.lang.UnsatisfiedLinkError: Issues

    java.lang.UnsatisfiedLinkError: No implementation found for int[] com.example.cn.Ragnarok.NativeFilterFunc.oilFilter(int[], int, int, int) (tried Java_com_example_cn_Ragnarok_NativeFilterFunc_oilFilter and Java_com_example_cn_Ragnarok_NativeFilterFunc_oilFilter___3IIII) at com.example.cn.Ragnarok.NativeFilterFunc.oilFilter(Native Method) at com.example.cn.Ragnarok.OilFilter.changeToOil(OilFilter.java:19) at com.example.cn.Ragnarok.BitmapFilter.changeStyle(BitmapFilter.java:52) at com.example.ShatteringActivity$ListAdapterEffect$1.onClick(ShatteringActivity.java:837) at android.view.View.performClick(View.java:5246) at android.view.View$PerformClick.run(View.java:21256) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:145)

    opened by manishmas 1
  • UnsatisfiedLinkError on some devices

    UnsatisfiedLinkError on some devices

    I added this library to my projects, it works properly on some devices but it does not on some others. System.loadLibrary line, throws an exception because library cannot be loaded. I unzip the apk and check libAndroidImageFilter.so is created for all architecture.

    There is no common among problematic devices. Some of them are KitKat whereas some other are JellyBean. Most of them are Samsung but there are also several HTC. Also there are a Samsung devices which does not have any crash. Furthermore, even though all of them has armv7 based cpu, there are a few armv7 based devices on which the library is able to run.

    In short, I have no idea why it crashes on some devices.

    opened by harunurhan 3
  • Unexpected stop on the demo

    Unexpected stop on the demo

    Hi, First of all, thank you for the great job on this. I am trying it out thru the demo app in this project.

    However, eveytime when I apply an effect then the demo app stops unexpectedly.

    Here are some examples of what I got when the unexpected stop happens:

    1. Select the LOMO effect in the items menu to apply the LOMO effect. The code goes all the way to the line:47 in cn.Ragnarok.LomoFilter.changeToLomo, which calls NativeFilterFunc.lomoAddBlckRound to get int[] resultPixels. Then, suddenly the demo app stops to cease. The logcat outputs 2 msg:
    • E/dalvikvm(31965): VM aborting
    • A/libc(31965): Fatal signal 6 (SIGABRT) at 0x00007cdd (code=-6), thread 31965 (imagefilterdemo)
    1. This time, try the Relief effect. The code goes untill the line:24 in cn.Ragnarok.ReliefFilter.changeToRelief, which calls Bitmap.createBitmap to get Bitmap returnBitmap. The logcat outputs:
    • E/AndroidRuntime(324): FATAL EXCEPTION: main
    • E/AndroidRuntime(324): Process: com.example.androidimagefilterdemo, PID: 324
    • E/AndroidRuntime(324): java.lang.OutOfMemoryError
    • E/AndroidRuntime(324): at android.graphics.Bitmap.nativeCreate(Native Method)
    • E/AndroidRuntime(324): at android.graphics.Bitmap.createBitmap(Bitmap.java:882)
    • E/AndroidRuntime(324): at android.graphics.Bitmap.createBitmap(Bitmap.java:906)
    • E/AndroidRuntime(324): at cn.Ragnarok.ReliefFilter.changeToRelief(ReliefFilter.java:24)
    • E/AndroidRuntime(324): at cn.Ragnarok.BitmapFilter.changeStyle(BitmapFilter.java:42)
    • E/AndroidRuntime(324): at com.example.androidimagefilterdemo.MainActivity.applyStyle(MainActivity.java:322)
    • E/AndroidRuntime(324): at com.example.androidimagefilterdemo.MainActivity.onItemClick(MainActivity.java:266)
    • E/AndroidRuntime(324): at android.widget.AdapterView.performItemClick(AdapterView.java:299)
    • E/AndroidRuntime(324): at android.widget.AbsListView.performItemClick(AbsListView.java:1113)
    • E/AndroidRuntime(324): at android.widget.AbsListView$PerformClick.run(AbsListView.java:2904)
    • E/AndroidRuntime(324): at android.widget.AbsListView$3.run(AbsListView.java:3638)
    • E/AndroidRuntime(324): at android.os.Handler.handleCallback(Handler.java:733)
    • E/AndroidRuntime(324): at android.os.Handler.dispatchMessage(Handler.java:95)
    • E/AndroidRuntime(324): at android.os.Looper.loop(Looper.java:212)
    • E/AndroidRuntime(324): at android.app.ActivityThread.main(ActivityThread.java:5151)
    • E/AndroidRuntime(324): at java.lang.reflect.Method.invokeNative(Native Method)
    • E/AndroidRuntime(324): at java.lang.reflect.Method.invoke(Method.java:515)
    • E/AndroidRuntime(324): at com.android.internal.os.ZygoteInit$MinvitigethodAndArgsCaller.run(ZygoteInit.java:878)
    • E/AndroidRuntime(324): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
    • E/AndroidRuntime(324): at dalvik.system.NativeStart.main(Native Method)

    Could the memory cause this issue ? What could the root cause ?

    Thank you

    opened by Fischer-L 7
Owner
RagnarokStack
水能载舟 亦可赛艇
RagnarokStack
Awesome Image Picker library will pick images/gifs with beautiful interface. Supports image or gif, Single and Multiple Image selection.

Awesome Image Picker Awesome Image Picker library will pick images/gifs with beautiful interface. Supports image or gif, Single and Multiple Image sel

Prabhakar Thota 162 Sep 13, 2022
This is an Image slider with swipes, Here we used Volley to Image load URL's from JSON! Here we make it very easy way to load images from Internet and We customized the description font style(OpenSans).

ImageSliderWithSwipes This is an Image slider with swipes, Here we used Volley to load URL's from JSON! Here we make it very easy way to load images f

Prabhakar Thota 44 May 31, 2021
Phimp.me Android Phimp.me is an Android image editor app

Phimp.me Android Phimp.me is an Android image editor app that aims to replace proprietary photographing and image apps on smart phones. It offers feat

FOSSASIA 2.6k Jan 6, 2023
An android image compression library.

Compressor Compressor is a lightweight and powerful android image compression library. Compressor will allow you to compress large photos into smaller

Zetra 6.7k Dec 31, 2022
Android widget for cropping and rotating an image.

Cropper The Cropper is an image cropping tool. It provides a way to set an image in XML and programmatically, and displays a resizable crop window on

Edmodo 2.9k Nov 14, 2022
A simple image cropping library for Android.

SimpleCropView The SimpleCropView is an image cropping library for Android. It simplifies your code for cropping image and provides an easily customiz

Issei Aoki 2.5k Dec 28, 2022
Customizable Android full screen image viewer for Fresco library supporting "pinch to zoom" and "swipe to dismiss" gestures. Made by Stfalcon

This project is no longer supported. If you're able to switch from Fresco to any other library that works with the Android's ImageView, please migrate

Stfalcon LLC 1.8k Dec 19, 2022
Dali is an image blur library for Android. It contains several modules for static blurring, live blurring and animations.

Dali Dali is an image blur library for Android. It is easy to use, fast and extensible. Dali contains several modules for either static blurring, live

Patrick Favre-Bulle 1k Dec 1, 2022
An image resizing library for Android

Resizer Inspired by zetbaitsu's Compressor, Resizer is a lightweight and easy-to-use Android library for image scaling. It allows you to resize an ima

Kakit Ho 426 Dec 22, 2022
Simple android image popup Library

Android Image Popup Show image as a popup on a click event or any event. Simply set the image as drawable and thats it!!!. And also you can set width,

Chathura Lakmal 64 Nov 15, 2022
Image loading library for Android

Image Loader Image loader library for Android. Deprecated. See Glide. Features Image transformations Automatic memory and storage caching Ability to l

Yuriy Budiyev 19 May 28, 2022
Image Cropping Library for Android, optimised for Camera / Gallery.

Image Cropping Library for Android, optimised for Camera / Gallery.

CanHub 812 Dec 30, 2022
An Android project containing image recognition and object detection models.

An Android project containing image recognition and object detection models. Users can input images into the deep learning model by taking photos, opening photo albums, and real-time previews on the Android side. After the calculation on the Android side is completed, the model will output the prediction result and show it to the user.

null 7 Nov 27, 2022
An image loading library for android.

Bilder Download Add following to your project's build.gradle allprojects { repositories { ... maven { url 'https://jitpack.io' } } }

Kshitij Sharma 4 Jan 1, 2022
An Android transformation library providing a variety of image transformations for Coil, Glide, Picasso, and Fresco.

An Android transformation library providing a variety of image transformations for Coil, Glide, Picasso, and Fresco.

Daichi Furiya 257 Jan 2, 2023
An image board client based on Gelbooru for android, made from Jetpack Compose 🚀 .

Mejiboard An image board client based on Gelbooru for android, made from Jetpack Compose ?? . Features Material Design UI Easy one-handed operation Li

Agung Watanabe 59 Dec 30, 2022
Image classifier app build in Android Studio.

Android Image Classifier App Strongly based on https://github.com/microsoft/onnxruntime-inference-examples/tree/main/mobile/examples/image_classificat

Luiz Santos 3 Feb 17, 2022
🎨 Modern image loading library for Android. Simple by design, powerful under the hood.

Simple Image Loader Modern image loading library for Android. Simple by design, powerful under the hood. Kotlin: Simple Image Loader is Kotlin-native

Igor Solkin 8 Nov 21, 2022
Android Fading (Circle/ Custom Corner) Image

Android Fading (Circle/ Custom Corner) Image Implementation add maven { url 'https://jitpack.io' } to build.gradle in your project: allprojects {

Aghiad Odeh 1 Jul 5, 2022