FileDocCategorySizeDatePackage
Grain.javaAPI DocAndroid 5.1 API2502Thu Mar 12 22:22:54 GMT 2015com.android.rs.image2

Grain

public class Grain extends TestBase

Fields Summary
private ScriptC_grain
mScript
private Allocation
mNoise
private Allocation
mNoise2
Constructors Summary
Methods Summary
public voidcreateTest(android.content.res.Resources res)

        int width = mInPixelsAllocation.getType().getX();
        int height = mInPixelsAllocation.getType().getY();

        int noiseW = findHighBit(width);
        int noiseH = findHighBit(height);
        if (noiseW > 9) {
            noiseW = 9;
        }
        if (noiseH > 9) {
            noiseH = 9;
        }
        noiseW = 1 << noiseW;
        noiseH = 1 << noiseH;

        Type.Builder tb = new Type.Builder(mRS, Element.U8(mRS));
        tb.setX(noiseW);
        tb.setY(noiseH);
        mNoise = Allocation.createTyped(mRS, tb.create());
        mNoise2 = Allocation.createTyped(mRS, tb.create());

        mScript = new ScriptC_grain(mRS);
        mScript.set_gWMask(noiseW - 1);
        mScript.set_gHMask(noiseH - 1);
        mScript.set_gNoiseStrength(0.5f);
        mScript.set_gBlendSource(mNoise);
        mScript.set_gNoise(mNoise2);
    
private intfindHighBit(int v)

        int bit = 0;
        while (v > 1) {
            bit++;
            v >>= 1;
        }
        return bit;
    
public voidonBar1Changed(int progress)

        float s = progress / 100.0f;
        mScript.set_gNoiseStrength(s);
    
public booleanonBar1Setup(android.widget.SeekBar b, android.widget.TextView t)

        t.setText("Strength");
        b.setProgress(50);
        return true;
    
public voidrunTest()

        mScript.forEach_genRand(mNoise);
        mScript.forEach_blend9(mNoise2);
        mScript.forEach_root(mInPixelsAllocation, mOutPixelsAllocation);