Package java.nio

Examples of java.nio.ShortBuffer


        fis.read(bb.array());
      }
      bb = ByteBuffer.allocate(MAX_NUM_CONFIGS * nShortByteSize);
      bb.order(bo);
      fis.read(bb.array());
      ShortBuffer sb = bb.asShortBuffer();
      for (int i = 0; i < this.ConfigLengths.length; i++) {
        this.ConfigLengths[i] = sb.get(i);
      }
      this.ProtoLengths = new short[NumProtoSets
          * Prototype.PROTOS_PER_PROTO_SET];
      Arrays.fill(this.ProtoLengths, (short) 0);
      bb = ByteBuffer.allocate(NumProtoSets
View Full Code Here


    ByteBuffer dest = ByteBuffer.allocateDirect(audio_bytes.length);
    dest.order(ByteOrder.nativeOrder());
    ByteBuffer src = ByteBuffer.wrap(audio_bytes);
    src.order(ByteOrder.LITTLE_ENDIAN);
    if (two_bytes_data) {
      ShortBuffer dest_short = dest.asShortBuffer();
      ShortBuffer src_short = src.asShortBuffer();
      while (src_short.hasRemaining())
        dest_short.put(src_short.get());
    } else {
      while (src.hasRemaining())
        dest.put(src.get());
    }
    dest.rewind();
View Full Code Here

    direct_buffer.position(buffer.position());
    return direct_buffer;
  }

  private static ShortBuffer doNoCopyWrap(ShortBuffer buffer) {
    ShortBuffer direct_buffer = lookupBuffer(buffer);
    direct_buffer.limit(buffer.limit());
    direct_buffer.position(buffer.position());
    return direct_buffer;
  }
View Full Code Here

    CachedBuffers buffers = getCachedBuffers(buffer.remaining()*2);
    return buffer.order() == ByteOrder.LITTLE_ENDIAN ? buffers.short_buffer_little : buffers.short_buffer_big;
  }

  private static ShortBuffer doWrap(ShortBuffer buffer) {
    ShortBuffer direct_buffer = lookupBuffer(buffer);
    direct_buffer.clear();
    int saved_position = buffer.position();
    direct_buffer.put(buffer);
    buffer.position(saved_position);
    direct_buffer.flip();
    return direct_buffer;
  }
View Full Code Here

      ja[i] = iter.getShortNext();
  }

  public ByteBuffer getDataAsByteBuffer() {
    ByteBuffer bb = ByteBuffer.allocate((int) (2 * getSize()));
    ShortBuffer ib = bb.asShortBuffer();
    ib.put((short[]) get1DJavaArray(short.class)); // make sure its in canonical order
    return bb;
  }
View Full Code Here

        Array sArray = Array.factory(DataType.BYTE, shape, bb.array());
        return (baseType == NCLibrary.NC_BYTE) ? sArray : MAMath.convertUnsigned(sArray);

      case NCLibrary.NC_SHORT:
      case NCLibrary.NC_USHORT:
        ShortBuffer sb = bb.asShortBuffer();
        sArray = Array.factory(DataType.SHORT, shape, sb.array());
        return (baseType == NCLibrary.NC_SHORT) ? sArray : MAMath.convertUnsigned(sArray);


      case NCLibrary.NC_INT:
      case NCLibrary.NC_UINT:
View Full Code Here

      case NCLibrary.NC_UBYTE:
        return Array.factory( DataType.BYTE.getPrimitiveClassType(), shape, bb.array());

      case NCLibrary.NC_SHORT:
      case NCLibrary.NC_USHORT:
        ShortBuffer sb = bb.asShortBuffer();
        return Array.factory( DataType.BYTE.getPrimitiveClassType(), shape, sb.array());

      case NCLibrary.NC_INT:
      case NCLibrary.NC_UINT:
        IntBuffer ib = bb.asIntBuffer();
        return Array.factory( DataType.BYTE.getPrimitiveClassType(), shape, ib.array());
View Full Code Here

                                       temp_image.nChannels() == ? FLYCAPTURE_MONO16 : FLYCAPTURE_RGB16);
            }

            if (conv_image.pixelFormat() == format && conv_image.iRowInc() == stride) {
                // we just need a copy to swap bytes..
                ShortBuffer in  = raw_image.getByteBuffer().order(frameEndian).asShortBuffer();
                ShortBuffer out = temp_image.getByteBuffer().order(ByteOrder.nativeOrder()).asShortBuffer();
                out.put(in);
                alreadySwapped = true;
            } else if (!colorrgb) {
                error = flycaptureConvertImage(context, raw_image, conv_image);
                if (error != FLYCAPTURE_OK) {
                    throw new Exception("flycaptureConvertImage() Error " + error);
                }
            }
        }

        if (!alreadySwapped && depth != IPL_DEPTH_8U &&
                !frameEndian.equals(ByteOrder.nativeOrder())) {
            // ack, the camera's endianness doesn't correspond to our machine ...
            // swap bytes of 16-bit images
            ByteBuffer  bb  = temp_image.getByteBuffer();
            ShortBuffer in  = bb.order(frameEndian).asShortBuffer();
            ShortBuffer out = bb.order(ByteOrder.nativeOrder()).asShortBuffer();
            out.put(in);
        }

        if (colorMode == ColorMode.BGR && numChannels != 3 && !colorbayer) {
            cvCvtColor(temp_image, return_image, CV_GRAY2BGR);
        } else if (colorMode == ColorMode.GRAY && (colorbayer || colorrgb)) {
View Full Code Here

            } else if (depth > 8 &&
                    frame.data_depth()   == conv_image.data_depth() &&
                    frame.color_coding() == conv_image.color_coding() &&
                    frame.stride()       == conv_image.stride()) {
                // we just need a copy to swap bytes..
                ShortBuffer in  = frame.getByteBuffer().order(frameEndian).asShortBuffer();
                ShortBuffer out = temp_image.getByteBuffer().order(ByteOrder.nativeOrder()).asShortBuffer();
                out.put(in);
                alreadySwapped = true;
            } else if (!colorrgb) {
                // from YUV, etc.
                err = dc1394_convert_frames(frame, conv_image);
                if (err != DC1394_SUCCESS) {
                    throw new Exception("dc1394_convert_frames() Error " + err + ": Could not convert frame.");
                }
            }
        }

        if (!alreadySwapped && depth > 8 && !frameEndian.equals(ByteOrder.nativeOrder())) {
            // ack, the camera's endianness doesn't correspond to our machine ...
            // swap bytes of 16-bit images
            ByteBuffer  bb  = temp_image.getByteBuffer();
            ShortBuffer in  = bb.order(frameEndian).asShortBuffer();
            ShortBuffer out = bb.order(ByteOrder.nativeOrder()).asShortBuffer();
            out.put(in);
        }

        // should we copy the padding as well?
        if (colorMode == ColorMode.BGR && numChannels != 3 && !colorbayer) {
            cvCvtColor(temp_image, return_image, CV_GRAY2BGR);
View Full Code Here

                        }
                    }
                    break;
                case CV_16U:
                case CV_16S:
                    ShortBuffer sb = getShortBuffer();
                    sb.position(index);
                    for (int i = 0; i < length; i++) {
                        if (d == CV_16U) {
                            vv[i+offset] = sb.get()&0xFFFF;
                        } else {
                            vv[i+offset] = sb.get();
                        }
                    }
                    break;
                case CV_32S:
                    IntBuffer ib = getIntBuffer();
View Full Code Here

TOP

Related Classes of java.nio.ShortBuffer

Copyright © 2018 www.massapicom. 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.