List of usage examples for java.nio ByteOrder nativeOrder
public static ByteOrder nativeOrder()
From source file:Main.java
private static Rect getRectByByte(byte[] org) { Rect rect = new Rect(); ByteBuffer byteBuffer = ByteBuffer.wrap(org).order(ByteOrder.nativeOrder()); rect.set(byteBuffer.getInt(3 * 4), byteBuffer.getInt(5 * 4), byteBuffer.getInt(4 * 4), byteBuffer.getInt(6 * 4));/* w w w.jav a2 s .c o m*/ return rect; }
From source file:Main.java
public static FloatBuffer createFloatBuffer(int floatCount) { ByteBuffer data = ByteBuffer.allocateDirect(floatCount * 4); data.order(ByteOrder.nativeOrder()); FloatBuffer p1 = data.asFloatBuffer(); return p1;//w w w .j a v a 2s . c om }
From source file:Main.java
public static ShortBuffer getShortBuffer(short[] coords) { ByteBuffer bb = ByteBuffer.allocateDirect(coords.length * 2); bb.order(ByteOrder.nativeOrder()); ShortBuffer shortBuffer = bb.asShortBuffer(); shortBuffer.put(coords);/*from w w w . j a v a 2 s .com*/ shortBuffer.position(0); return shortBuffer; }
From source file:Main.java
public static ShortBuffer createShortBuffer(int shortCount) { ByteBuffer data = ByteBuffer.allocateDirect(shortCount * 4); data.order(ByteOrder.nativeOrder()); ShortBuffer p1 = data.asShortBuffer(); return p1;/*from w w w . j av a2 s . com*/ }
From source file:Main.java
public static FloatBuffer makeFloatBufferFromArray(float[] arr) { ByteBuffer bb = ByteBuffer.allocateDirect(arr.length * 4); bb.order(ByteOrder.nativeOrder()); FloatBuffer fb = bb.asFloatBuffer(); fb.put(arr);//from w w w.java 2 s . co m fb.position(0); return fb; }
From source file:Main.java
public static ShortBuffer buildShortBuffer(short[] array) { ByteBuffer byteBuf = ByteBuffer.allocateDirect(array.length * 2); byteBuf.order(ByteOrder.nativeOrder()); ShortBuffer buffer = byteBuf.asShortBuffer(); buffer.put(array);//from ww w .j av a 2 s. c o m buffer.position(0); return buffer; }
From source file:Main.java
/** * @param length//from w w w .j a v a 2 s. c o m * @return A direct, native-order buffer */ public static ByteBuffer createByteBuffer(int length) { return ByteBuffer.allocateDirect(length).order(ByteOrder.nativeOrder()); }
From source file:Main.java
public static IntBuffer intArrayToBuffer(int[] intArray) { ByteBuffer byteBuffer = ByteBuffer.allocateDirect(intArray.length * 4); byteBuffer.order(ByteOrder.nativeOrder()); IntBuffer intBuffer = byteBuffer.asIntBuffer(); intBuffer.put(intArray);// w w w . j a v a2 s. c o m intBuffer.position(0); return intBuffer; }
From source file:Main.java
public static FloatBuffer float2Buffer(float[] a) { FloatBuffer floatBuffer;//from w w w. jav a 2 s . com ByteBuffer bb = ByteBuffer.allocateDirect(a.length * 4); bb.order(ByteOrder.nativeOrder()); floatBuffer = bb.asFloatBuffer(); floatBuffer.put(a); floatBuffer.position(0); return floatBuffer; }
From source file:Main.java
public static IntBuffer makeBuffer(int[] data) { ByteBuffer b = ByteBuffer.allocateDirect(data.length * 4); b.order(ByteOrder.nativeOrder()); IntBuffer buffer = b.asIntBuffer(); buffer.put(data);// w w w . j a va 2 s . c om buffer.position(0); return buffer; }