Code example for CharBuffer

Methods: put

0
 
    public static CharBuffer createCharBuffer(char data[]) {
        ByteBuffer vbb = ByteBuffer.allocateDirect(data.length * 2);
        vbb.order(ByteOrder.nativeOrder());
        CharBuffer outBuffer = vbb.asCharBuffer();
        outBuffer.put(data).position(0);
        return outBuffer;
    }     
     
    public static ByteBuffer createByteBuffer(byte data[]) {
        ByteBuffer vbb = ByteBuffer.allocateDirect(data.length);
        vbb.put(data).position(0);
        return vbb;
    } 
     
    public static Bitmap getTextureFromBitmapResource(Context context, int resourceId) {
        Bitmap bitmap = null;
        Matrix yFlipMatrix = new Matrix();
        yFlipMatrix.postScale(1, -1); // flip Y axis
        try { 
            bitmap = BitmapFactory.decodeResource(context.getResources(), resourceId);