Search in sources :

Example 41 with Quad

use of android.filterfw.geometry.Quad in project android_frameworks_base by crdroidandroid.

the class CropFilter method process.

@Override
public void process(FilterContext env) {
    // Get input frame
    Frame imageFrame = pullInput("image");
    Frame boxFrame = pullInput("box");
    createProgram(env, imageFrame.getFormat());
    // Get the box
    Quad box = (Quad) boxFrame.getObjectValue();
    // Create output format
    MutableFrameFormat outputFormat = imageFrame.getFormat().mutableCopy();
    outputFormat.setDimensions(mOutputWidth == -1 ? outputFormat.getWidth() : mOutputWidth, mOutputHeight == -1 ? outputFormat.getHeight() : mOutputHeight);
    // Create output frame
    Frame output = env.getFrameManager().newFrame(outputFormat);
    // Set the program parameters
    if (mProgram instanceof ShaderProgram) {
        ShaderProgram shaderProgram = (ShaderProgram) mProgram;
        shaderProgram.setSourceRegion(box);
    }
    mProgram.process(imageFrame, output);
    // Push output
    pushOutput("image", output);
    // Release pushed frame
    output.release();
}
Also used : Quad(android.filterfw.geometry.Quad) Frame(android.filterfw.core.Frame) ShaderProgram(android.filterfw.core.ShaderProgram) MutableFrameFormat(android.filterfw.core.MutableFrameFormat)

Example 42 with Quad

use of android.filterfw.geometry.Quad in project android_frameworks_base by crdroidandroid.

the class DrawRectFilter method process.

@Override
public void process(FilterContext env) {
    // Get input frame
    Frame imageFrame = pullInput("image");
    Frame boxFrame = pullInput("box");
    // Get the box
    Quad box = (Quad) boxFrame.getObjectValue();
    box = box.scaled(2.0f).translated(-1.0f, -1.0f);
    // Create output frame with copy of input
    GLFrame output = (GLFrame) env.getFrameManager().duplicateFrame(imageFrame);
    // Draw onto output
    output.focus();
    renderBox(box);
    // Push output
    pushOutput("image", output);
    // Release pushed frame
    output.release();
}
Also used : Quad(android.filterfw.geometry.Quad) Frame(android.filterfw.core.Frame) GLFrame(android.filterfw.core.GLFrame) GLFrame(android.filterfw.core.GLFrame)

Aggregations

Quad (android.filterfw.geometry.Quad)42 Frame (android.filterfw.core.Frame)24 ShaderProgram (android.filterfw.core.ShaderProgram)18 Point (android.filterfw.geometry.Point)18 MutableFrameFormat (android.filterfw.core.MutableFrameFormat)12 GLFrame (android.filterfw.core.GLFrame)7 FrameFormat (android.filterfw.core.FrameFormat)6 NativeFrame (android.filterfw.core.NativeFrame)3