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

Blend

public class Blend extends TestBase

Fields Summary
private android.renderscript.ScriptIntrinsicBlend
mBlend
private ScriptC_blend
mBlendHelper
private short
image1Alpha
private short
image2Alpha
String[]
mIntrinsicNames
private android.renderscript.Allocation
image1
private android.renderscript.Allocation
image2
private int
currentIntrinsic
private AdapterView.OnItemSelectedListener
mIntrinsicSpinnerListener
Constructors Summary
Methods Summary
public voidcreateTest(android.content.res.Resources res)


        
        mBlend = ScriptIntrinsicBlend.create(mRS, Element.U8_4(mRS));
        mBlendHelper = new ScriptC_blend(mRS);
        mBlendHelper.set_alpha((short)128);

        image1 = Allocation.createTyped(mRS, mInPixelsAllocation.getType());
        image2 = Allocation.createTyped(mRS, mInPixelsAllocation2.getType());

        mIntrinsicNames = new String[14];
        mIntrinsicNames[0] = "Source";
        mIntrinsicNames[1] = "Destination";
        mIntrinsicNames[2] = "Source Over";
        mIntrinsicNames[3] = "Destination Over";
        mIntrinsicNames[4] = "Source In";
        mIntrinsicNames[5] = "Destination In";
        mIntrinsicNames[6] = "Source Out";
        mIntrinsicNames[7] = "Destination Out";
        mIntrinsicNames[8] = "Source Atop";
        mIntrinsicNames[9] = "Destination Atop";
        mIntrinsicNames[10] = "XOR";
        mIntrinsicNames[11] = "Add";
        mIntrinsicNames[12] = "Subtract";
        mIntrinsicNames[13] = "Multiply";
    
public voidonBar1Changed(int progress)

        image1Alpha = (short)progress;
    
public booleanonBar1Setup(android.widget.SeekBar b, android.widget.TextView t)

        t.setText("Image 1 Alpha");
        b.setMax(255);
        b.setProgress(image1Alpha);
        return true;
    
public voidonBar2Changed(int progress)

        image2Alpha = (short)progress;
    
public booleanonBar2Setup(android.widget.SeekBar b, android.widget.TextView t)

        t.setText("Image 2 Alpha");
        b.setMax(255);
        b.setProgress(image2Alpha);
        return true;
    
public booleanonSpinner1Setup(android.widget.Spinner s)

        s.setAdapter(new ArrayAdapter<String>(
            act, R.layout.spinner_layout, mIntrinsicNames));
        s.setSelection(0, false);
        s.setOnItemSelectedListener(mIntrinsicSpinnerListener);
        return true;
    
public voidrunTest()

        image1.copy2DRangeFrom(0, 0, mInPixelsAllocation.getType().getX(), mInPixelsAllocation.getType().getY(), mInPixelsAllocation, 0, 0);
        image2.copy2DRangeFrom(0, 0, mInPixelsAllocation2.getType().getX(), mInPixelsAllocation2.getType().getY(), mInPixelsAllocation2, 0, 0);

        mBlendHelper.set_alpha(image1Alpha);
        mBlendHelper.forEach_setImageAlpha(image1);

        mBlendHelper.set_alpha(image2Alpha);
        mBlendHelper.forEach_setImageAlpha(image2);

        switch (currentIntrinsic) {
        case 0:
            mBlend.forEachSrc(image1, image2);
            break;
        case 1:
            mBlend.forEachDst(image1, image2);
            break;
        case 2:
            mBlend.forEachSrcOver(image1, image2);
            break;
        case 3:
            mBlend.forEachDstOver(image1, image2);
            break;
        case 4:
            mBlend.forEachSrcIn(image1, image2);
            break;
        case 5:
            mBlend.forEachDstIn(image1, image2);
            break;
        case 6:
            mBlend.forEachSrcOut(image1, image2);
            break;
        case 7:
            mBlend.forEachDstOut(image1, image2);
            break;
        case 8:
            mBlend.forEachSrcAtop(image1, image2);
            break;
        case 9:
            mBlend.forEachDstAtop(image1, image2);
            break;
        case 10:
            mBlend.forEachXor(image1, image2);
            break;
        case 11:
            mBlend.forEachAdd(image1, image2);
            break;
        case 12:
            mBlend.forEachSubtract(image1, image2);
            break;
        case 13:
            mBlend.forEachMultiply(image1, image2);
            break;
        }

        mOutPixelsAllocation.copy2DRangeFrom(0, 0, image2.getType().getX(), image2.getType().getY(), image2, 0, 0);