Search in sources :

Example 96 with Frame

use of android.filterfw.core.Frame in project android_frameworks_base by DirtyUnicorns.

the class FixedRotationFilter method process.

@Override
public void process(FilterContext context) {
    Frame input = pullInput("image");
    if (mRotation == 0) {
        pushOutput("image", input);
        return;
    }
    FrameFormat inputFormat = input.getFormat();
    // Create program if not created already
    if (mProgram == null) {
        mProgram = ShaderProgram.createIdentity(context);
    }
    MutableFrameFormat outputFormat = inputFormat.mutableCopy();
    int width = inputFormat.getWidth();
    int height = inputFormat.getHeight();
    Point p1 = new Point(0.0f, 0.0f);
    Point p2 = new Point(1.0f, 0.0f);
    Point p3 = new Point(0.0f, 1.0f);
    Point p4 = new Point(1.0f, 1.0f);
    Quad sourceRegion;
    switch(((int) Math.round(mRotation / 90f)) % 4) {
        case 1:
            sourceRegion = new Quad(p3, p1, p4, p2);
            outputFormat.setDimensions(height, width);
            break;
        case 2:
            sourceRegion = new Quad(p4, p3, p2, p1);
            break;
        case 3:
            sourceRegion = new Quad(p2, p4, p1, p3);
            outputFormat.setDimensions(height, width);
            break;
        case 0:
        default:
            sourceRegion = new Quad(p1, p2, p3, p4);
            break;
    }
    // Create output frame
    Frame output = context.getFrameManager().newFrame(outputFormat);
    // Set the source region
    mProgram.setSourceRegion(sourceRegion);
    // Process
    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) Quad(android.filterfw.geometry.Quad) Frame(android.filterfw.core.Frame) MutableFrameFormat(android.filterfw.core.MutableFrameFormat) Point(android.filterfw.geometry.Point) Point(android.filterfw.geometry.Point)

Example 97 with Frame

use of android.filterfw.core.Frame in project android_frameworks_base by DirtyUnicorns.

the class GrainFilter method process.

@Override
public void process(FilterContext context) {
    // Get input frame
    Frame input = pullInput("image");
    FrameFormat inputFormat = input.getFormat();
    FrameFormat noiseFormat = ImageFormat.create(inputFormat.getWidth() / 2, inputFormat.getHeight() / 2, ImageFormat.COLORSPACE_RGBA, FrameFormat.TARGET_GPU);
    // Create noise frame
    Frame noiseFrame = context.getFrameManager().newFrame(inputFormat);
    // Create output frame
    Frame output = context.getFrameManager().newFrame(inputFormat);
    // Create program if not created already
    if (mNoiseProgram == null || mGrainProgram == null || inputFormat.getTarget() != mTarget) {
        initProgram(context, inputFormat.getTarget());
        updateParameters();
    }
    // Check if the frame size has changed
    if (inputFormat.getWidth() != mWidth || inputFormat.getHeight() != mHeight) {
        updateFrameSize(inputFormat.getWidth(), inputFormat.getHeight());
    }
    Frame[] empty = {};
    mNoiseProgram.process(empty, noiseFrame);
    // Process
    Frame[] inputs = { input, noiseFrame };
    mGrainProgram.process(inputs, output);
    // Push output
    pushOutput("image", output);
    // Release pushed frame
    output.release();
    noiseFrame.release();
}
Also used : FrameFormat(android.filterfw.core.FrameFormat) Frame(android.filterfw.core.Frame)

Example 98 with Frame

use of android.filterfw.core.Frame in project android_frameworks_base by DirtyUnicorns.

the class ImageCombineFilter method process.

@Override
public void process(FilterContext context) {
    // Pull input frames
    int i = 0;
    Frame[] inputs = new Frame[mInputNames.length];
    for (String inputName : mInputNames) {
        inputs[i++] = pullInput(inputName);
    }
    // Create output frame
    Frame output = context.getFrameManager().newFrame(inputs[0].getFormat());
    // Make sure we have a program
    updateProgramWithTarget(inputs[0].getFormat().getTarget(), context);
    // Process
    mProgram.process(inputs, output);
    // Push output
    pushOutput(mOutputName, output);
    // Release pushed frame
    output.release();
}
Also used : Frame(android.filterfw.core.Frame)

Example 99 with Frame

use of android.filterfw.core.Frame in project android_frameworks_base by DirtyUnicorns.

the class ToRGBAFilter method process.

@Override
public void process(FilterContext context) {
    // Get input frame
    Frame input = pullInput("image");
    createProgram(context, input.getFormat());
    // Create output frame
    Frame output = context.getFrameManager().newFrame(getConvertedFormat(input.getFormat()));
    // Process
    mProgram.process(input, output);
    // Push output
    pushOutput("image", output);
    // Release pushed frame
    output.release();
}
Also used : Frame(android.filterfw.core.Frame)

Example 100 with Frame

use of android.filterfw.core.Frame in project android_frameworks_base by DirtyUnicorns.

the class ToRGBFilter method process.

@Override
public void process(FilterContext context) {
    // Get input frame
    Frame input = pullInput("image");
    createProgram(context, input.getFormat());
    // Create output frame
    Frame output = context.getFrameManager().newFrame(getConvertedFormat(input.getFormat()));
    // Process
    mProgram.process(input, output);
    // Push output
    pushOutput("image", output);
    // Release pushed frame
    output.release();
}
Also used : Frame(android.filterfw.core.Frame)

Aggregations

Frame (android.filterfw.core.Frame)414 FrameFormat (android.filterfw.core.FrameFormat)198 GLFrame (android.filterfw.core.GLFrame)73 MutableFrameFormat (android.filterfw.core.MutableFrameFormat)47 NativeFrame (android.filterfw.core.NativeFrame)38 Quad (android.filterfw.geometry.Quad)24 GLEnvironment (android.filterfw.core.GLEnvironment)18 ShaderProgram (android.filterfw.core.ShaderProgram)18 ByteBuffer (java.nio.ByteBuffer)18 Point (android.filterfw.geometry.Point)12 IOException (java.io.IOException)12 FrameManager (android.filterfw.core.FrameManager)6 Bitmap (android.graphics.Bitmap)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)6 Map (java.util.Map)6 SortedMap (java.util.SortedMap)6 TreeMap (java.util.TreeMap)6 CachedFrameManager (android.filterfw.core.CachedFrameManager)1