List of usage examples for java.nio IntBuffer position
public final Buffer position(int newPosition)
From source file:Main.java
static void toArray(IntBuffer src, int[] dst, int offset) { src.position(0); src.get(dst, offset, dst.length - offset); }
From source file:Main.java
public static IntBuffer getIntBuffer(int[] coords) { ByteBuffer bb = ByteBuffer.allocateDirect(coords.length * 4); bb.order(ByteOrder.nativeOrder()); IntBuffer intBuffer = bb.asIntBuffer(); intBuffer.put(coords);//from w w w . j a v a 2 s . c om intBuffer.position(0); return intBuffer; }
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);//from w w w . j a va2s . co m buffer.position(0); return buffer; }
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 ww . j av a 2 s .c o m*/ intBuffer.position(0); return intBuffer; }
From source file:Main.java
public static IntBuffer makeIntBuffer(int[] array) /* */ {// w w w .ja v a 2s .c o m /* 52 */int integerSize = 4; /* 53 */ByteBuffer byteBuffer = ByteBuffer.allocateDirect(array.length * 4); /* 54 */byteBuffer.order(ByteOrder.nativeOrder()); /* 55 */IntBuffer intBuffer = byteBuffer.asIntBuffer(); /* 56 */intBuffer.put(array); /* 57 */intBuffer.position(0); /* 58 */return intBuffer; /* */}
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 a v a 2 s . c o m intBuffer.position(0); return intBuffer; }
From source file:Main.java
/**android methods*/ //Only for Android public static IntBuffer makeFloatBuffer(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);//from www. j av a2 s . c o m intBuffer.position(0); return intBuffer; }
From source file:Main.java
public static IntBuffer createIndexBuffer(int[] indices) { IntBuffer indexBuffer; ByteBuffer bb = ByteBuffer.allocateDirect(indices.length * 4); bb.order(ByteOrder.nativeOrder()); indexBuffer = bb.asIntBuffer();//from w ww . j av a 2s . c om indexBuffer.put(indices); indexBuffer.position(0); return indexBuffer; }
From source file:org.jcodec.codecs.mjpeg.JpegDecoder.java
private static void lineToRgb(IntBuffer Y, IntBuffer Cb, IntBuffer Cr, IntBuffer rgb) { for (int i = 0; i < 8; i++) { Cb.position(Cb.position() - (i & 1)); Cr.position(Cr.position() - (i & 1)); int y = Y.get(); int cb = Cb.get(); int cr = Cr.get(); rgb.put(ImageConvert.ycbcr_to_rgb24(y, cb, cr)); }/* ww w . j a v a 2s . c o m*/ }
From source file:Main.java
public static Buffer setupIntBuffer(IntBuffer preBuffer, int[] array) { if (preBuffer == null || preBuffer.capacity() < array.length) { preBuffer = createIntBuffer(array.length * 2); } else {/*from w ww . j av a 2 s. com*/ preBuffer.clear(); } preBuffer.clear(); preBuffer.put(array); preBuffer.position(0); return preBuffer; }