Refine search
public static IntBuffer newIntBuffer (int numInts) { ByteBuffer buffer = ByteBuffer.allocateDirect(numInts * 4); buffer.order(ByteOrder.nativeOrder()); return buffer.asIntBuffer(); }
public String glGetProgramInfoLog (int program) { ByteBuffer buffer = ByteBuffer.allocateDirect(1024 * 10); buffer.order(ByteOrder.nativeOrder()); ByteBuffer tmp = ByteBuffer.allocateDirect(4); tmp.order(ByteOrder.nativeOrder()); IntBuffer intBuffer = tmp.asIntBuffer(); GL20.glGetProgramInfoLog(program, intBuffer, buffer); int numBytes = intBuffer.get(0); byte[] bytes = new byte[numBytes]; buffer.get(bytes); return new String(bytes); }
@Override synchronized void fillCountsArrayFromBuffer(final ByteBuffer buffer, final int length) { buffer.asIntBuffer().get(counts, 0, length); } }
/** * Convert an array to a byte buffer * @param arr the array * @return a direct byte buffer with the array contents */ public static IntBuffer toBuffer(int... arr) { ByteBuffer directBuffer = ByteBuffer.allocateDirect(arr.length * 4).order(ByteOrder.nativeOrder()); IntBuffer buffer = directBuffer.asIntBuffer(); for (int i = 0; i < arr.length; i++) buffer.put(i, arr[i]); return buffer; }
fromView.order(ByteOrder.nativeOrder()); toView.order(ByteOrder.nativeOrder()); switch (bufferType) { case INT: IntBuffer fromInt = fromView.asIntBuffer(); IntBuffer toInt = toView.asIntBuffer(); for (int i = 0; i < n; i++) { int put = fromInt.get(fromOffset + i * fromStride); toInt.put(toOffset + i * toStride, put);
public byte[] toBytes() { if (words == null) { return new byte[]{}; } ByteBuffer buf = ByteBuffer.allocate(words.capacity() * Integer.BYTES); buf.asIntBuffer().put(words.asReadOnlyBuffer()); return buf.array(); }
PinotDataBuffer buffer = _memoryManager.allocate(bbSize, _allocationContext); _pinotDataBuffers.add(buffer); IntBuffer iBuf = buffer.toDirectByteBuffer(0L, bbSize).asIntBuffer(); for (int i = 0; i < iBuf.capacity(); i++) { iBuf.put(i, NULL_VALUE_INDEX); boolean done = false; for (int i = offsetInBuf; i < offsetInBuf + NUM_COLUMNS; i++) { if (iBuf.get(i) == NULL_VALUE_INDEX) { iBuf.put(i, entry.getValue()); done = true; break;
public String glGetShaderInfoLog (int shader) { ByteBuffer buffer = ByteBuffer.allocateDirect(1024 * 10); buffer.order(ByteOrder.nativeOrder()); ByteBuffer tmp = ByteBuffer.allocateDirect(4); tmp.order(ByteOrder.nativeOrder()); IntBuffer intBuffer = tmp.asIntBuffer(); GL20.glGetShaderInfoLog(shader, intBuffer, buffer); int numBytes = intBuffer.get(0); byte[] bytes = new byte[numBytes]; buffer.get(bytes); return new String(bytes); }
public void setIndices(int[] indices, boolean override) { final BufferInfo indexInfo = mBuffers.get(INDEX_BUFFER_KEY); if (indexInfo.buffer == null || override == true) { indexInfo.buffer = ByteBuffer.allocateDirect(indices.length * INT_SIZE_BYTES) .order(ByteOrder.nativeOrder()).asIntBuffer(); ((IntBuffer) indexInfo.buffer).put(indices).position(0); mNumIndices = indices.length; } else { ((IntBuffer) indexInfo.buffer).put(indices); } }
public static IntBuffer newIntBuffer (int numInts) { ByteBuffer buffer = ByteBuffer.allocateDirect(numInts * 4); buffer.order(ByteOrder.nativeOrder()); return buffer.asIntBuffer(); }
defaultFramebufferHandleInitialized = true; if (Gdx.app.getType() == ApplicationType.iOS) { IntBuffer intbuf = ByteBuffer.allocateDirect(16 * Integer.SIZE / 8).order(ByteOrder.nativeOrder()).asIntBuffer(); gl.glGetIntegerv(GL20.GL_FRAMEBUFFER_BINDING, intbuf); defaultFramebufferHandle = intbuf.get(0); } else { defaultFramebufferHandle = 0; IntBuffer buffer = BufferUtils.newIntBuffer(colorTextureCounter); for (int i = 0; i < colorTextureCounter; i++) { buffer.put(GL30.GL_COLOR_ATTACHMENT0 + i);
ByteBuffer bb = ByteBuffer.wrap(new byte[] {0, 0, 0, 1, 0, 0, 0, 4}); IntBuffer ib = bb.asIntBuffer(); int i0 = ib.get(0); int i1 = ib.get(1); System.out.println(i0); System.out.println(i1);
import java.nio.*; import java.net.*; class Test { public static void main(String [] args) throws Exception // Just for simplicity! { int[] data = { 100, 200, 300, 400 }; ByteBuffer byteBuffer = ByteBuffer.allocate(data.length * 4); IntBuffer intBuffer = byteBuffer.asIntBuffer(); intBuffer.put(data); byte[] array = byteBuffer.array(); for (int i=0; i < array.length; i++) { System.out.println(i + ": " + array[i]); } } }
public static byte[] intsToBytes(int[] ints) { ByteBuffer bb = ByteBuffer.allocate(ints.length * 4); IntBuffer ib = bb.asIntBuffer(); for (int i : ints) ib.put(i); return bb.array(); } public static int[] bytesToInts(byte[] bytes) { int[] ints = new int[bytes.length / 4]; ByteBuffer.wrap(bytes).asIntBuffer().get(ints); return ints; }
public String glGetShaderInfoLog (int shader) { ByteBuffer buffer = ByteBuffer.allocateDirect(1024 * 10); buffer.order(ByteOrder.nativeOrder()); ByteBuffer tmp = ByteBuffer.allocateDirect(4); tmp.order(ByteOrder.nativeOrder()); IntBuffer intBuffer = tmp.asIntBuffer(); GL20.glGetShaderInfoLog(shader, intBuffer, buffer); int numBytes = intBuffer.get(0); byte[] bytes = new byte[numBytes]; buffer.get(bytes); return new String(bytes); }
public static final ByteBuffer getImageDataFromImage(BufferedImage bufferedImage) { WritableRaster wr; DataBuffer db; BufferedImage bi = new BufferedImage(128, 64, BufferedImage.TYPE_INT_ARGB); Graphics2D g = bi.createGraphics(); g.drawImage(bufferedImage, null, null); bufferedImage = bi; wr = bi.getRaster(); db = wr.getDataBuffer(); DataBufferInt dbi = (DataBufferInt) db; int[] data = dbi.getData(); ByteBuffer byteBuffer = ByteBuffer.allocateDirect(data.length * 4); byteBuffer.order(ByteOrder.LITTLE_ENDIAN); byteBuffer.asIntBuffer().put(data); byteBuffer.flip(); return byteBuffer; }
static IntBuffer allocateDirect(int size) { return ByteBuffer.allocateDirect(size * Integer.BYTES) .order(ByteOrder.nativeOrder()) .asIntBuffer(); } }
defaultFramebufferHandleInitialized = true; if (Gdx.app.getType() == ApplicationType.iOS) { IntBuffer intbuf = ByteBuffer.allocateDirect(16 * Integer.SIZE / 8).order(ByteOrder.nativeOrder()).asIntBuffer(); gl.glGetIntegerv(GL20.GL_FRAMEBUFFER_BINDING, intbuf); defaultFramebufferHandle = intbuf.get(0); } else { defaultFramebufferHandle = 0; IntBuffer buffer = BufferUtils.newIntBuffer(colorTextureCounter); for (int i = 0; i < colorTextureCounter; i++) { buffer.put(GL30.GL_COLOR_ATTACHMENT0 + i);
static { System.loadLibrary("webp"); } private Bitmap webpToBitmap(byte[] encoded) { int[] width = new int[] { 0 }; int[] height = new int[] { 0 }; byte[] decoded = libwebp.WebPDecodeARGB(encoded, encoded.length, width, height); int[] pixels = new int[decoded.length / 4]; ByteBuffer.wrap(decoded).asIntBuffer().get(pixels); return Bitmap.createBitmap(pixels, width[0], height[0], Bitmap.Config.ARGB_8888); }
public static Decimal getDecimal(int number, int scale) { ByteBuffer bb = ByteBuffer.allocate(4); bb.asIntBuffer().put(number); return new Decimal((short) scale, bb); }