List of usage examples for java.nio ByteOrder nativeOrder
public static ByteOrder nativeOrder()
From source file:Main.java
public static ShortBuffer shortToBuffer(short[] a) { ShortBuffer shortBuffer;// www . j ava2 s.co m ByteBuffer ibb = ByteBuffer.allocateDirect(a.length * 2); ibb.order(ByteOrder.nativeOrder()); shortBuffer = ibb.asShortBuffer(); shortBuffer.put(a); shortBuffer.position(0); return shortBuffer; }
From source file:Main.java
public static FloatBuffer floatArrayToBuffer(float[] floatArray) { ByteBuffer byteBuffer = ByteBuffer.allocateDirect(floatArray.length * 4); byteBuffer.order(ByteOrder.nativeOrder()); FloatBuffer floatBuffer = byteBuffer.asFloatBuffer(); floatBuffer.put(floatArray);/*ww w . j a va2 s . co m*/ floatBuffer.position(0); return floatBuffer; }
From source file:Main.java
public static short[] byteToShortArray(byte[] data) { short[] shorts = new short[data.length / BYTES_PER_SHORT]; ByteBuffer.wrap(data).order(ByteOrder.nativeOrder()).asShortBuffer().get(shorts); return shorts; }
From source file:Main.java
public static IntBuffer newIntBuffer(int numInts) { ByteBuffer buffer = ByteBuffer.allocate(numInts * 4); buffer.order(ByteOrder.nativeOrder()); return buffer.asIntBuffer(); }
From source file:Main.java
public static ByteBuffer create(int size) { return ByteBuffer.allocateDirect(size).order(ByteOrder.nativeOrder()); }
From source file:Main.java
public static FloatBuffer toFloatBuffer(float[] v) { ByteBuffer buff = ByteBuffer.allocateDirect(v.length * 4); buff.order(ByteOrder.nativeOrder()); FloatBuffer buffer = buff.asFloatBuffer(); buffer.put(v);//from ww w .ja v a 2 s . co m buffer.position(0); return buffer; }
From source file:Main.java
public static LongBuffer newLongBuffer(int numLongs) { ByteBuffer buffer = ByteBuffer.allocate(numLongs * 8); buffer.order(ByteOrder.nativeOrder()); return buffer.asLongBuffer(); }
From source file:Main.java
public static ShortBuffer toShortBuffer(short[] v) { ByteBuffer buff = ByteBuffer.allocateDirect(v.length * 2); buff.order(ByteOrder.nativeOrder()); ShortBuffer buffer = buff.asShortBuffer(); buffer.put(v);/* w w w. j av a 2 s . c o m*/ buffer.position(0); return buffer; }
From source file:Main.java
public static IntBuffer createIndexBuffer(int[] indices) { IntBuffer indexBuffer;/*from w ww . j ava 2s . c o m*/ ByteBuffer bb = ByteBuffer.allocateDirect(indices.length * 4); bb.order(ByteOrder.nativeOrder()); indexBuffer = bb.asIntBuffer(); indexBuffer.put(indices); indexBuffer.position(0); return indexBuffer; }
From source file:Main.java
public static ByteBuffer makeByteBuffer(byte[] array) /* */ {//from w w w . ja va 2s . c o m /* 63 */int SIZE = 1; /* 64 */ByteBuffer byteBuffer = ByteBuffer.allocateDirect(array.length * 1); /* 65 */byteBuffer.order(ByteOrder.nativeOrder()); /* 66 */byteBuffer.put(array); /* 67 */byteBuffer.position(0); /* 68 */return byteBuffer; /* */}