{"id":15038887,"url":"https://github.com/wysaid/android-gpuimage-plus","last_synced_at":"2025-05-14T06:14:19.690Z","repository":{"id":37587621,"uuid":"46547417","full_name":"wysaid/android-gpuimage-plus","owner":"wysaid","description":"Android Image \u0026 Camera Filters Based on OpenGL. ","archived":false,"fork":false,"pushed_at":"2025-03-20T08:25:41.000Z","size":119959,"stargazers_count":1846,"open_issues_count":322,"forks_count":478,"subscribers_count":96,"default_branch":"master","last_synced_at":"2025-04-11T01:41:49.433Z","etag":null,"topics":["android-gpuimage","cge","filter","opengl"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wysaid.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGE.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2015-11-20T07:47:36.000Z","updated_at":"2025-04-10T06:19:09.000Z","dependencies_parsed_at":"2023-02-10T13:32:06.481Z","dependency_job_id":"32bdf853-5d1f-4c97-bdbd-8a61234e2da8","html_url":"https://github.com/wysaid/android-gpuimage-plus","commit_stats":{"total_commits":481,"total_committers":12,"mean_commits":"40.083333333333336","dds":"0.20166320166320162","last_synced_commit":"61beec3aa422804356ca18b11d71e6921bb36791"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wysaid%2Fandroid-gpuimage-plus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wysaid%2Fandroid-gpuimage-plus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wysaid%2Fandroid-gpuimage-plus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wysaid%2Fandroid-gpuimage-plus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wysaid","download_url":"https://codeload.github.com/wysaid/android-gpuimage-plus/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254083873,"owners_count":22011905,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android-gpuimage","cge","filter","opengl"],"created_at":"2024-09-24T20:40:39.712Z","updated_at":"2025-05-14T06:14:19.672Z","avatar_url":"https://github.com/wysaid.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Android-GPUImage-Plus\n\nA C++ \u0026 Java library for `Image`/`Camera`/`Video` filters. PRs are welcomed.\n\n## New Feature\n\nSee the `image deform demo`.\n\n![screenshots](screenshots/6.gif) ![screenshots](screenshots/5.gif)\n\n## Gradle dependency\n\n```gradle\nallprojects {\n    repositories {\n        maven {\n            // Use github hosted maven repo for now.\n            // Will be uploaded to maven central later.\n            url 'https://maven.wysaid.org/'\n        }\n    }\n}\n\n//Choose only one of them\ndependencies {\n    //All arch: armeabi-v7a, arm64-v8a, x86, x86_64 with video module (ffmpeg bundled)\n    implementation 'org.wysaid:gpuimage-plus:3.0.0'\n\n    //All arch: armeabi-v7a, arm64-v8a, x86, x86_64 without video module (no ffmpeg)\n    implementation 'org.wysaid:gpuimage-plus:3.0.0-min'\n}\n```\n\n\u003e __The jcenter is out of date, please try the source for now. Latest prebuilt versions will be provided soon.__\n\n\u003e To compile other versions of ffmpeg, see: \u003chttps://github.com/wysaid/FFmpeg-Android.git\u003e\n\n## Build\n\n* Important options in `local.properties`:\n  * `usingCMakeCompile=true`: Set to true to compile the native library with CMake. Defaults to false, allowing the use of prebuilt libraries.\n  * `usingCMakeCompileDebug=true`: Set to true to compile the native library in Debug Mode. Defaults to false.\n  * `disableVideoModule=true`: Set to true to disable the video recording feature, which is useful for image-only scenarios. This reduces the size of the native library significantly. Defaults to false.\n  * `enable16kPageSizes=true`: Set to true to enable [16k page sizes](https://developer.android.com/guide/practices/page-sizes#16-kb-impact) for the native library, applicable only in CMake compile mode. Defaults to false.\n\n* Build with `Android Studio` and CMake: (Recommended)\n  * Put `usingCMakeCompile=true` in your `local.properties`\n  * Open the repo with the latest version of `Android Studio`\n  * Waiting for the initialization. (NDK/cmake install)\n  * Done.\n\n* Using `Visual Studio Code`: (Requires __[WSL(Recommended)](https://learn.microsoft.com/en-us/windows/wsl/install)__/__[MinGW](https://osdn.net/projects/mingw/)__/__[Cygwin](https://www.cygwin.com/)__ on Windows.)\n  * Setup ENV variable `ANDROID_HOME` to your Android SDK installation directory.\n  * Open the repo with `Visual Studio Code`\n  * Press `⌘ + shift + B` (Mac) or `ctrl + shift + B` (Win/Linux), choose the option `Enable CMake And Build Project With CMake`.\n  * Done.\n\n* Build with preset tasks: (Requires __[WSL(Recommended)](https://learn.microsoft.com/en-us/windows/wsl/install)__/__[MinGW](https://osdn.net/projects/mingw/)__/__[Cygwin](https://www.cygwin.com/)__ on Windows.)\n\n  ```shell\n  # define the environment variable \"ANDROID_HOME\"\n  # If using Windows, define ANDROID_HOME in Windows Environment Settings by yourself.\n  export ANDROID_HOME=/path/to/android/sdk\n  \n  # Setup Project\n  bash tasks.sh --setup-project\n\n  # Compile with CMake Debug\n  bash tasks.sh --debug --enable-cmake --build\n  # Compile with CMake Release\n  bash tasks.sh --release --enable-cmake --build\n\n  # Start Demo By Command\n  bash tasks.sh --run\n  ```\n\n* Build `JNI` part with ndk-build: (Not recommended)\n\n  ```shell\n  export NDK=path/of/your/ndk\n  cd folder/of/jni (android-gpuimage-plus/library/src/main/jni)\n  \n  #This will make all arch: armeabi, armeabi-v7a arm64-v8a, x86, mips\n  ./buildJNI\n  #Or use \"sh buildJNI\"\n  \n  #Try this if you failed to run the shell above\n  export CGE_USE_VIDEO_MODULE=1\n  $NDK/ndk-build\n  \n  #If you don't want anything except the image filter,\n  #Do as below to build with only cge module\n  #No ffmpeg, opencv or faceTracker.\n  #And remove the loading part of ffmpeg\u0026facetracker\n  $NDK/ndk-build\n  \n  #For Windows user, you should include the `.cmd` extension to `ndk-build` like this:\n  cd \u003cyour\\path\\to\\this\\repo\u003e\\library\\src\\main\\jni\n  \u003cyour\\path\\to\\ndk\u003e\\ndk-build.cmd\n  \n  #Also remember to comment out these line in NativeLibraryLoader\n  //System.loadLibrary(\"ffmpeg\");\n  //CGEFFmpegNativeLibrary.avRegisterAll();\n  ```\n\n\u003e You can find precompiled libs here: [android-gpuimage-plus-libs](https://github.com/wysaid/android-gpuimage-plus-libs) (The precompiled '.so' files are generated with NDK-r23b)\n\nNote that the generated file \"libFaceTracker.so\" is not necessary. So just remove this file if you don't want any feature of it.\n\n* iOS version: [https://github.com/wysaid/ios-gpuimage-plus](https://github.com/wysaid/ios-gpuimage-plus \"http://wysaid.org\")\n\n## Manual\n\n### 1. Usage\n\n___Sample Code for doing a filter with Bitmap___\n\n```java\n//Simply apply a filter to a Bitmap.\n@Override\nprotected void onCreate(Bundle savedInstanceState) {\n    super.onCreate(savedInstanceState);\n    setContentView(R.layout.activity_main);\n\n    Bitmap srcImage = ...;\n\n    //HSL Adjust (hue: 0.02, saturation: -0.31, luminance: -0.17)\n    //Please see the manual for more details.\n    String ruleString = \"@adjust hsl 0.02 -0.31 -0.17\";\n\n    Bitmap dstImage = CGENativeLibrary.filterImage_MultipleEffects(src, ruleString, 1.0f);\n\n    //Then the dstImage is applied with the filter.\n\n    //Save the result image to /sdcard/libCGE/rec_???.jpg.\n    ImageUtil.saveBitmap(dstImage);\n}\n```\n\n### 2. Custom Shader Filter\n\n#### 2.1 Write your own filter\n\n\u003eYour filter must inherit [CGEImageFilterInterfaceAbstract](https://github.com/wysaid/android-gpuimage-plus/blob/master/library/src/main/jni/include/cgeImageFilter.h#L42) or its child class. Most of the filters are inherited from [CGEImageFilterInterface](https://github.com/wysaid/android-gpuimage-plus/blob/master/library/src/main/jni/include/cgeImageFilter.h#L57) because it has many useful functions.\n\n```cpp\n// A simple customized filter to do a color reversal.\nclass MyCustomFilter : public CGE::CGEImageFilterInterface\n{\npublic:\n    \n    bool init()\n    {\n        CGEConstString fragmentShaderString = CGE_SHADER_STRING_PRECISION_H\n        (\n        varying vec2 textureCoordinate;  //defined in 'g_vshDefaultWithoutTexCoord'\n        uniform sampler2D inputImageTexture; // the same to above.\n\n        void main()\n        {\n            vec4 src = texture2D(inputImageTexture, textureCoordinate);\n            src.rgb = 1.0 - src.rgb;  //Simply reverse all channels.\n            gl_FragColor = src;\n        }\n        );\n\n        //m_program is defined in 'CGEImageFilterInterface'\n        return m_program.initWithShaderStrings(g_vshDefaultWithoutTexCoord, s_fsh);\n    }\n\n    //void render2Texture(CGE::CGEImageHandlerInterface* handler, GLuint srcTexture, GLuint vertexBufferID)\n    //{\n    //  //Your own render functions here.\n    //  //Do not override this function to use the CGEImageFilterInterface's.\n    //}\n};\n```\n\n\u003eNote: To add your own shader filter with c++. [Please see the demo for further details](https://github.com/wysaid/android-gpuimage-plus/blob/master/library/src/main/jni/source/customFilter_N.cpp).\n\n#### 2.2 Run your own filter\n\n__In C++, you can use a CGEImageHandler to do that:__\n\n```cpp\n//Assume the gl context already exists:\n//JNIEnv* env = ...;\n//jobject bitmap = ...;\nCGEImageHandlerAndroid handler;\nCustomFilterType* customFilter = new CustomFilterType();\n\n//You should handle the return value (false is returned when failed.)\ncustomFilter-\u003einit();\nhandler.initWithBitmap(env, bitmap);\n\n//The customFilter will be released when the handler' destructor is called.\n//So you don't have to call 'delete customFilter' if you add it into the handler.\nhandler.addImageFilter(customFilter);\n\nhandler.processingFilters(); //Run the filters.\n\njobject resultBitmap = handler.getResultBitmap(env);\n```\n\n\u003eIf no gl context exists, the class [CGESharedGLContext](https://github.com/wysaid/android-gpuimage-plus/blob/master/library/src/main/jni/interface/cgeSharedGLContext.h#L22) may be helpful.\n\n__In Java, you can simply follow the sample:__\n\nSee: [CGENativeLibrary.cgeFilterImageWithCustomFilter](https://github.com/wysaid/android-gpuimage-plus/blob/master/cgeDemo/src/main/java/org/wysaid/cgeDemo/TestCaseActivity.java#L123)\n\n__Or to do with a [CGEImageHandler](https://github.com/wysaid/android-gpuimage-plus/blob/master/library/src/main/java/org/wysaid/nativePort/CGEImageHandler.java#L93)__\n\n### 3. Filter Rule String ###\n\nDoc: \u003chttps://github.com/wysaid/android-gpuimage-plus/wiki\u003e\n\nEn: [https://github.com/wysaid/android-gpuimage-plus/wiki/Parsing-String-Rule-(EN)](https://github.com/wysaid/android-gpuimage-plus/wiki/Parsing-String-Rule-(EN) \"http://wysaid.org\")\n\nCh: [https://github.com/wysaid/android-gpuimage-plus/wiki/Parsing-String-Rule-(ZH)](https://github.com/wysaid/android-gpuimage-plus/wiki/Parsing-String-Rule-(ZH) \"http://wysaid.org\")\n\n## Tool\n\nSome utils are available for creating filters: [https://github.com/wysaid/cge-tools](https://github.com/wysaid/cge-tools \"http://wysaid.org\")\n\n[![Tool](https://raw.githubusercontent.com/wysaid/cge-tools/master/screenshots/0.jpg \"cge-tool\")](https://github.com/wysaid/cge-tools)\n\n## License\n\n[MIT License](https://github.com/wysaid/android-gpuimage-plus/blob/master/LICENSE)\n\n## Donate\n\nAlipay:\n\n![Alipay](https://raw.githubusercontent.com/wysaid/android-gpuimage-plus/master/screenshots/alipay.jpg \"alipay\")\n\nPaypal:\n\n[![Paypal](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif \"Paypal\")](http://blog.wysaid.org/p/donate.html)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwysaid%2Fandroid-gpuimage-plus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwysaid%2Fandroid-gpuimage-plus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwysaid%2Fandroid-gpuimage-plus/lists"}