Class PortableFloatMap

java.lang.Object
gaiasky.util.gdx.loader.PortableFloatMap

public final class PortableFloatMap
extends java.lang.Object
  • Nested Class Summary

    Nested Classes
    Modifier and Type Class Description
    static class  PortableFloatMap.Mode  
  • Field Summary

    Fields
    Modifier and Type Field Description
    boolean bigEndian
    Indicates whether the image read was in big endian, or indicates whether to write the image in big endian.
    int height
    The height of the image.
    PortableFloatMap.Mode mode
    The mode of the image, color/grayscale.
    float[] pixels
    The pixels in the image, in row-major order from bottom to top.
    int width
    The width of the image.
  • Constructor Summary

    Constructors
    Constructor Description
    PortableFloatMap()
    Constructs a blank Portable FloatMap image.
    PortableFloatMap​(java.io.File file)
    Constructs a PFM image by reading from the specified file.
    PortableFloatMap​(java.io.InputStream in)
    Constructs a PFM image by reading from the specified input stream.
  • Method Summary

    Modifier and Type Method Description
    void write​(java.io.File file)
    Writes this PFM image to the specified file.
    void write​(java.io.OutputStream out)
    Writes this PFM image to the specified output stream.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • width

      public int width
      The width of the image. Must be positive.
    • height

      public int height
      The height of the image. Must be positive.
    • mode

      public PortableFloatMap.Mode mode
      The mode of the image, color/grayscale. Must not be null.
    • pixels

      public float[] pixels
      The pixels in the image, in row-major order from bottom to top. Must not be null. Grayscale images use 1 number per pixel. Color images use 3 numbers per pixel, in RGB order. (These details correspond with the low-level file format.)

      For grayscale, the array length must equal (width × height); for color it must equal (width × height × 3). The width, height, and mode must not make the pixel array length exceed Integer.MAX_VALUE.

    • bigEndian

      public boolean bigEndian
      Indicates whether the image read was in big endian, or indicates whether to write the image in big endian. Big endian is preferred for Java, while little endian is preferred for C/C++.
  • Constructor Details

    • PortableFloatMap

      public PortableFloatMap()
      Constructs a blank Portable FloatMap image.
    • PortableFloatMap

      public PortableFloatMap​(java.io.File file) throws java.io.IOException
      Constructs a PFM image by reading from the specified file. All 5 fields are set to values from the file.
      Parameters:
      file - the file to read from
      Throws:
      java.lang.NullPointerException - if the file is null
      java.lang.IllegalArgumentException - if the file data does not represent a valid PFM file
      java.io.IOException - if an I/O exception occurred
    • PortableFloatMap

      public PortableFloatMap​(java.io.InputStream in) throws java.io.IOException
      Constructs a PFM image by reading from the specified input stream. All 5 fields are set to values from the stream.

      The stream is not closed by this method. If successful, only the exact number of bytes for the image are read - no extra bytes are read past the end of the image, so it is possible to continue reading from the stream for other purposes. Otherwise if the file format is detected to be invalid or an I/O exception occurs, then an undetermined number of bytes will have been read.

      Parameters:
      in - the input stream to read from
      Throws:
      java.lang.NullPointerException - if the stream is null
      java.lang.IllegalArgumentException - if the stream data does not represent a valid PFM file
      java.io.IOException - if an I/O exception occurred
  • Method Details

    • write

      public void write​(java.io.File file) throws java.io.IOException
      Writes this PFM image to the specified file.
      Parameters:
      file - the file to write to
      Throws:
      java.lang.NullPointerException - if the file or mode or pixel array is null
      java.lang.IllegalStateException - if the width or height is zero/negative, or the pixel array is not exactly the expected length
      java.lang.IllegalArgumentException - if the width, height, and mode imply a pixel array length that exceeds Integer.MAX_VALUE
      java.io.IOException - if an I/O exception occurred
    • write

      public void write​(java.io.OutputStream out) throws java.io.IOException
      Writes this PFM image to the specified output stream.
      Parameters:
      out - the output stream to write to
      Throws:
      java.lang.NullPointerException - if the stream or mode or pixel array is null
      java.lang.IllegalStateException - if the width or height is zero/negative, or the pixel array is not exactly the expected length
      java.lang.IllegalArgumentException - if the width, height, and mode imply a pixel array length that exceeds Integer.MAX_VALUE
      java.io.IOException - if an I/O exception occurred