wasabeef /android-gpuimage
Android filters based on OpenGL (idea from GPUImage for iOS)
★ 9,155⑂ 2,290👁 396⑃ 134● 419▤ 0
+0
日增长
9,155
stars
2,290
forks
396
watchers
134
prs
419
issues
0
releases
README
GPUImage for Android

Idea from: iOS GPUImage framework
Goal is to have something as similar to GPUImage as possible. Vertex and fragment shaders are exactly the same. That way it makes it easier to port filters from GPUImage iOS to Android.
Requirements
Android 2.2 or higher (OpenGL ES 2.0)
Usage
Gradle dependency
groovy
repositories {
mavenCentral()
}
dependencies {
implementation 'jp.co.cyberagent.android:gpuimage:2.x.x'
}
Sample Code
With preview:
Java:
java
@Override
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity);
Uri imageUri = ...;
gpuImage = new GPUImage(this);
gpuImage.setGLSurfaceView((GLSurfaceView) findViewById(R.id.surfaceView));
gpuImage.setImage(imageUri); // this loads image on the current thread, should be run in a thread
gpuImage.setFilter(new GPUImageSepiaFilter());
// Later when image should be saved saved:
gpuImage.saveToPictures("GPUImage", "ImageWithFilter.jpg", null);
}
Kotlin:
kotlin
public override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_gallery)
val imageUri: Uri = ...
gpuImage = GPUImage(this)
gpuImage.setGLSurfaceView(findViewById(R.id.surfaceView))
gpuImage.setImage(imageUri) // this loads image on the current thread, should be run in a thread
gpuImage.setFilter(GPUImageSepiaFilter())
// Later when image should be saved saved:
gpuImage.saveToPictures("GPUImage", "ImageWithFilter.jpg", null)
}
Using GPUImageView
xml
Java:
java
@Override
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity);
Uri imageUri = ...;
gpuImageView = findViewById(R.id.gpuimageview);
gpuImageView.setImage(imageUri); // this loads image on the current thread, should be run in a thread
gpuImageView.setFilter(new GPUImageSepiaFilter());
// Later when image should be saved saved:
gpuImageView.saveToPictures("GPUImage", "ImageWithFilter.jpg", null);
}
Kotlin:
kotlin
public override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_gallery)
val imageUri: Uri = ...
gpuImageView = findViewById(R.id.gpuimageview)
gpuImageView.setImage(imageUri) // this loads image on the current thread, should be run in a thread
gpuImageView.setFilter(GPUImageSepiaFilter())
// Later when image should be saved saved:
gpuImageView.saveToPictures("GPUImage", "ImageWithFilter.jpg", null)
}
Without preview:
Java:
java
public void onCreate(final Bundle savedInstanceState) {
public void onCreate(final Bundle savedInstanceState) {
Uri imageUri = ...;
gpuImage = new GPUImage(context);
gpuImage.setFilter(new GPUImageSobelEdgeDetectTop issues
#260How to use Group filters with opacity?16 comments · 2016-03-09#248no libgpuimage-library.so16 comments · 2016-01-27#238The image has been cut off16 comments · 2016-01-05#39Enable transparency16 comments · 2013-05-31#557Not compatible with 16 KB PageSize15 comments · 2025-06-26#20Process Video in the Background14 comments · 2013-03-19#189GPUIImageView Render Blank/Black in RecyclerView after scroll13 comments · 2015-07-06#156problems with grandle ndk on android studio 13 comments · 2015-01-19