Example usage for java.nio IntBuffer array

List of usage examples for java.nio IntBuffer array

Introduction

In this page you can find the example usage for java.nio IntBuffer array.

Prototype

public final int[] array() 

Source Link

Document

Returns the int array which this buffer is based on, if there is one.

Usage

From source file:Main.java

public static void main(String[] args) {
    IntBuffer intBuffer = IntBuffer.allocate(10);
    intBuffer.put(100);//from w  ww.  j  a v  a  2  s.  c om

    intBuffer.rewind();

    IntBuffer intBuffer2 = intBuffer.asReadOnlyBuffer();

    System.out.println(Arrays.toString(intBuffer2.array()));

}

From source file:Main.java

public static void main(String[] args) {
    IntBuffer bb = IntBuffer.wrap(new int[] { 0, 1, 2, 3, 4, 5, 6 });
    bb.put(100);/*  w  ww . java  2s  .  com*/
    System.out.println(Arrays.toString(bb.array()));

}

From source file:Main.java

public static void main(String[] args) {
    IntBuffer bb = IntBuffer.allocate(10);
    bb.put(100);//from w w  w  . j  a  va 2 s.  com

    bb.rewind();

    IntBuffer intBuffer2 = IntBuffer.allocate(10);

    intBuffer2.put(bb);

    System.out.println(Arrays.toString(intBuffer2.array()));

}

From source file:Main.java

public static void main(String[] args) {
    IntBuffer bb = IntBuffer.wrap(new int[] { 0, 1, 2, 3, 4, 5, 6 }, 0, 3);
    bb.put(100);/*from   w  w  w . j a  v  a2 s .  com*/
    System.out.println(Arrays.toString(bb.array()));

}

From source file:com.moscona.dataSpace.debug.ByteBufferTest.java

public static void main(String[] args) {
    ByteBuffer bytes = ByteBuffer.allocate(40);
    print("after allocation", bytes);
    byte[] byteArray = bytes.array();
    for (int i = 0; i < byteArray.length; i++) {
        byteArray[i] = 1;//from  ww  w. ja v a  2  s .c o  m
    }
    print("after filling with 1s", bytes);
    IntBuffer ints = bytes.asIntBuffer();
    System.out.println("ints has array: " + ints.hasArray());
    int[] array = ints.array();
    for (int i = 0; i < array.length; i++) {
        array[i] = 100 + i;
    }
    print("after filling ints array", bytes);
}

From source file:Main.java

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);
}

From source file:Main.java

public static void saveRgb2Bitmap(IntBuffer buf, String filePath, int width, int height) {
    final int[] pixelMirroredArray = new int[width * height];
    Log.d("TryOpenGL", "Creating " + filePath);
    BufferedOutputStream bos = null;
    try {/*from www.  j  a  va 2  s .  c om*/
        int[] pixelArray = buf.array();
        // rotate 180 deg with x axis because y is reversed
        for (int i = 0; i < height; i++) {
            for (int j = 0; j < width; j++) {
                pixelMirroredArray[(height - i - 1) * width + j] = pixelArray[i * width + j];
            }
        }
        bos = new BufferedOutputStream(new FileOutputStream(filePath));
        Bitmap bmp = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
        bmp.copyPixelsFromBuffer(IntBuffer.wrap(pixelMirroredArray));
        bmp.compress(Bitmap.CompressFormat.JPEG, 90, bos);
        bmp.recycle();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        if (bos != null) {
            try {
                bos.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}

From source file:com.wlanjie.streaming.camera.CameraView.java

@Override
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
    GLES20.glDisable(GL10.GL_DITHER);//from  www.  j  av  a 2s.  co m
    GLES20.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);

    HandlerThread thread = new HandlerThread("glDraw");
    thread.start();
    mHandler = new Handler(thread.getLooper()) {

        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            IntBuffer buffer = mEglCore.getRgbaBuffer();
            mFrameBuffer.asIntBuffer().put(buffer.array());
            if (mCallback != null) {
                mCallback.onPreviewFrame(CameraView.this, mFrameBuffer.array());
            }
        }
    };

    mEglCore = new EglCore(getResources());
    mEglCore.init();

    mSurfaceTexture.setOnFrameAvailableListener(new SurfaceTexture.OnFrameAvailableListener() {
        @Override
        public void onFrameAvailable(SurfaceTexture surfaceTexture) {
            mGLSurfaceView.requestRender();
        }
    });
}