SepiaFilterpublic class SepiaFilter extends android.filterfw.core.Filter
Fields Summary |
---|
private int | mTileSize | private android.filterfw.core.Program | mProgram | private int | mTarget | private final String | mSepiaShader |
Constructors Summary |
---|
public SepiaFilter(String name)
super(name);
|
Methods Summary |
---|
public android.filterfw.core.FrameFormat | getOutputFormat(java.lang.String portName, android.filterfw.core.FrameFormat inputFormat)
return inputFormat;
| private void | initParameters()
float weights[] = { 805.0f / 2048.0f, 715.0f / 2048.0f, 557.0f / 2048.0f,
1575.0f / 2048.0f, 1405.0f / 2048.0f, 1097.0f / 2048.0f,
387.0f / 2048.0f, 344.0f / 2048.0f, 268.0f / 2048.0f };
mProgram.setHostValue("matrix", weights);
| public void | initProgram(android.filterfw.core.FilterContext context, int target)
switch (target) {
case FrameFormat.TARGET_GPU:
ShaderProgram shaderProgram = new ShaderProgram(context, mSepiaShader);
shaderProgram.setMaximumTileSize(mTileSize);
mProgram = shaderProgram;
break;
default:
throw new RuntimeException("Filter Sharpen does not support frames of " +
"target " + target + "!");
}
mTarget = target;
| public void | process(android.filterfw.core.FilterContext context)
// Get input frame
Frame input = pullInput("image");
FrameFormat inputFormat = input.getFormat();
// Create output frame
Frame output = context.getFrameManager().newFrame(inputFormat);
// Create program if not created already
if (mProgram == null || inputFormat.getTarget() != mTarget) {
initProgram(context, inputFormat.getTarget());
initParameters();
}
// Process
mProgram.process(input, output);
// Push output
pushOutput("image", output);
// Release pushed frame
output.release();
| public void | setupPorts()
addMaskedInputPort("image", ImageFormat.create(ImageFormat.COLORSPACE_RGBA));
addOutputBasedOnInput("image", "image");
|
|