Android FloatBuffer Create makeFloatBuffer(float[] arr)

Here you can find the source of makeFloatBuffer(float[] arr)

Description

Make a direct NIO FloatBuffer from an array of floats

Parameter

Parameter Description
arr The array

Return

The newly created FloatBuffer

Declaration

public static FloatBuffer makeFloatBuffer(float[] arr) 

Method Source Code

//package com.java2s;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;

public class Main {
    /**/*from   w  ww  .  j a v  a  2 s. c  om*/
     * Make a direct NIO FloatBuffer from an array of floats
     * @param arr The array
     * @return The newly created FloatBuffer
     */
    public static FloatBuffer makeFloatBuffer(float[] arr) {
        ByteBuffer bb = ByteBuffer.allocateDirect(arr.length * 4);
        bb.order(ByteOrder.nativeOrder());
        FloatBuffer fb = bb.asFloatBuffer();
        fb.put(arr);
        fb.position(0);
        return fb;
    }
}

Related

  1. makeFloatBuffer(float[] array)
  2. makeFloatBuffer(float[][] array, int rows, int cols)
  3. makeFloatBuffer(int length)
  4. ConvToFloatBuffer(float buf[])
  5. ConvToFloatBuffer(float buf[])
  6. makeFloatBuffer(float[] i_arr)
  7. makeFloatBuffer(int i_len)