Example usage for android.renderscript Element I32_4

List of usage examples for android.renderscript Element I32_4

Introduction

In this page you can find the example usage for android.renderscript Element I32_4.

Prototype

public static Element I32_4(RenderScript rs) 

Source Link

Usage

From source file:Main.java

/**
 * Return the histograms for each color channel (interleaved).
 *
 * @param rs a {@link RenderScript} context to use.
 * @param bmap a {@link Bitmap} to generate the histograms for.
 * @return an array containing NUM_CHANNELS * COLOR_BIT_DEPTH histogram bucket values, with
 * the color channels interleaved.//  w w  w  .  j av  a 2s. c o m
 */
public static int[] calcHistograms(RenderScript rs, Bitmap bmap) {
    ScriptIntrinsicHistogram hist = ScriptIntrinsicHistogram.create(rs, Element.U8_4(rs));
    Allocation sums = Allocation.createSized(rs, Element.I32_4(rs), COLOR_BIT_DEPTH);

    // Setup input allocation (ARGB 8888 bitmap).
    Allocation input = Allocation.createFromBitmap(rs, bmap);

    hist.setOutput(sums);
    hist.forEach(input);
    int[] output = new int[COLOR_BIT_DEPTH * NUM_CHANNELS];
    sums.copyTo(output);
    return output;
}