Package java.nio

Examples of java.nio.ByteOrder


        try {
            load_from_file(szUnicharFile);
            loadPffmTable(szPfmTable);
            FileInputStream fis = new FileInputStream(szIntTempFile);
            ByteBuffer bb = ByteBuffer.allocate(nIntByteSize * 3);
            ByteOrder bo = ByteOrder.BIG_ENDIAN;
            fis.read(bb.array());
            IntBuffer ib = bb.asIntBuffer();
            boolean swap = (ib.get(2) < 0 || ib.get(2) > MAX_NUM_CLASS_PRUNERS);
            if (swap) {
                bo = ByteOrder.LITTLE_ENDIAN;
View Full Code Here


  public PcapBlockRecordImpl(final FileCapture file, final FileEditor editor,
      final EditorHandle handle) throws IOException, FileFormatException {
    super(file, editor, handle, PcapFile.headerReader);

    final ByteBuffer b = this.getRecordBuffer();
    final ByteOrder order = this.determineByteOrder(b);
    editor.order(order);

  }
View Full Code Here

      final Filter<ProtocolFilterTarget> filter) throws IOException {
    if (t == PcapInput.class) {
      final BufferedReadableByteChannel b = new BufferedReadableByteChannel(in);
      b.mark(4);

      ByteOrder order = PcapInputCapture.checkFormat(b);

      b.reset();
      return t.cast(new PcapInputCapture(b, order, filter));

    } else if (t == SnoopInput.class) {
View Full Code Here

    final FormatType type = this.formatType(b);

    switch (type) {
      case Pcap:
        b.reset();
        ByteOrder order = PcapInputCapture.checkFormat(b);

        b.reset();
        return new PcapInputCapture(b, order, filter);

      case Snoop:
View Full Code Here

   *          source buffer
   * @return new buffer
   */
  public static ByteBuffer slice(ByteBuffer buffer) {

    final ByteOrder o = buffer.order();
    final ByteBuffer r = buffer.slice();
    r.order(o);

    return r;
  }
View Full Code Here

   *          source buffer
   * @return new buffer
   */
  public static ByteBuffer asReadonly(ByteBuffer buffer) {

    final ByteOrder o = buffer.order();
    final ByteBuffer r = buffer.asReadOnlyBuffer();
    r.order(o);

    return r;
  }
View Full Code Here

  }

  public static ByteBuffer copy(ByteBuffer buffer) {

    final int length = buffer.limit() - buffer.position();
    final ByteOrder o = buffer.order();
    final ByteBuffer r = ByteBuffer.allocate(length);
    r.order(o);

    r.put(buffer);
    r.clear(); // Reset position and limit after the put()
View Full Code Here

  public SnoopBlockRecordImpl(final FileCapture file, final FileEditor editor,
      final EditorHandle handle) throws IOException, FileFormatException {
    super(file, editor, handle, SnoopFile.headerReader);

    final ByteBuffer b = this.getRecordBuffer();
    final ByteOrder order = this.determineByteOrder(b);
    editor.order(order);

  }
View Full Code Here

    }

    if (vinfo.mfp != null) { // filtered
      if (debugFilter) System.out.println("read variable filtered " + v2.getFullName() + " vinfo = " + vinfo);
      assert vinfo.isChunked;
      ByteOrder bo = (vinfo.typeInfo.endian == 0) ? ByteOrder.BIG_ENDIAN : ByteOrder.LITTLE_ENDIAN;
      layout = new H5tiledLayoutBB(v2, wantSection, myRaf, vinfo.mfp.getFilters(), bo);
      data = IospHelper.readDataFill((LayoutBB) layout, v2.getDataType(), vinfo.getFillValue());

    } else { // normal case
      if (debug) System.out.println("read variable " + v2.getFullName() + " vinfo = " + vinfo);
View Full Code Here

        int numChannels = getNumChannels(format);
        error = flycaptureGetCameraRegister(context, IMAGE_DATA_FORMAT, regOut);
        if (error != FLYCAPTURE_OK) {
            throw new Exception("flycaptureGetCameraRegister() Error " + error);
        }
        ByteOrder frameEndian = (regOut[0] & 0x1) != 0 ?
                ByteOrder.BIG_ENDIAN : ByteOrder.LITTLE_ENDIAN;
        boolean alreadySwapped = false;
        boolean colorbayer = raw_image.bStippled();
        boolean colorrgb = format == FLYCAPTURE_RGB8 || format == FLYCAPTURE_RGB16 ||
                           format == FLYCAPTURE_BGR  || format == FLYCAPTURE_BGRU;

        if ((depth == IPL_DEPTH_8U || frameEndian.equals(ByteOrder.nativeOrder())) &&
                (colorMode == ColorMode.RAW || (colorMode == ColorMode.BGR && numChannels == 3 &&
                                                format    == FLYCAPTURE_BGR) ||
                (colorMode == ColorMode.GRAY && numChannels == 1 && !colorbayer))) {
            if (return_image == null) {
                return_image = IplImage.createHeader(w, h, depth, numChannels);
            }
            return_image.widthStep(stride);
            return_image.imageSize(size);
            return_image.imageData(raw_image.pData());
        } else {
            if (return_image == null) {
                return_image = IplImage.create(w, h, depth, colorMode == ColorMode.BGR ? 3 : 1);
            }
            if (temp_image == null) {
                if (colorMode == ColorMode.GRAY && colorbayer) {
                    temp_image = IplImage.create(w, h, depth, 3);
                } else if (colorMode == ColorMode.GRAY && colorrgb) {
                    temp_image = IplImage.createHeader(w, h, depth, 3);
                    temp_image.widthStep(stride);
                    temp_image.imageSize(size);
                    temp_image.imageData(raw_image.pData());
                } else {
                    temp_image = return_image;
                }
            }
            conv_image.iRowInc(temp_image.widthStep());
            conv_image.pData(temp_image.imageData());
            if (depth == IPL_DEPTH_8U) {
                conv_image.pixelFormat(colorMode == ColorMode.RAW ? FLYCAPTURE_RAW8 :
                                       temp_image.nChannels() == ? FLYCAPTURE_MONO8 : FLYCAPTURE_BGR);
            } else {
                conv_image.pixelFormat(colorMode == ColorMode.RAW ? FLYCAPTURE_RAW16 :
                                       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();
View Full Code Here

TOP

Related Classes of java.nio.ByteOrder

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.