Example usage for java.nio ByteOrder nativeOrder

List of usage examples for java.nio ByteOrder nativeOrder

Introduction

In this page you can find the example usage for java.nio ByteOrder nativeOrder.

Prototype

public static ByteOrder nativeOrder() 

Source Link

Document

Returns the current platform byte order.

Usage

From source file:Main.java

public static DoubleBuffer createDoubleBufferOnHeap(final int size) {
    final DoubleBuffer buf = ByteBuffer.allocate(SIZEOF_DOUBLE * size).order(ByteOrder.nativeOrder())
            .asDoubleBuffer();// w  w w. j a v a  2  s  . com
    buf.clear();
    return buf;
}

From source file:Main.java

public static LongBuffer newLongBuffer(int numLongs) {
    ByteBuffer buffer = ByteBuffer.allocateDirect(numLongs * 8);
    buffer.order(ByteOrder.nativeOrder());
    return buffer.asLongBuffer();
}

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 DoubleBuffer createDoubleBuffer(final int size) {
    final DoubleBuffer buf = ByteBuffer.allocateDirect(SIZEOF_DOUBLE * size).order(ByteOrder.nativeOrder())
            .asDoubleBuffer();//from   w  ww.  j a  va2 s. com
    buf.clear();
    return buf;
}

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 ShortBuffer createShortBuffer(final int size) {
    final ShortBuffer buf = ByteBuffer.allocateDirect(SIZEOF_SHORT * size).order(ByteOrder.nativeOrder())
            .asShortBuffer();//from w w w  . j  a v a2  s .  c  om
    buf.clear();
    return buf;
}

From source file:Main.java

/**buffer methods*/

public static IntBuffer makeIntBuffer(int[] array) {
    final int integerSize = Integer.SIZE / 8;
    ByteBuffer byteBuffer = ByteBuffer.allocateDirect(array.length * integerSize);
    byteBuffer.order(ByteOrder.nativeOrder());
    IntBuffer intBuffer = byteBuffer.asIntBuffer();
    intBuffer.put(array);/*  w  w  w . j  ava 2  s .  com*/
    intBuffer.position(0);
    return intBuffer;
}

From source file:Main.java

public static byte[] getBytePixels(final Bitmap bit) {
    if (bit == null) {
        return null;
    }//  w w w  .ja va 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;
}

From source file:Main.java

public static ByteBuffer createByteBuffer(final int size) {
    final ByteBuffer buf = ByteBuffer.allocateDirect(size).order(ByteOrder.nativeOrder());
    buf.clear();/*from  w  w w.j  a va2 s.c o m*/
    return buf;
}