congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
LittleEndianDataInput
Code IndexAdd Tabnine to your IDE (free)

How to use
LittleEndianDataInput
in
com.ardor3d.util

Best Java code snippets using com.ardor3d.util.LittleEndianDataInput (Showing top 20 results out of 315)

origin: com.ardor3d/ardor3d-core

public final void readFully(final byte b[], final int off, final int len) throws IOException {
  // this may look over-complicated, but the problem is that the InputStream.read() methods are
  // not guaranteed to fill up the buffer you pass to it. So we need to loop until we have filled
  // up the buffer or until we reach the end of the file.
  final int bytesRead = _stream.read(b, off, len);
  if (bytesRead == -1) {
    throw new EOFException("EOF reached");
  }
  if (bytesRead < len) {
    // we didn't get all the data we wanted, so read some more
    readFully(b, off + bytesRead, len - bytesRead);
  }
}
origin: com.ardor3d/ardor3d-core

  static DdsPixelFormat read(final LittleEndianDataInput in) throws IOException {
    final DdsPixelFormat format = new DdsPixelFormat();
    format.dwSize = in.readInt();
    if (format.dwSize != 32) {
      throw new Error("invalid pixel format size: " + format.dwSize);
    }
    format.dwFlags = in.readInt();
    format.dwFourCC = in.readInt();
    format.dwRGBBitCount = in.readInt();
    format.dwRBitMask = in.readInt();
    format.dwGBitMask = in.readInt();
    format.dwBBitMask = in.readInt();
    format.dwABitMask = in.readInt();
    return format;
  }
}
origin: Renanse/Ardor3D

public final double readDouble() throws IOException {
  return Double.longBitsToDouble(readLong());
}
origin: Renanse/Ardor3D

public Image load(final InputStream is, final boolean flipVertically) throws IOException {
  final LittleEndianDataInput in = new LittleEndianDataInput(is);
  // Read and check magic word...
  final int dwMagic = in.readInt();
  if (dwMagic != getInt("DDS ")) {
    throw new Error("Not a dds file.");
  }
  logger.finest("Reading DDS file.");
  // Create our data store;
  final DdsImageInfo info = new DdsImageInfo();
  info.flipVertically = flipVertically;
  // Read standard dds header
  info.header = DdsHeader.read(in);
  // if applicable, read DX10 header
  info.headerDX10 = info.header.ddpf.dwFourCC == getInt("DX10") ? DdsHeaderDX10.read(in) : null;
  // Create our new image
  final Image image = new Image();
  image.setWidth(info.header.dwWidth);
  image.setHeight(info.header.dwHeight);
  // update depth based on flags / header
  updateDepth(image, info);
  // add our format and image data.
  populateImage(image, info, in);
  // return the loaded image
  return image;
}
origin: Renanse/Ardor3D

DataInput di = dis;
if (isLittleEndian) {
  di = new LittleEndianDataInput(dis);
origin: Renanse/Ardor3D

public final short readShort() throws IOException {
  return (short) readUnsignedShort();
}
origin: com.ardor3d/ardor3d-core

public Image load(final InputStream is, final boolean flipVertically) throws IOException {
  final LittleEndianDataInput in = new LittleEndianDataInput(is);
  // Read and check magic word...
  final int dwMagic = in.readInt();
  if (dwMagic != getInt("DDS ")) {
    throw new Error("Not a dds file.");
  }
  logger.finest("Reading DDS file.");
  // Create our data store;
  final DdsImageInfo info = new DdsImageInfo();
  info.flipVertically = flipVertically;
  // Read standard dds header
  info.header = DdsHeader.read(in);
  // if applicable, read DX10 header
  info.headerDX10 = info.header.ddpf.dwFourCC == getInt("DX10") ? DdsHeaderDX10.read(in) : null;
  // Create our new image
  final Image image = new Image();
  image.setWidth(info.header.dwWidth);
  image.setHeight(info.header.dwHeight);
  // update depth based on flags / header
  updateDepth(image, info);
  // add our format and image data.
  populateImage(image, info, in);
  // return the loaded image
  return image;
}
origin: com.ardor3d/ardor3d-terrain

DataInput di = dis;
if (isLittleEndian) {
  di = new LittleEndianDataInput(dis);
origin: com.ardor3d/ardor3d-core

public final char readChar() throws IOException {
  return (char) readUnsignedShort();
}
origin: Renanse/Ardor3D

public final void readFully(final byte b[], final int off, final int len) throws IOException {
  // this may look over-complicated, but the problem is that the InputStream.read() methods are
  // not guaranteed to fill up the buffer you pass to it. So we need to loop until we have filled
  // up the buffer or until we reach the end of the file.
  final int bytesRead = _stream.read(b, off, len);
  if (bytesRead == -1) {
    throw new EOFException("EOF reached");
  }
  if (bytesRead < len) {
    // we didn't get all the data we wanted, so read some more
    readFully(b, off + bytesRead, len - bytesRead);
  }
}
origin: Renanse/Ardor3D

@Before
public void setup() throws Exception {
  in = new MockInputStream();
  array = new byte[10];
  littleEndien = new LittleEndianDataInput(in);
}
origin: Renanse/Ardor3D

  static DdsPixelFormat read(final LittleEndianDataInput in) throws IOException {
    final DdsPixelFormat format = new DdsPixelFormat();
    format.dwSize = in.readInt();
    if (format.dwSize != 32) {
      throw new Error("invalid pixel format size: " + format.dwSize);
    }
    format.dwFlags = in.readInt();
    format.dwFourCC = in.readInt();
    format.dwRGBBitCount = in.readInt();
    format.dwRBitMask = in.readInt();
    format.dwGBitMask = in.readInt();
    format.dwBBitMask = in.readInt();
    format.dwABitMask = in.readInt();
    return format;
  }
}
origin: com.ardor3d/ardor3d-core

public final short readShort() throws IOException {
  return (short) readUnsignedShort();
}
origin: com.ardor3d/ardor3d-core

public final double readDouble() throws IOException {
  return Double.longBitsToDouble(readLong());
}
origin: com.ardor3d/ardor3d-core

static final ByteBuffer readDXT(final LittleEndianDataInput in, final int totalSize, final DdsImageInfo info,
    final Image image) throws IOException {
  int mipWidth = info.header.dwWidth;
  int mipHeight = info.header.dwHeight;
  final ByteBuffer buffer = BufferUtils.createByteBuffer(totalSize);
  for (int mip = 0; mip < info.header.dwMipMapCount; mip++) {
    final byte[] data = new byte[info.mipmapByteSizes[mip]];
    in.readFully(data);
    if (!info.flipVertically) {
      buffer.put(data);
    } else {
      final byte[] flipped = flipDXT(data, mipWidth, mipHeight, image.getDataFormat());
      buffer.put(flipped);
      mipWidth = Math.max(mipWidth / 2, 1);
      mipHeight = Math.max(mipHeight / 2, 1);
    }
  }
  buffer.rewind();
  return buffer;
}
origin: com.ardor3d/ardor3d-core

public final float readFloat() throws IOException {
  return Float.intBitsToFloat(readInt());
}
origin: Renanse/Ardor3D

public final char readChar() throws IOException {
  return (char) readUnsignedShort();
}
origin: Renanse/Ardor3D

static final ByteBuffer readDXT(final LittleEndianDataInput in, final int totalSize, final DdsImageInfo info,
    final Image image) throws IOException {
  int mipWidth = info.header.dwWidth;
  int mipHeight = info.header.dwHeight;
  final ByteBuffer buffer = BufferUtils.createByteBuffer(totalSize);
  for (int mip = 0; mip < info.header.dwMipMapCount; mip++) {
    final byte[] data = new byte[info.mipmapByteSizes[mip]];
    in.readFully(data);
    if (!info.flipVertically) {
      buffer.put(data);
    } else {
      final byte[] flipped = flipDXT(data, mipWidth, mipHeight, image.getDataFormat());
      buffer.put(flipped);
      mipWidth = Math.max(mipWidth / 2, 1);
      mipHeight = Math.max(mipHeight / 2, 1);
    }
  }
  buffer.rewind();
  return buffer;
}
origin: Renanse/Ardor3D

public final float readFloat() throws IOException {
  return Float.intBitsToFloat(readInt());
}
origin: Renanse/Ardor3D

  public void run() {
    try {
      littleEndien.readFully(array);
    } catch (IOException e) {
      e.printStackTrace();
      fail("ioexception");
    }
  }
});
com.ardor3d.utilLittleEndianDataInput

Javadoc

LittleEndianDataInput is a class to read little-endian stored data via a InputStream. All functions work as defined in DataInput, but assume they come from a LittleEndian input stream.

Most used methods

  • <init>
    Creates a new LittleEndian reader from the given input stream. The stream is wrapped in a BufferedIn
  • readFully
  • readInt
  • readLong
  • readUnsignedShort

Popular in Java

  • Updating database using SQL prepared statement
  • getApplicationContext (Context)
  • getContentResolver (Context)
  • startActivity (Activity)
  • FileWriter (java.io)
    A specialized Writer that writes to a file in the file system. All write requests made by calling me
  • RandomAccessFile (java.io)
    Allows reading from and writing to a file in a random-access manner. This is different from the uni-
  • InetAddress (java.net)
    An Internet Protocol (IP) address. This can be either an IPv4 address or an IPv6 address, and in pra
  • NumberFormat (java.text)
    The abstract base class for all number formats. This class provides the interface for formatting and
  • Base64 (org.apache.commons.codec.binary)
    Provides Base64 encoding and decoding as defined by RFC 2045.This class implements section 6.8. Base
  • Logger (org.apache.log4j)
    This is the central class in the log4j package. Most logging operations, except configuration, are d
  • Best plugins for Eclipse
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now