Search in sources :

Example 11 with GLFrame

use of android.filterfw.core.GLFrame in project android_frameworks_base by crdroidandroid.

the class ResizeFilter method process.

@Override
public void process(FilterContext env) {
    // Get input frame
    Frame input = pullInput("image");
    createProgram(env, input.getFormat());
    // Create output frame
    MutableFrameFormat outputFormat = input.getFormat().mutableCopy();
    if (mKeepAspectRatio) {
        FrameFormat inputFormat = input.getFormat();
        mOHeight = mOWidth * inputFormat.getHeight() / inputFormat.getWidth();
    }
    outputFormat.setDimensions(mOWidth, mOHeight);
    Frame output = env.getFrameManager().newFrame(outputFormat);
    // Process
    if (mGenerateMipMap) {
        GLFrame mipmapped = (GLFrame) env.getFrameManager().newFrame(input.getFormat());
        mipmapped.setTextureParameter(GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR_MIPMAP_NEAREST);
        mipmapped.setDataFromFrame(input);
        mipmapped.generateMipMap();
        mProgram.process(mipmapped, output);
        mipmapped.release();
    } else {
        mProgram.process(input, output);
    }
    // Push output
    pushOutput("image", output);
    // Release pushed frame
    output.release();
}
Also used : FrameFormat(android.filterfw.core.FrameFormat) MutableFrameFormat(android.filterfw.core.MutableFrameFormat) Frame(android.filterfw.core.Frame) GLFrame(android.filterfw.core.GLFrame) GLFrame(android.filterfw.core.GLFrame) MutableFrameFormat(android.filterfw.core.MutableFrameFormat)

Example 12 with GLFrame

use of android.filterfw.core.GLFrame 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

Frame (android.filterfw.core.Frame)12 GLFrame (android.filterfw.core.GLFrame)12 FrameFormat (android.filterfw.core.FrameFormat)6 MutableFrameFormat (android.filterfw.core.MutableFrameFormat)6 Quad (android.filterfw.geometry.Quad)6 NativeFrame (android.filterfw.core.NativeFrame)2