FileDocCategorySizeDatePackage
Resize.javaAPI DocAndroid 5.1 API2635Thu Mar 12 22:22:54 GMT 2015com.android.rs.image

Resize

public class Resize extends TestBase

Fields Summary
private ScriptC_resize
mScript
private android.renderscript.ScriptIntrinsicResize
mIntrinsic
private android.renderscript.Allocation
mScratchAllocation
private int
mWidth
private int
mHeight
private boolean
mUseIntrinsic
Constructors Summary
public Resize(boolean useIntrinsic)

        mUseIntrinsic = useIntrinsic;
    
Methods Summary
public voidcreateTest(android.content.res.Resources res)

        mWidth = mInPixelsAllocation.getType().getX();
        mHeight = mInPixelsAllocation.getType().getY();
        float scale = 1.f / 32.f;

        Type t = Type.createXY(mRS, mInPixelsAllocation.getElement(),
                               (int)(mWidth * scale), (int)(mHeight * scale));
        mScratchAllocation = Allocation.createTyped(mRS, t);

        // make small buffer
        mScript = new ScriptC_resize(mRS);
        mScript.set_gIn(mInPixelsAllocation);
        mScript.set_gWidthIn(mWidth);
        mScript.set_gHeightIn(mHeight);
        mScript.set_scale(1.f / scale);
        mScript.forEach_nearest(mScratchAllocation);

        // setup normal ops
        mScript.set_gIn(mScratchAllocation);
        mScript.set_gWidthIn(t.getX());
        mScript.set_gHeightIn(t.getY());
        mScript.set_scale(scale);
        //mScript.forEach_nearest(mScratchAllocation);

        mIntrinsic = ScriptIntrinsicResize.create(mRS);
        mIntrinsic.setInput(mScratchAllocation);
    
public voidrunTest()

        if (mUseIntrinsic) {
            mIntrinsic.forEach_bicubic(mOutPixelsAllocation);
        } else {
            mScript.forEach_bicubic(mOutPixelsAllocation);
        }