Android Image & Camera Filters Based on OpenGL.
Android Image & Camera Filters Based on OpenGL.
A C++ & Java library for Image/Camera/Video filters. PRs are welcomed.
v3.x adds CameraX support (CameraXProvider) and a unified zoom API (ICameraProvider.setZoomRatio).
…Important: The
3.1.2-16kvariants were linked with LLD 17 and can fail to load on 4KB-page-size devices withcan't enable GNU RELRO protection ... Out of memory. Use3.2.0or newer; its 16KB variants are compatible with both 4KB and 16KB devices.
To compile other versions of ffmpeg, see: https://github.com/wysaid/FFmpeg-Android.git
Quick start with Android Studio:
usingCMakeCompile=true to local.propertiesFor detailed build instructions, configuration options, and alternative build methods (VS Code, command line, ndk-build), see docs/build.md.
Precompiled libraries: android-gpuimage-plus-libs
iOS version: ios-gpuimage-plus
Apply a filter with a rule string:
Bitmap srcImage = ...;
// HSL Adjust (hue: 0.02, saturation: -0.31, luminance: -0.17)
String ruleString = "@adjust hsl 0.02 -0.31 -0.17";
Bitmap dstImage = CGENativeLibrary.filterImage_MultipleEffects(srcImage, ruleString, 1.0f);
// Save result
ImageUtil.saveBitmap(dstImage);Custom filters inherit from CGEImageFilterInterface:
…See customFilter_N.cpp for a complete example.
In C++:
// Assumes GL context exists
CGEImageHandlerAndroid handler;
auto* customFilter = new MyCustomFilter();
customFilter->init();
handler.initWithBitmap(env, bitmap);
handler.addImageFilter(customFilter); // Handler takes ownership
handler.processingFilters();
jobject resultBitmap = handler.getResultBitmap(env);If no GL context exists, use
CGESharedGLContext.
In Java:
Use CGENativeLibrary.cgeFilterImageWithCustomFilter or CGEImageHandler directly.
Filter effects are defined by text-based rule strings. See docs/filter-rules.md for complete syntax reference.
Quick example:
// Chain multiple filters with @ separator
String filter = "@curve RGB (0,0) (128,150) (255,255) " +
"@adjust hsl 0.02 -0.31 -0.17 " +
"@blend overlay texture.jpg 80";| Class | Purpose |
|---|---|
CGENativeLibrary |
Main entry — static filter methods |
CGEImageHandler |
Image handler wrapper |
CGEFrameRenderer |
Real-time camera/video renderer |
CGEFrameRecorder |
Video recording (requires FFmpeg) |
Important: GL operations must run on the GL thread:
glSurfaceView.queueEvent(() -> {
// Your GL operations here
});CGE-Tools — open-source desktop companion for creating and previewing CGE filter rules (macOS / Linux / Windows). Latest release: v2.0.0.
This project is built with help from the open-source community. Contributions of code, documentation, tests, bug reports, and reviews are all welcome.
No open issues yet, or sync has not completed.