Android GPUImage源码分析(一)简介

Android GPUImage源码分析(一) 简介

cats-oss/android-gpuimage

Android filters based on OpenGL (idea from GPUImage for iOS)

源码链接

GPUImage广泛用于图片处理摄像头摄影视频处理,比如添加滤镜、动态贴纸等功能

要求:

  • Android 2.2 or higher (OpenGL ES 2.0)

简单实用

repositories {
    jcenter()
}

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

使用中带GPUImageView预览时

@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);
}
 

使用中不带预览时

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);
}

常见滤镜效果

Support status of GPUImage for iOS shaders

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

Others

  •  Texture 3x3
  •  Gray Scale

你可能感兴趣的:(Android源码分析,GPUImage源码分析)