Examples of asShortBuffer()


Examples of java.nio.ByteBuffer.asShortBuffer()

            ByteBuffer bb = c.map(FileChannel.MapMode.READ_ONLY, c.position(), totalData);

            if (dataType == DataBuffer.TYPE_USHORT) {
                bb.order(ByteOrder.BIG_ENDIAN);
                bb.asShortBuffer().get((short[]) imageData.data);
            } else
                bb.get((byte[]) imageData.data);

            if (bb instanceof DirectBuffer)
                ((DirectBuffer) bb).cleaner().clean();
View Full Code Here

Examples of java.nio.ByteBuffer.asShortBuffer()

            {
                buffer.setData(newData.array());
            }
            else if (Format.shortArray.equals(dataClass))
            {
                buffer.setData(newData.asShortBuffer().array());
            }
            else if (Format.intArray.equals(dataClass))
            {
                buffer.setData(newData.asIntBuffer().array());
            }
View Full Code Here

Examples of java.nio.ByteBuffer.asShortBuffer()

    public void testBufferView() {
        ByteBuffer b = ByteBuffer.allocateDirect(100);
        assertTrue(b.isDirect());
        assertView("duplicate", b, b.duplicate(), 1);
        assertView("char view", b, b.asCharBuffer(), 2);
        assertView("short view", b, b.asShortBuffer(), 2);
        assertView("int view", b, b.asIntBuffer(), 4);
        assertView("float view", b, b.asFloatBuffer(), 4);
        assertView("double view", b, b.asDoubleBuffer(), 8);
        assertView("long view", b, b.asLongBuffer(), 8);
    }
View Full Code Here

Examples of java.nio.ByteBuffer.asShortBuffer()

        }
    }
   
    public void testDirectShortBufferArgument() {
        ByteBuffer buf  = ByteBuffer.allocateDirect(1024*2).order(ByteOrder.nativeOrder());
        ShortBuffer shortBuf = buf.asShortBuffer();
        final short MAGIC = (short)0xABED;
        lib.fillInt16Buffer(shortBuf, 1024, MAGIC);
        for (int i=0;i < shortBuf.capacity();i++) {
            assertEquals("Bad value at index " + i, MAGIC, shortBuf.get(i));
        }
View Full Code Here

Examples of java.nio.ByteBuffer.asShortBuffer()

        Pointer p = new Memory(1024);
        ByteBuffer b = p.getByteBuffer(0, 1024);
        assertEquals("ByteBuffer Pointer does not match",
                     p, Native.getDirectBufferPointer(b));
        assertEquals("ShortBuffer Pointer does not match",
                     p, Native.getDirectBufferPointer(b.asShortBuffer()));
        assertEquals("IntBuffer Pointer does not match",
                     p, Native.getDirectBufferPointer(b.asIntBuffer()));
        assertEquals("LongBuffer Pointer does not match",
                     p, Native.getDirectBufferPointer(b.asLongBuffer()));
        assertEquals("FloatBuffer Pointer does not match",
View Full Code Here

Examples of java.nio.ByteBuffer.asShortBuffer()

          ByteArrayInputStream bis = new ByteArrayInputStream(buf.array());
          return bis;
        } else if (type.getName().equals(CAS.TYPE_NAME_SHORT_ARRAY)) {
          arrayStart = this.getHeap().heap[getArrayStartAddress(fs.getAddress())];
          buf = ByteBuffer.allocate(arraySize * 2);
          ShortBuffer shortbuf = buf.asShortBuffer();
          shortbuf.put(this.getShortHeap().heap, arrayStart, arraySize);

          ByteArrayInputStream bis = new ByteArrayInputStream(buf.array());
          return bis;
        } else if (type.getName().equals(CAS.TYPE_NAME_LONG_ARRAY)) {
View Full Code Here

Examples of java.nio.ByteBuffer.asShortBuffer()

        this.channel = (new FileInputStream(this.file)).getChannel();
        try {
            ByteBuffer buff = channel.map(MapMode.READ_ONLY, 0, file.length());
            buff.order(BYTEORDER);
            this.buffer = buff.asShortBuffer();
        } catch (IOException ex) {
            this.channel.close();
            throw ex;
        }
    }
View Full Code Here

Examples of java.nio.ByteBuffer.asShortBuffer()

        if (bit_depth == 8) {
            for (int samp = 0; samp < number_samples; samp++)
                for (int chan = 0; chan < number_of_channels; chan++)
                    sample_values[chan][samp] = (double) byte_buffer.get() / max_sample_value;
        } else if (bit_depth == 16) {
            ShortBuffer short_buffer = byte_buffer.asShortBuffer();
            for (int samp = 0; samp < number_samples; samp++)
                for (int chan = 0; chan < number_of_channels; chan++)
                    sample_values[chan][samp] = (double) short_buffer.get() / max_sample_value;
        }
View Full Code Here

Examples of java.nio.ByteBuffer.asShortBuffer()

                for (double[] sample_value1 : sample_values) {
                    double sample_value = sample_value1[samp] * max_sample_value;
                    byte_buffer.put((byte) sample_value);
                }
        } else if (bit_depth == 16) {
            ShortBuffer short_buffer = byte_buffer.asShortBuffer();
            for (int samp = 0; samp < sample_values[0].length; samp++)
                for (double[] sample_value1 : sample_values) {
                    double sample_value = sample_value1[samp] * max_sample_value;
                    short_buffer.put((short) sample_value);
                }
View Full Code Here

Examples of java.nio.ByteBuffer.asShortBuffer()

                result = array;
                break;
            }
            case VariableInfo.SHORT: {
                final short[] array = new short[length];
                buffer.asShortBuffer().get(array);
                result = array;
                break;
            }
            case VariableInfo.INT: {
                final int[] array = new int[length];
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.