-
public interface FilterA Filter is a real time filter that operates onto the camera preview, plus any snapshot media taken with takePictureSnapshot and takeVideoSnapshot. You can apply filters to the camera engine using setFilter. The default filter is called NoFilter and can be used to restore the normal preview. A lof of other filters are collected in the Filters class. Advanced users can create custom filters using GLES. It is recommended to extend BaseFilter instead of this class. All Filters should have a no-arguments public constructor. This ensures that you can pass the filter class to XML attribute
{@code app:cameraFilter}, and also helps BaseFilter automatically make a copy of the filter. Parameterized filters can implement OneParameterFilter and TwoParameterFilter to receive parameters in the 0F-1F range. This helps in making filter copies and also let us map the filter parameter to gestures.
-
-
Method Summary
Modifier and Type Method Description abstract StringgetVertexShader()Returns a String containing the vertex shader. abstract StringgetFragmentShader()Returns a String containing the fragment shader. abstract voidonCreate(int programHandle)The filter program was just created. abstract voidonDestroy()The filter program is about to be destroyed. abstract voiddraw(long timestampUs, @NonNull() Array<float> transformMatrix)Called to render the actual texture. abstract voidsetSize(int width, int height)Called anytime the output size changes. abstract Filtercopy()Clones this filter creating a new instance of it.If it has any important parameters, these should be passedto the new instance. -
-
Method Detail
-
getVertexShader
@NonNull() abstract String getVertexShader()
Returns a String containing the vertex shader.Together with getFragmentShader, this will be used tocreate the OpenGL program.
-
getFragmentShader
@NonNull() abstract String getFragmentShader()
Returns a String containing the fragment shader.Together with getVertexShader, this will be used tocreate the OpenGL program.
-
onCreate
abstract void onCreate(int programHandle)
The filter program was just created. We pass in a handle to the OpenGLprogram that was created, so you can fetch pointers.
- Parameters:
programHandle- handle
-
onDestroy
abstract void onDestroy()
The filter program is about to be destroyed.
-
draw
abstract void draw(long timestampUs, @NonNull() Array<float> transformMatrix)
Called to render the actual texture. The given transformation matrixshould be applied.
- Parameters:
timestampUs- timestamp in microsecondstransformMatrix- matrix
-
setSize
abstract void setSize(int width, int height)
Called anytime the output size changes.
- Parameters:
width- widthheight- height
-
-
-
-