public static int loadTextureAsBitmap(final IntBuffer data, final Size size, final int usedTexId) { Bitmap bitmap = Bitmap .createBitmap(data.array(), size.width, size.height, Config.ARGB_8888); return loadTexture(bitmap, usedTexId); }
/** * For direct buffers, calls {@link Pointer#Pointer(Buffer)}, while for buffers * backed with an array, allocates enough memory for the array and copies it. * * @param buffer the Buffer to reference or copy * @see #put(int[]) */ public IntPointer(IntBuffer buffer) { super(buffer); if (buffer != null && !buffer.isDirect() && buffer.hasArray()) { int[] array = buffer.array(); allocateArray(array.length - buffer.arrayOffset()); put(array, buffer.arrayOffset(), array.length - buffer.arrayOffset()); position(buffer.position()); limit(buffer.limit()); } } /**
/** * Take a certain number of ints from the buffer and return them in an array. * * @param buffer the buffer to read * @param cnt the number of ints to take * @return the ints */ public static int[] take(IntBuffer buffer, int cnt) { if (cnt < 0) { throw msg.parameterOutOfRange("cnt"); } if (buffer.hasArray()) { final int pos = buffer.position(); final int lim = buffer.limit(); if (lim - pos < cnt) { throw new BufferUnderflowException(); } final int[] array = buffer.array(); final int offset = buffer.arrayOffset(); buffer.position(pos + cnt); final int start = offset + pos; return Arrays.copyOfRange(array, start, start + cnt); } final int[] ints = new int[cnt]; buffer.get(ints); return ints; }
@Override public void run() { GPUImageNativeLibrary.YUVtoRBGA(data, width, height, glRgbBuffer.array()); glTextureId = OpenGlUtils.loadTexture(glRgbBuffer, width, height, glTextureId); if (imageWidth != width) { imageWidth = width; imageHeight = height; adjustImageScaling(); } } });
/** * Fill a buffer with a repeated value. * * @param buffer the buffer to fill * @param value the value to fill * @param count the number of ints to fill * @return the buffer instance */ public static IntBuffer fill(IntBuffer buffer, int value, int count) { if (count > buffer.remaining()) { throw msg.bufferUnderflow(); } if (buffer.hasArray()) { final int offs = buffer.arrayOffset(); Arrays.fill(buffer.array(), offs + buffer.position(), offs + buffer.limit(), value); skip(buffer, count); } else { for (int i = count; i > 0; i--) { buffer.put(value); } } return buffer; }
int[] intArray() { assert type == Type.INT; return intBuffer.array(); }
int inLimit = utf16In.arrayOffset() + utf16In.limit(); int[] outInt = intBuffer.array(); int outOffset = intBuffer.arrayOffset() + intBuffer.position();
Assert.assertArrayEquals(new int[] {0, 2, 3, 4}, iterator.conversions[0].array()); Assert.assertArrayEquals(new int[] {1, 2, 4}, iterator.conversions[1].array()); Assert.assertArrayEquals(new int[] {0, 3, 5}, iterator.conversions[2].array()); Assert.assertArrayEquals(new int[] {0, 1, 2}, iterator.conversions[3].array()); Assert.assertArrayEquals(new int[] {0, 1, 2, 3, 4, 5}, iterator.conversions[4].array());
private static int[] readArrayFromChannel(ReadableByteChannel channel) throws IOException { int length = readIntFromByteChannel(channel); ByteBuffer tmpBuffer = ByteBuffer.allocate(length * INT_BYTES); while (tmpBuffer.hasRemaining() && (channel.read(tmpBuffer) >= 0)) { } tmpBuffer.rewind(); IntBuffer intBuffer = tmpBuffer.asIntBuffer(); if (intBuffer.hasArray() && !intBuffer.isReadOnly()) { return intBuffer.array(); } int[] array = new int[length]; intBuffer.get(array); return array; } }
private Bitmap convertToBitmap() { int[] iat = new int[mWidth * mHeight]; IntBuffer ib = IntBuffer.allocate(mWidth * mHeight); mEGLHelper.mGL.glReadPixels(0, 0, mWidth, mHeight, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, ib); int[] ia = ib.array(); // Convert upside down mirror-reversed image to right-side up normal // image. for (int i = 0; i < mHeight; i++) { System.arraycopy(ia, i * mWidth, iat, (mHeight - i - 1) * mWidth, mWidth); } Bitmap bitmap = Bitmap.createBitmap(mWidth, mHeight, Bitmap.Config.ARGB_8888); bitmap.copyPixelsFromBuffer(IntBuffer.wrap(iat)); return bitmap; }
byte[] temp = new byte[fileIntLength*4]; read.readFully(); if (temp.length > 0){ ints = ByteBuffer.wrap(temp).asIntBuffer().array(); }
@Override public void glGetProgramInfoLog(int program, int bufsize, IntBuffer length, ByteBuffer infolog) { glGetProgramInfoLog(program, bufsize, length.array(), infolog.position(), infolog.array(), infolog.position()); }
public static int loadTextureAsBitmap(final IntBuffer data, final Size size, final int usedTexId) { Bitmap bitmap = Bitmap .createBitmap(data.array(), size.width, size.height, Config.ARGB_8888); return loadTexture(bitmap, usedTexId); }
public static int loadTextureAsBitmap(final IntBuffer data, final Size size, final int usedTexId) { Bitmap bitmap = Bitmap .createBitmap(data.array(), size.width, size.height, Config.ARGB_8888); return loadTexture(bitmap, usedTexId); }
@Override public void glGetShaderInfoLog(int shader, int bufsize, IntBuffer length, ByteBuffer infolog) { glGetShaderInfoLog(shader, bufsize, length.array(), length.position(), infolog.array(), infolog.position()); }
@Override public void glGetShaderInfoLog(int shader, int bufsize, IntBuffer length, ByteBuffer infolog) { glGetShaderInfoLog(shader, bufsize, length.array(), length.position(), infolog.array(), infolog.position()); }
protected static void updateIntBuffer(IntBuffer buf, int[] arr, int offset, int size) { if (USE_DIRECT_BUFFERS || (buf.hasArray() && buf.array() != arr)) { buf.position(offset); buf.put(arr, offset, size); buf.rewind(); } }
protected static void putIntArray(IntBuffer buf, int[] arr) { if (!buf.hasArray() || buf.array() != arr) { buf.position(0); buf.put(arr); buf.rewind(); } }
protected static void updateIntBuffer(IntBuffer buf, int[] arr, int offset, int size) { if (USE_DIRECT_BUFFERS || (buf.hasArray() && buf.array() != arr)) { buf.position(offset); buf.put(arr, offset, size); buf.rewind(); } }