Class PortableFloatMap

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

public final class PortableFloatMap extends Object
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
     
  • Field Summary

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

    Constructors
    Constructor
    Description
    Constructs a blank Portable FloatMap image.
    Constructs a PFM image by reading from the specified file.
    Constructs a PFM image by reading from the specified input stream.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    write(File file)
    Writes this PFM image to the specified file.
    void
    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(File file) throws 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:
      NullPointerException - if the file is null
      IllegalArgumentException - if the file data does not represent a valid PFM file
      IOException - if an I/O exception occurred
    • PortableFloatMap

      public PortableFloatMap(InputStream in) throws 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:
      NullPointerException - if the stream is null
      IllegalArgumentException - if the stream data does not represent a valid PFM file
      IOException - if an I/O exception occurred
  • Method Details

    • write

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

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