Android FloatBuffer Create asFloatBuffer(float[] array)

Here you can find the source of asFloatBuffer(float[] array)

Description

as Float Buffer

Declaration

public static FloatBuffer asFloatBuffer(float[] array) 

Method Source Code

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

public class Main {
    public static final int BYTES_PER_FLOAT = Float.SIZE / Byte.SIZE;

    public static FloatBuffer asFloatBuffer(float[] array) {
        ByteBuffer bbuf = ByteBuffer.allocateDirect(array.length
                * BYTES_PER_FLOAT);//from  w  ww .ja v  a2 s. c  o  m
        bbuf.order(ByteOrder.nativeOrder());
        FloatBuffer fbuf = bbuf.asFloatBuffer();
        fbuf.put(array);
        fbuf.position(0);
        return fbuf;
    }
}

Related

  1. setupFloatBuffer(FloatBuffer preBuffer, float[] array)
  2. list2FloatBuffer(List arr)
  3. list2FloatBuffer(List list)
  4. getFloatBuffer(float[] list)
  5. buildFloatBuffer(float[] buffer)
  6. wrap(float[] buffer)
  7. makeFloatBuffer(float[] array)
  8. makeFloatBuffer(float[][] array, int rows, int cols)
  9. makeFloatBuffer(int length)