Android FloatBuffer Create makeFloatBuffer(int i_len)

Here you can find the source of makeFloatBuffer(int i_len)

Description

make Float Buffer

Declaration

public static FloatBuffer makeFloatBuffer(int i_len) 

Method Source Code

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

public class Main {
    public static FloatBuffer makeFloatBuffer(int i_len) {
        ByteBuffer bb = ByteBuffer.allocateDirect(i_len * 4);
        bb.order(ByteOrder.nativeOrder());
        FloatBuffer fb = bb.asFloatBuffer();
        fb.position(0);/*  w  w  w. jav a2 s . c o  m*/
        return fb;
    }

    public static FloatBuffer makeFloatBuffer(float[] i_arr) {
        ByteBuffer bb = ByteBuffer.allocateDirect(i_arr.length * 4);
        bb.order(ByteOrder.nativeOrder());
        FloatBuffer fb = bb.asFloatBuffer();
        fb.put(i_arr);
        fb.position(0);
        return fb;
    }
}

Related

  1. makeFloatBuffer(int length)
  2. ConvToFloatBuffer(float buf[])
  3. ConvToFloatBuffer(float buf[])
  4. makeFloatBuffer(float[] arr)
  5. makeFloatBuffer(float[] i_arr)