FileDocCategorySizeDatePackage
BitmapSource.javaAPI DocAndroid 5.1 API3401Thu Mar 12 22:22:30 GMT 2015android.filterpacks.imageproc

BitmapSource

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

Fields Summary
String
mTargetString
private android.graphics.Bitmap
mBitmap
private boolean
mRecycleBitmap
boolean
mRepeatFrame
private int
mTarget
private android.filterfw.core.Frame
mImageFrame
Constructors Summary
public BitmapSource(String name)


       
        super(name);
    
Methods Summary
public voidfieldPortValueUpdated(java.lang.String name, android.filterfw.core.FilterContext context)

        // Clear image (to trigger reload) in case parameters have been changed
        if (name.equals("bitmap") || name.equals("target")) {
            if (mImageFrame != null) {
                mImageFrame.release();
                mImageFrame = null;
            }
        }
    
public voidloadImage(android.filterfw.core.FilterContext filterContext)

        // Create frame with bitmap
        mTarget = FrameFormat.readTargetString(mTargetString);
        FrameFormat outputFormat = ImageFormat.create(mBitmap.getWidth(),
                                                      mBitmap.getHeight(),
                                                      ImageFormat.COLORSPACE_RGBA,
                                                      mTarget);
        mImageFrame = filterContext.getFrameManager().newFrame(outputFormat);
        mImageFrame.setBitmap(mBitmap);
        mImageFrame.setTimestamp(Frame.TIMESTAMP_UNKNOWN);

        // Free up space used by bitmap
        if (mRecycleBitmap) {
            mBitmap.recycle();
        }
        mBitmap = null;
    
public voidprocess(android.filterfw.core.FilterContext context)

        if (mImageFrame == null) {
            loadImage(context);
        }

        pushOutput("image", mImageFrame);

        if (!mRepeatFrame) {
            closeOutputPort("image");
        }
    
public voidsetupPorts()

        // Setup output format
        FrameFormat outputFormat = ImageFormat.create(ImageFormat.COLORSPACE_RGBA,
                                                      FrameFormat.TARGET_UNSPECIFIED);

        // Add output port
        addOutputPort("image", outputFormat);
    
public voidtearDown(android.filterfw.core.FilterContext env)

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