Android Allocation - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android Allocation class.

This code example shows how to use the following methods:copyTo
        mScript.bind_ideal(mIdealPixelsAllocation);
        mScript.bind_given(mGivenPixelsAllocation);
 
        mOutputPixelsAllocation = Allocation.createFromBitmap(mRS, output,
                Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_SCRIPT);
        mScript.forEach_displayDifference(mOutputPixelsAllocation, mOutputPixelsAllocation);
        mOutputPixelsAllocation.copyTo(output);
    } 
 
    public static float calcError(Bitmap ideal, Bitmap given) {
        if (LOG_TIMING) {
            startMillis = System.currentTimeMillis();
        } 
 
        int interestingRegions = 0;
        for (int x = 0; x < ideal.getWidth(); x += REGION_SIZE) {
            for (int y = 0; y < ideal.getWidth(); y += REGION_SIZE) {
                if (inspectRegion(ideal, x, y)) {
                    interestingRegions++;
                } 
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getConfig, getHeight, getWidth, createFromBitmap
        if (input_image < BITMAP_LOW || input_image > BITMAP_HI) {
            Log.e(TAG, "Invalid slot " + input_image + " for HDR input");
            return; 
        } 
 
        mInBitmapAlloc[input_image] = Allocation.createFromBitmap(mRS, input, 
                                          Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_SCRIPT);
 
        // Bind our allocations to our script 
        switch (input_image) {
        case BITMAP_LOW:
            mScript.bind_gInputLow(mInBitmapAlloc[BITMAP_LOW]);
            break; 
 
        case BITMAP_MID:
            mScript.bind_gInputMid(mInBitmapAlloc[BITMAP_MID]);
            break; 
 
        case BITMAP_HI:
            mScript.bind_gInputHi(mInBitmapAlloc[BITMAP_HI]);

8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:ioSendOutput, setSurfaceTexture
        public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) {
            mOutPixelsAllocation.setSurfaceTexture(surface);
        } 
 
        public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) {
            mOutPixelsAllocation.setSurfaceTexture(surface);
            filterAlloc(mOutPixelsAllocation, mSampler);
        } 
 
        public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) {
            mOutPixelsAllocation.setSurfaceTexture(null);
            return true; 
        } 
    } 
 
    private final String TAG = "Img";
    private Bitmap mBitmapTwoByTwo;
    private Bitmap mBitmapCity;
 
    private TextView mBenchmarkResult;

8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:ioSendOutput, setSurfaceTexture
        b.recycle();
        return b2;
    } 
 
    private void filter() { 
        mScript.forEach_root(mInPixelsAllocation, mOutPixelsAllocation);
        mOutPixelsAllocation.ioSendOutput();
        mRS.finish();
    } 
 
    public void benchmark(View v) {
        filter(); 
        long t = java.lang.System.currentTimeMillis();
        filter(); 
        t = java.lang.System.currentTimeMillis() - t;
        mDisplayView.invalidate();
        mBenchmarkResult.setText("Result: " + t + " ms");
    } 
 
 

7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:copyFrom, getType
            } else { 
                mBlurInputAllocation.copyFrom(src);
            } 
 
            if (mBlurOutputAllocation == null) {
                mBlurOutputAllocation = Allocation.createTyped(mRS, mBlurInputAllocation.getType());
            } 
 
            mBlurScript.setRadius(radius);
            mBlurScript.forEach(mBlurOutputAllocation);
            mBlurOutputAllocation.copyTo(src);
        } 
 
        return src;
    } 
 
    /** 
     * Returns a glowed image of the provided icon. If the 
     * provided name is already in the cache, the cached image 
     * will be returned. Otherwise, the bitmap will be glowed and 
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:copyTo
        mScript.bind_ideal(mIdealPixelsAllocation);
        mScript.bind_given(mGivenPixelsAllocation);
 
        mOutputPixelsAllocation = Allocation.createFromBitmap(mRS, output,
                Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_SCRIPT);
        mScript.forEach_displayDifference(mOutputPixelsAllocation, mOutputPixelsAllocation);
        mOutputPixelsAllocation.copyTo(output);
    } 
 
    public static float calcError(Bitmap ideal, Bitmap given) {
        if (LOG_TIMING) {
            startMillis = System.currentTimeMillis();
        } 
 
        int interestingRegions = 0;
        for (int x = 0; x < ideal.getWidth(); x += REGION_SIZE) {
            for (int y = 0; y < ideal.getWidth(); y += REGION_SIZE) {
                if (inspectRegion(ideal, x, y)) {
                    interestingRegions++;
                } 
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:ioSendOutput
        return b2;
    } 
 
    private synchronized void filterAlloc(Allocation alloc, Sampler sampler) {
        long t = java.lang.System.currentTimeMillis();
        mScript.invoke_setSampleData(alloc, mTwoByTwoAlloc, sampler);
        mScript.forEach_root(alloc);
        alloc.ioSendOutput();
        mRS.finish();
        t = java.lang.System.currentTimeMillis() - t;
        Log.i(TAG, "Filter time is: " + t + " ms");
    } 
 
    public void benchmark(View v) {
        /*filterAlloc(); 
        long t = java.lang.System.currentTimeMillis(); 
        filterAlloc(); 
        t = java.lang.System.currentTimeMillis() - t; 
        mDisplayView.invalidate(); 
        mBenchmarkResult.setText("Result: " + t + " ms");*/ 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:copyTo
    } 
 
    public void surfaceCreated(SurfaceHolder holder) {
        createScript(); 
        mScript.invoke_filter();
        mOutPixelsAllocation.copyTo(mBitmapOut);
    } 
 
    public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
    } 
 
    public void surfaceDestroyed(SurfaceHolder holder) {
    } 
 
    private void createScript() { 
        mRS = RenderScript.create(this);
        mRS.setMessageHandler(new FilterCallback());
 
        mInPixelsAllocation = Allocation.createFromBitmap(mRS, mBitmapIn,
                                                          Allocation.MipmapControl.MIPMAP_NONE,
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:copy2DRangeFrom, copyTo
		 
		//Compute Discrete Cosine transform  
		computeDCT.forEach_root(fftOut, mDCTY);
				 
		//Compute Mel Ceps 
		mMelCeps.copy2DRangeFrom(0, 0, 1, numFrames, mSumPowerInFreq, 0, 0);
		mMelCeps.copy2DRangeFrom(1, 0, nCeps, numFrames, mDCTY, 1, 0);
 
		//Copy final Cepstral Coefficients back to host 
		float[] debug = new float[(nCeps+1)*numFrames];
		mMelCeps.copyTo(debug);
	} 
	 
	//This is the pre-emphasis filter that was used for the input data in matlab 
	private float[] emphData(float[] data, float emph){
		float[] tmpData = new float[data.length];
		 
		tmpData[0] = data[0];
		for (int i = 1; i < data.length; ++i){
			tmpData[i] = data[i] - emph * data[i-1];
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:createSized, createTyped, I32
    return new ScriptC_convolutionint(rs);
  } 
 
  @Override 
  protected Allocation onProcessImage(Context context, RenderScript rs) {
    Allocation blur = Allocation.createSized(rs, Element.I32(rs), 9,
        Allocation.USAGE_SCRIPT);
    blur.copyFrom(BLUR);
    ScriptC_convolutionint convolution = getScript();
    convolution.bind_convolution_factors(blur);
    Allocation in = getAllocation(context, rs, ORIGINAL);
    convolution.bind_gPixels(in);
    Allocation out = Allocation.createTyped(rs, in.getType());
    convolution.invoke_filter(convolution, in, out);
    return out;
  } 
} 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java

Related Android Allocation Questions & Answers:

See Code Examples for Android Allocation Methods: