MCPcopy Index your code
hub / github.com/wasabeef/android-gpuimage

github.com/wasabeef/android-gpuimage @v2.0.4

repository ↗ · DeepWiki ↗ · release v2.0.4 ↗ · + Follow
697 symbols 1,396 edges 97 files 149 documented · 21%
README

GPUImage for Android

License Download Build Status

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

repositories {
    jcenter()
}

dependencies {
    implementation 'jp.co.cyberagent.android:gpuimage:2.x.x'
}

Sample Code

With preview:

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:

public override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_gallery)

    val imageUri: Uri = ...
    gpuImage = GPUImage(this)
    gpuImage.setGLSurfaceView(findViewById<GLSurfaceView>(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

<jp.co.cyberagent.android.gpuimage.GPUImageView
    android:id="@+id/gpuimageview"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:gpuimage_show_loading="false"
    app:gpuimage_surface_type="texture_view" /> 

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:

public override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_gallery)

    val imageUri: Uri = ...
    gpuImageView = findViewById<GPUImageView>(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:

public void onCreate(final Bundle savedInstanceState) {
    public void onCreate(final Bundle savedInstanceState) {
    Uri imageUri = ...;
    gpuImage = new GPUImage(context);
    gpuImage.setFilter(new GPUImageSobelEdgeDetection());
    gpuImage.setImage(imageUri);
    gpuImage.saveToPictures("GPUImage", "ImageWithFilter.jpg", null);
}

Kotlin:

public override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_gallery)
    val imageUri: Uri = ...
    gpuImage = GPUImage(this)
    gpuImage.setFilter(GPUImageSepiaFilter())
    gpuImage.setImage(imageUri)
    gpuImage.saveToPictures("GPUImage", "ImageWithFilter.jpg", null)
}

Support status of GPUImage for iOS shaders

  • [x] Saturation
  • [x] Contrast
  • [x] Brightness
  • [x] Levels
  • [x] Exposure
  • [x] RGB
  • [x] RGB Diation
  • [x] Hue
  • [x] White Balance
  • [x] Monochrome
  • [x] False Color
  • [x] Sharpen
  • [ ] Unsharp Mask
  • [x] Transform Operation
  • [ ] Crop
  • [x] Gamma
  • [x] Highlights and Shadows
  • [x] Haze
  • [x] Sepia Tone
  • [ ] Amatorka
  • [ ] Miss Etikate
  • [ ] Soft Elegance
  • [x] Color Inversion
  • [x] Solarize
  • [x] Vibrance
  • [ ] Highlight and Shadow Tint
  • [x] Luminance
  • [x] Luminance Threshold
  • [ ] Average Color
  • [ ] Average Luminance
  • [ ] Average Luminance Threshold
  • [ ] Adaptive Threshold
  • [ ] Polar Pixellate
  • [x] Pixellate
  • [ ] Polka Dot
  • [x] Halftone
  • [x] Crosshatch
  • [x] Sobel Edge Detection
  • [ ] Prewitt Edge Detection
  • [ ] Canny Edge Detection
  • [x] Threshold Sobel EdgeDetection
  • [ ] Harris Corner Detector
  • [ ] Noble Corner Detector
  • [ ] Shi Tomasi Feature Detector
  • [ ] Colour FAST Feature Detector
  • [ ] Low Pass Filter
  • [ ] High Pass Filter
  • [x] Sketch Filter
  • [ ] Threshold Sketch Filter
  • [x] Toon Filter
  • [x] SmoothToon Filter
  • [ ] Tilt Shift
  • [x] CGA Colorspace Filter
  • [x] Posterize
  • [x] Convolution 3x3
  • [x] Emboss Filter
  • [x] Laplacian
  • [x] Chroma Keying
  • [x] Kuwahara Filter
  • [ ] Kuwahara Radius3 Filter
  • [x] Vignette
  • [x] Gaussian Blur
  • [x] Box Blur
  • [x] Bilateral Blur
  • [ ] Motion Blur
  • [x] Zoom Blur
  • [ ] iOS Blur
  • [ ] Median Filter
  • [x] Swirl Distortion
  • [x] Bulge Distortion
  • [ ] Pinch Distortion
  • [x] Sphere Refraction
  • [x] Glass Sphere Refraction
  • [ ] Stretch Distortion
  • [x] Dilation
  • [ ] Erosion
  • [ ] Opening Filter
  • [ ] Closing Filter
  • [ ] Local Binary Pattern
  • [ ] Color Local Binary Pattern
  • [x] Dissolve Blend
  • [x] Chroma Key Blend
  • [x] Add Blend
  • [x] Divide Blend
  • [x] Multiply Blend
  • [x] Overlay Blend
  • [x] Lighten Blend
  • [x] Darken Blend
  • [x] Color Burn Blend
  • [x] Color Dodge Blend
  • [x] Linear Burn Blend
  • [x] Screen Blend
  • [x] Difference Blend
  • [x] Subtract Blend
  • [x] Exclusion Blend
  • [x] HardLight Blend
  • [x] SoftLight Blend
  • [x] Color Blend
  • [x] Hue Blend
  • [x] Saturation Blend
  • [x] Luminosity Blend
  • [x] Normal Blend
  • [x] Source Over Blend
  • [x] Alpha Blend
  • [x] Non Maximum Suppression
  • [ ] Thresholded Non Maximum Suppression
  • [ ] Directional Non Maximum Suppression
  • [x] Opacity
  • [x] Weak Pixel Inclusion Filter
  • [x] Color Matrix
  • [x] Directional Sobel Edge Detection
  • [x] Lookup
  • [x] Tone Curve (*.acv files)

Others

  • [x] Texture 3x3
  • [x] Gray Scale

Gradle

Make sure that you run the clean target when using maven.

gradle clean assemble

License

Copyright 2018 CyberAgent, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Extension points exported contracts — how you extend this code

EGLConfigChooser (Interface)
An interface for choosing an EGLConfig configuration from a list of potential configurations. This interface must be [4 …
library/src/main/java/jp/co/cyberagent/android/gpuimage/GLTextureView.java
EGLContextFactory (Interface)
An interface for customizing the eglCreateContext and eglDestroyContext calls. This interface must be implemented by [2 …
library/src/main/java/jp/co/cyberagent/android/gpuimage/GLTextureView.java
EGLWindowSurfaceFactory (Interface)
An interface for customizing the eglCreateWindowSurface and eglDestroySurface calls. This interface must be implemen [2 …
library/src/main/java/jp/co/cyberagent/android/gpuimage/GLTextureView.java
Renderer (Interface)
A generic renderer interface. The renderer is responsible for making OpenGL calls to render a frame. GLTextureVi [1 implementers]
library/src/main/java/jp/co/cyberagent/android/gpuimage/GLTextureView.java
GLWrapper (Interface)
An interface used to wrap a GL interface. Typically used for implementing debugging and tracing on top of the default
library/src/main/java/jp/co/cyberagent/android/gpuimage/GLTextureView.java

Core symbols most depended-on inside this repo

getProgram
called by 92
library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageFilter.java
setFloat
called by 62
library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageFilter.java
setFloatVec3
called by 13
library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageFilter.java
runOnDraw
called by 13
library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageFilter.java
ifNeedInit
called by 12
library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageFilter.java
addFilter
called by 10
library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageFilterGroup.java
flip
called by 9
library/src/main/java/jp/co/cyberagent/android/gpuimage/util/TextureRotationUtil.java
addDistance
called by 8
library/src/main/java/jp/co/cyberagent/android/gpuimage/GPUImageRenderer.java

Shape

Method 574
Class 113
Interface 8
Enum 2

Languages

Java100%

Modules by API surface

library/src/main/java/jp/co/cyberagent/android/gpuimage/GLTextureView.java106 symbols
library/src/main/java/jp/co/cyberagent/android/gpuimage/GPUImage.java53 symbols
library/src/main/java/jp/co/cyberagent/android/gpuimage/GPUImageView.java41 symbols
library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageFilter.java32 symbols
library/src/main/java/jp/co/cyberagent/android/gpuimage/GPUImageRenderer.java25 symbols
library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageToneCurveFilter.java17 symbols
library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageTransformFilter.java12 symbols
library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageTwoInputFilter.java11 symbols
library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageFilterGroup.java11 symbols
library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageSphereRefractionFilter.java9 symbols
library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageLevelsFilter.java9 symbols
library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageGlassSphereFilter.java9 symbols

For agents

$ claude mcp add android-gpuimage \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact