Java Code Examples for java.nio.IntBuffer#position()
The following examples show how to use
java.nio.IntBuffer#position() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UnsafeOptimizeStringColumnBinaryMaker.java From yosegi with Apache License 2.0 | 6 votes |
@Override public IntBuffer getIndexIntBuffer( final int size , final byte[] buffer , final int start , final int length , final ByteOrder order ) throws IOException { IReadSupporter wrapBuffer = ByteBufferSupporterFactory.createReadSupporter( buffer , start , length , order ); IntBuffer result = IntBuffer.allocate( size ); for ( int i = 0 ; i < size ; i++ ) { result.put( NumberToBinaryUtils.getUnsignedShortToInt( wrapBuffer.getShort() ) ); } result.position( 0 ); return result; }
Example 2
Source File: Image.java From JavaAV with GNU General Public License v2.0 | 6 votes |
public static void copy(IntBuffer srcBuf, int srcStep, IntBuffer dstBuf, int dstStep) { int w = Math.min(srcStep, dstStep); int srcLine = srcBuf.position(); int dstLine = dstBuf.position(); while (srcLine < srcBuf.capacity() && dstLine < dstBuf.capacity()) { srcBuf.position(srcLine); dstBuf.position(dstLine); w = Math.min(Math.min(w, srcBuf.remaining()), dstBuf.remaining()); for (int x = 0; x < w; x++) { int in = srcBuf.get(); int out = in; dstBuf.put(out); } srcLine += srcStep; dstLine += dstStep; } }
Example 3
Source File: UnsafeOptimizeDoubleColumnBinaryMaker.java From yosegi with Apache License 2.0 | 6 votes |
@Override public IntBuffer getIndexIntBuffer( final byte[] buffer , final int start , final int length , final ByteOrder order ) throws IOException { int size = length / Byte.BYTES; IReadSupporter wrapBuffer = ByteBufferSupporterFactory.createReadSupporter( buffer , start , length , order ); IntBuffer result = IntBuffer.allocate( size ); for ( int i = 0 ; i < size ; i++ ) { result.put( NumberToBinaryUtils.getUnsignedByteToInt( wrapBuffer.getByte() ) ); } result.position( 0 ); return result; }
Example 4
Source File: GlyphMapping.java From ttt with BSD 2-Clause "Simplified" License | 5 votes |
private static int[] getGlyphs(GlyphSequence gs) { IntBuffer gb = gs.getGlyphs(); gb.rewind(); int[] glyphs = new int[gb.limit() - gb.position()]; for (int i = 0; gb.position() < gb.limit(); ) { glyphs[i++] = gb.get(); } return glyphs; }
Example 5
Source File: OptimizeLongColumnBinaryMaker.java From multiple-dimension-spread with Apache License 2.0 | 5 votes |
@Override public IntBuffer getIndexIntBuffer( final byte[] buffer , final int start , final int length ) throws IOException{ int size = length / Short.BYTES; ByteBuffer wrapBuffer = ByteBuffer.wrap( buffer , start , length ); IntBuffer result = IntBuffer.allocate( size ); for( int i = 0 ; i < size ; i++ ){ result.put( (int)( wrapBuffer.getShort() ) ); } result.position( 0 ); return result; }
Example 6
Source File: UnsafeOptimizeFloatColumnBinaryMaker.java From multiple-dimension-spread with Apache License 2.0 | 5 votes |
@Override public IntBuffer getIndexIntBuffer( final byte[] buffer , final int start , final int length , ByteOrder order ) throws IOException{ int size = length / Integer.BYTES; IReadSupporter wrapBuffer = ByteBufferSupporterFactory.createReadSupporter( buffer , start , length , order ); IntBuffer result = IntBuffer.allocate( size ); for( int i = 0 ; i < size ; i++ ){ result.put( wrapBuffer.getInt() ); } result.position( 0 ); return result; }
Example 7
Source File: UnsafeOptimizeDoubleColumnBinaryMaker.java From multiple-dimension-spread with Apache License 2.0 | 5 votes |
@Override public IntBuffer getIndexIntBuffer( final byte[] buffer , final int start , final int length , ByteOrder order ) throws IOException{ int size = length / Integer.BYTES; IReadSupporter wrapBuffer = ByteBufferSupporterFactory.createReadSupporter( buffer , start , length , order ); IntBuffer result = IntBuffer.allocate( size ); for( int i = 0 ; i < size ; i++ ){ result.put( wrapBuffer.getInt() ); } result.position( 0 ); return result; }
Example 8
Source File: ICUResourceBundleReader.java From trekarta with GNU General Public License v3.0 | 5 votes |
private int[] getInts(int offset, int count) { int[] ints = new int[count]; if (count <= 16) { for(int i = 0; i < count; offset += 4, ++i) { ints[i] = bytes.getInt(offset); } } else { IntBuffer temp = bytes.asIntBuffer(); temp.position(offset / 4); temp.get(ints); } return ints; }
Example 9
Source File: ICUResourceBundleReader.java From j2objc with Apache License 2.0 | 5 votes |
private int[] getInts(int offset, int count) { int[] ints = new int[count]; if (count <= 16) { for(int i = 0; i < count; offset += 4, ++i) { ints[i] = bytes.getInt(offset); } } else { IntBuffer temp = bytes.asIntBuffer(); temp.position(offset / 4); temp.get(ints); } return ints; }
Example 10
Source File: OptimizeStringColumnBinaryMaker.java From multiple-dimension-spread with Apache License 2.0 | 5 votes |
@Override public IntBuffer getIndexIntBuffer( final int size , final ByteBuffer wrapBuffer ) throws IOException{ IntBuffer result = IntBuffer.allocate( size ); for( int i = 0 ; i < size ; i++ ){ result.put( wrapBuffer.getInt() ); } result.position( 0 ); return result; }
Example 11
Source File: OptimizeDoubleColumnBinaryMaker.java From multiple-dimension-spread with Apache License 2.0 | 5 votes |
@Override public IntBuffer getIndexIntBuffer( final byte[] buffer , final int start , final int length ) throws IOException{ int size = length / Short.BYTES; ByteBuffer wrapBuffer = ByteBuffer.wrap( buffer , start , length ); IntBuffer result = IntBuffer.allocate( size ); for( int i = 0 ; i < size ; i++ ){ result.put( (int)( wrapBuffer.getShort() ) ); } result.position( 0 ); return result; }
Example 12
Source File: MatrixTrackingGL.java From PanoramaGL with Apache License 2.0 | 5 votes |
public void glMultMatrixx(IntBuffer m) { int position = m.position(); mCurrent.glMultMatrixx(m); m.position(position); mgl.glMultMatrixx(m); if ( _check) check(); }
Example 13
Source File: LwjglALC.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void alcGetInteger(int param, IntBuffer buffer, int size) { if (buffer.position() != 0) throw new AssertionError(); if (buffer.limit() != size) throw new AssertionError(); ALCcontext context = ALC10.alcGetCurrentContext(); ALCdevice device = ALC10.alcGetContextsDevice(context); ALC10.alcGetInteger(device, param, buffer); }
Example 14
Source File: LwjglEFX.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public void alGenEffects(final int numEffects, final IntBuffer buffers) { if (buffers.position() != 0) throw new AssertionError(); if (buffers.limit() != numEffects) throw new AssertionError(); EXTEfx.alGenEffects(buffers); }
Example 15
Source File: LwjglEFX.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public void alGenAuxiliaryEffectSlots(int numSlots, IntBuffer buffers) { if (buffers.position() != 0) throw new AssertionError(); if (buffers.limit() != numSlots) throw new AssertionError(); EFX10.alGenAuxiliaryEffectSlots(buffers); }
Example 16
Source File: LwjglAL.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public void alDeleteBuffers(final int numBuffers, final IntBuffer buffers) { if (buffers.position() != 0) throw new AssertionError(); if (buffers.limit() != numBuffers) throw new AssertionError(); AL10.alDeleteBuffers(buffers); }
Example 17
Source File: LwjglEFX.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public void alGenEffects(int numEffects, IntBuffer buffers) { if (buffers.position() != 0) throw new AssertionError(); if (buffers.limit() != numEffects) throw new AssertionError(); EFX10.alGenEffects(buffers); }
Example 18
Source File: CacheReader.java From netbeans with Apache License 2.0 | 4 votes |
/** Locates metadata related to the passed id (converted into a byte * array). Returns either a bytebuffer with the position set to the * start of the metadata or null. */ private ByteBuffer findMetadataFor (byte[] id) throws IOException { System.err.println("FindMetadataFor " + new String(id)); long result = -1; //Get a buffer clone so we don't have threading problems - never //use the master buffer ByteBuffer buf = getMetaBuffer().asReadOnlyBuffer(); IntBuffer ibuf = buf.asIntBuffer(); do { //First, see if the ID (image filename) length matches the ID //we received - if it doesn't, no need to examine the record int thisIdLength = ibuf.get(); System.err.println("pos:" + ibuf.position() + " idLen: " + thisIdLength + " looking for len: " + id.length); if (thisIdLength == id.length) { //Mark the start of this metadata record and position to //the start of the ID entry System.err.println("Length match. Putting mark at " + (buf.position()) + " and moving to " + (buf.position() + ID_OFFSET) + " to check data"); buf.mark().position (buf.position() + ID_OFFSET); byte[] chars = new byte[id.length]; //Fetch the ID into the array, and reset the buffer position //for either returning or skipping to the next record buf.get(chars).reset(); System.err.println(" id from metadata: " + new String(chars)); //Compare it with the id we were passed if (Arrays.equals(chars, id)) { System.err.println(" MATCHED - position: " + buf.position()); return buf; } } //Skip ahead to the next record buf.position(buf.position() + METAENTRY_LENGTH); ibuf.position(buf.position() / 4); System.err.println("Buffer pos: " + buf.position() + " ibuf: " + ibuf.position()); } while (buf.position() <= buf.limit() - METAENTRY_LENGTH); return null; }
Example 19
Source File: BitmapOutput.java From AndroidFastImageProcessing with MIT License | votes |
@Override public void drawFrame() { if(frameBuffer == null) { if(getWidth() != 0 && getHeight() != 0) { initFBO(); } else { return; } } GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, frameBuffer[0]); super.drawFrame(); int[] pixels = new int[getWidth()*getHeight()]; IntBuffer intBuffer = IntBuffer.wrap(pixels); intBuffer.position(0); GLES20.glReadPixels(0, 0, getWidth(), getHeight(), GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, intBuffer); GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0); for(int i = 0; i < pixels.length; i++) { pixels[i] = (pixels[i] & (0xFF00FF00)) | ((pixels[i] >> 16) & 0x000000FF) | ((pixels[i] << 16) & 0x00FF0000); //swap red and blue to translate back to bitmap rgb style } Bitmap image = Bitmap.createBitmap(pixels, getWidth(), getHeight(), Bitmap.Config.ARGB_8888); callback.bitmapCreated(image); }
Example 20
Source File: BitmapOutput.java From UltimateAndroid with Apache License 2.0 | votes |
@Override public void drawFrame() { if(frameBuffer == null) { if(getWidth() != 0 && getHeight() != 0) { initFBO(); } else { return; } } GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, frameBuffer[0]); super.drawFrame(); int[] pixels = new int[getWidth()*getHeight()]; IntBuffer intBuffer = IntBuffer.wrap(pixels); intBuffer.position(0); GLES20.glReadPixels(0, 0, getWidth(), getHeight(), GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, intBuffer); GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0); for(int i = 0; i < pixels.length; i++) { pixels[i] = (pixels[i] & (0xFF00FF00)) | ((pixels[i] >> 16) & 0x000000FF) | ((pixels[i] << 16) & 0x00FF0000); //swap red and blue to translate back to bitmap rgb style } Bitmap image = Bitmap.createBitmap(pixels, getWidth(), getHeight(), Bitmap.Config.ARGB_8888); callback.bitmapCreated(image); }