FileDocCategorySizeDatePackage
BitmapOverlayFilter.javaAPI DocAndroid 5.1 API4445Thu Mar 12 22:22:30 GMT 2015android.filterpacks.imageproc

BitmapOverlayFilter

public class BitmapOverlayFilter extends android.filterfw.core.Filter
hide

Fields Summary
private android.graphics.Bitmap
mBitmap
private int
mTileSize
private android.filterfw.core.Program
mProgram
private android.filterfw.core.Frame
mFrame
private int
mTarget
private final String
mOverlayShader
Constructors Summary
public BitmapOverlayFilter(String name)


       
        super(name);
    
Methods Summary
private android.filterfw.core.FramecreateBitmapFrame(android.filterfw.core.FilterContext context)

        FrameFormat format = ImageFormat.create(mBitmap.getWidth(),
                                                mBitmap.getHeight(),
                                                ImageFormat.COLORSPACE_RGBA,
                                                FrameFormat.TARGET_GPU);

        Frame frame = context.getFrameManager().newFrame(format);
        frame.setBitmap(mBitmap);

        mBitmap.recycle();
        mBitmap = null;

        return frame;
    
public android.filterfw.core.FrameFormatgetOutputFormat(java.lang.String portName, android.filterfw.core.FrameFormat inputFormat)

        return inputFormat;
    
public voidinitProgram(android.filterfw.core.FilterContext context, int target)

        switch (target) {
            case FrameFormat.TARGET_GPU:
                ShaderProgram shaderProgram = new ShaderProgram(context, mOverlayShader);
                shaderProgram.setMaximumTileSize(mTileSize);
                mProgram = shaderProgram;
                break;

            default:
                throw new RuntimeException("Filter FisheyeFilter does not support frames of " +
                    "target " + target + "!");
        }
        mTarget = target;
    
public voidprocess(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());
        }

        if (mBitmap != null) {
            Frame frame = createBitmapFrame(context);
            // Process
            Frame[] inputs = {input, frame};
            mProgram.process(inputs, output);

            frame.release();
        } else {
            output.setDataFromFrame(input);
        }

        // Push output
        pushOutput("image", output);

        // Release pushed frame
        output.release();
    
public voidsetupPorts()

        addMaskedInputPort("image", ImageFormat.create(ImageFormat.COLORSPACE_RGBA));
        addOutputBasedOnInput("image", "image");
    
public voidtearDown(android.filterfw.core.FilterContext context)

        if (mFrame != null) {
            mFrame.release();
            mFrame = null;
        }