List of usage examples for java.nio ByteBuffer order
Endianness order
To view the source code for java.nio ByteBuffer order.
Click Source Link
From source file:Main.java
public static IntBuffer allocateInttBuffer(int capacity) { final ByteBuffer vbb = ByteBuffer.allocateDirect(capacity); vbb.order(ByteOrder.nativeOrder()); return vbb.asIntBuffer(); }
From source file:Main.java
public static ShortBuffer newShortBuffer(int numShorts) { ByteBuffer buffer = ByteBuffer.allocateDirect(numShorts * 2); buffer.order(ByteOrder.nativeOrder()); return buffer.asShortBuffer(); }
From source file:Main.java
public static FloatBuffer newFloatBuffer(int numFloats) { ByteBuffer buffer = ByteBuffer.allocateDirect(numFloats * 4); buffer.order(ByteOrder.nativeOrder()); return buffer.asFloatBuffer(); }
From source file:Main.java
public static FloatBuffer makeFloatBuffer4(float $a, float $b, float $c, float $d) { ByteBuffer b = ByteBuffer.allocateDirect(4 * BYTES_PER_FLOAT); b.order(ByteOrder.nativeOrder()); FloatBuffer buffer = b.asFloatBuffer(); buffer.put($a);/*from w ww . j a v a2 s .c o m*/ buffer.put($b); buffer.put($c); buffer.put($d); buffer.position(0); return buffer; }
From source file:Main.java
public static DoubleBuffer newDoubleBuffer(int numDoubles) { ByteBuffer buffer = ByteBuffer.allocateDirect(numDoubles * 8); buffer.order(ByteOrder.nativeOrder()); return buffer.asDoubleBuffer(); }
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 av a 2 s. c o m intBuffer.position(0); return intBuffer; }
From source file:Main.java
public static FloatBuffer createFloatBuffer(float[] coords) { // Allocate a direct ByteBuffer, using 4 bytes per float, and copy coords into it. ByteBuffer bb = ByteBuffer.allocateDirect(coords.length * 4); bb.order(ByteOrder.nativeOrder()); FloatBuffer fb = bb.asFloatBuffer(); fb.put(coords);/* w ww . j av a2 s. co m*/ fb.position(0); return fb; }
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);/*from ww w . j a v a2 s .co m*/ floatBuffer.position(0); return floatBuffer; }
From source file:Main.java
public static FloatBuffer createFloatBuffer(int size) { ByteBuffer buffer = ByteBuffer.allocateDirect(size * BYTES_PER_FLOAT); buffer.order(ByteOrder.nativeOrder()); return buffer.asFloatBuffer(); }
From source file:Main.java
public static byte[] getBytePixels(final Bitmap bit) { if (bit == null) { return null; }// ww w . j av a 2 s. c o m final byte[] pixels = new byte[bit.getWidth() * bit.getHeight() * 4]; final ByteBuffer buf = ByteBuffer.wrap(pixels); buf.order(ByteOrder.nativeOrder()); bit.copyPixelsToBuffer(buf); return pixels; }