Package gaiasky.util.gdx.loader
Class PortableFloatMap
java.lang.Object
gaiasky.util.gdx.loader.PortableFloatMap
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionboolean
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
ConstructorDescriptionConstructs a blank Portable FloatMap image.PortableFloatMap
(File file) 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 TypeMethodDescriptionvoid
Writes this PFM image to the specified file.void
write
(OutputStream out) Writes this PFM image to the specified output stream.
-
Field Details
-
width
public int widthThe width of the image. Must be positive. -
height
public int heightThe height of the image. Must be positive. -
mode
The mode of the image, color/grayscale. Must not benull
. -
pixels
public float[] pixelsThe pixels in the image, in row-major order from bottom to top. Must not benull
. 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 bigEndianIndicates 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
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 isnull
IllegalArgumentException
- if the file data does not represent a valid PFM fileIOException
- if an I/O exception occurred
-
PortableFloatMap
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 isnull
IllegalArgumentException
- if the stream data does not represent a valid PFM fileIOException
- if an I/O exception occurred
-
-
Method Details
-
write
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 isnull
IllegalStateException
- if the width or height is zero/negative, or the pixel array is not exactly the expected lengthIllegalArgumentException
- if the width, height, and mode imply a pixel array length that exceedsInteger.MAX_VALUE
IOException
- if an I/O exception occurred
-
write
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 isnull
IllegalStateException
- if the width or height is zero/negative, or the pixel array is not exactly the expected lengthIllegalArgumentException
- if the width, height, and mode imply a pixel array length that exceedsInteger.MAX_VALUE
IOException
- if an I/O exception occurred
-