List of usage examples for java.nio ShortBuffer allocate
public static ShortBuffer allocate(int capacity)
From source file:Main.java
public static void main(String[] args) { ShortBuffer bb = ShortBuffer.allocate(10); bb.put((short) 100); bb.rewind();/* w w w.jav a 2 s. co m*/ short[] shortArray = new short[10]; bb.get(shortArray); System.out.println(Arrays.toString(shortArray)); }
From source file:Main.java
public static void main(String[] args) { ShortBuffer bb = ShortBuffer.allocate(10); bb.put((short) 100); bb.rewind();//from w w w . jav a 2s.c o m short[] shortArray = new short[10]; bb.get(shortArray, 0, 2); System.out.println(Arrays.toString(shortArray)); }
From source file:Main.java
public static void main(String[] args) { ShortBuffer bb = ShortBuffer.allocate(10); bb.put((short) 100); bb.rewind();//from w w w. j a va 2s . co m ShortBuffer shortBuffer2 = ShortBuffer.allocate(10); shortBuffer2.put(bb); System.out.println(Arrays.toString(shortBuffer2.array())); }
From source file:Main.java
public static void main(String[] args) { ShortBuffer shortBuffer = ShortBuffer.allocate(10); shortBuffer.put((short) 100); shortBuffer.rewind();/*w ww . jav a 2s. c o m*/ ShortBuffer shortBuffer2 = shortBuffer.compact(); System.out.println(Arrays.toString(shortBuffer2.array())); }
From source file:Main.java
public static void main(String[] args) { ShortBuffer shortBuffer = ShortBuffer.allocate(10); shortBuffer.put((short) 100); shortBuffer.rewind();/*from ww w. j a va 2s.c o m*/ ShortBuffer shortBuffer2 = shortBuffer.compact(); System.out.println(shortBuffer2.equals(shortBuffer2)); }
From source file:Main.java
public static void main(String[] args) { ShortBuffer shortBuffer = ShortBuffer.allocate(10); shortBuffer.put((short) 100); shortBuffer.rewind();// w w w. j a va 2 s . c o m ShortBuffer shortBuffer2 = shortBuffer.duplicate(); System.out.println(shortBuffer2.equals(shortBuffer2)); }
From source file:Main.java
public static void main(String[] args) { ShortBuffer shortBuffer = ShortBuffer.allocate(10); shortBuffer.put((short) 100); shortBuffer.rewind();/*from ww w . java 2 s . co m*/ ShortBuffer shortBuffer2 = shortBuffer.slice(); System.out.println(shortBuffer2.equals(shortBuffer2)); }
From source file:Main.java
public static void main(String[] args) { ShortBuffer shortBuffer = ShortBuffer.allocate(10); shortBuffer.put((short) 100); shortBuffer.rewind();//w w w. j a va 2s . co m ShortBuffer shortBuffer2 = shortBuffer.asReadOnlyBuffer(); System.out.println(Arrays.toString(shortBuffer2.array())); }
From source file:Main.java
public static void main(String[] args) { ShortBuffer shortBuffer = ShortBuffer.allocate(10); shortBuffer.put((short) 100); shortBuffer.rewind();/* www.j ava2s . co m*/ ShortBuffer shortBuffer2 = shortBuffer.compact(); System.out.println(shortBuffer2.compareTo(shortBuffer2)); }
From source file:Main.java
public static Bitmap fromYUV420P(byte[] yuv, int width, int height) { if (yuv == null) { Log.e(TAG, "yuv data==null"); return null; }/*ww w .j av a 2s . com*/ if (yuv.length != width * height * 1.5) { Log.e(TAG, "yudData does not match the provided width and height"); return null; } Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565); int offsetY = 0; ShortBuffer buffer = ShortBuffer.allocate(width * height * 2); for (int line = 0; line < height; line++) { for (int col = 0; col < width; col++) { int y = yuv[offsetY++] & 0xFF; buffer.put((short) ((y >> 3) << 11 | (y >> 2) << 5 | (y >> 3))); } } bitmap.copyPixelsFromBuffer(buffer); return bitmap; }