Class RGBE
- java.lang.Object
-
- com.twelvemonkeys.imageio.plugins.hdr.RGBE
-
final class RGBE extends java.lang.ObjectThis file contains code to read and write four byte rgbe file format developed by Greg Ward. It handles the conversions between rgbe and pixels consisting of floats. The data is assumed to be an array of floats. By default there are three floats per pixel in the order red, green, blue. (RGBE_DATA_??? values control this.) Only the mimimal header reading and writing is implemented. Each routine does error checking and will return a status value as defined below. This code is intended as a skeleton so feel free to modify it to suit your needs.Ported to Java and restructured by Kenneth Russell. posted to www.graphics.cornell.edu/~bjw/ written by Bruce Walter (bjw@graphics.cornell.edu) 5/26/95 based on code written by Greg Ward
- See Also:
- Source
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classRGBE.FracExpstatic classRGBE.Header
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.StringexposureStringprivate static java.lang.StringgammaStringprivate static doublehugeprivate static doubletinyprivate static doubletwo54private static doubletwom54private static intVALID_EXPOSUREprivate static intVALID_GAMMAprivate static intVALID_PROGRAMTYPEprivate static java.util.regex.PatternwidthHeightPattern
-
Constructor Summary
Constructors Constructor Description RGBE()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static doublecopysign(double x, double y)copysign(double x, double y)
copysign(x,y) returns a value with the magnitude of x and with the sign bit of y.private static booleanfinite(double x)static voidfloat2rgbe(byte[] rgbe, float red, float green, float blue)Standard conversion from float pixels to rgbe pixels.private static RGBE.FracExpfrexp(double x)private static doublefromhilo(int hi, int lo)private static inthi(double x)static doubleldexp(double value, int exp)private static intlo(double x)static voidmain(java.lang.String[] args)static RGBE.HeaderreadHeader(java.io.DataInput in)static voidreadPixels(java.io.DataInput in, float[] data, int numpixels)Simple read routine.static voidreadPixelsRaw(java.io.DataInput in, byte[] data, int offset, int numpixels)static voidreadPixelsRawRLE(java.io.DataInput in, byte[] data, int offset, int scanline_width, int num_scanlines)static voidrgbe2float(float[] rgb, byte[] rgbe, int startRGBEOffset)Standard conversion from rgbe to float pixels.private static doublescalbn(double x, int n)scalbn (double x, int n)
scalbn(x,n) returns x* 2**n computed by exponent manipulation rather than by actually performing an exponentiation or a multiplication.
-
-
-
Field Detail
-
VALID_PROGRAMTYPE
private static final int VALID_PROGRAMTYPE
- See Also:
- Constant Field Values
-
VALID_GAMMA
private static final int VALID_GAMMA
- See Also:
- Constant Field Values
-
VALID_EXPOSURE
private static final int VALID_EXPOSURE
- See Also:
- Constant Field Values
-
gammaString
private static final java.lang.String gammaString
- See Also:
- Constant Field Values
-
exposureString
private static final java.lang.String exposureString
- See Also:
- Constant Field Values
-
widthHeightPattern
private static final java.util.regex.Pattern widthHeightPattern
-
two54
private static final double two54
- See Also:
- Constant Field Values
-
twom54
private static final double twom54
- See Also:
- Constant Field Values
-
huge
private static final double huge
- See Also:
- Constant Field Values
-
tiny
private static final double tiny
- See Also:
- Constant Field Values
-
-
Method Detail
-
readHeader
public static RGBE.Header readHeader(java.io.DataInput in) throws java.io.IOException
- Throws:
java.io.IOException
-
readPixels
public static void readPixels(java.io.DataInput in, float[] data, int numpixels) throws java.io.IOExceptionSimple read routine. Will not correctly handle run length encoding.- Throws:
java.io.IOException
-
readPixelsRaw
public static void readPixelsRaw(java.io.DataInput in, byte[] data, int offset, int numpixels) throws java.io.IOException- Throws:
java.io.IOException
-
readPixelsRawRLE
public static void readPixelsRawRLE(java.io.DataInput in, byte[] data, int offset, int scanline_width, int num_scanlines) throws java.io.IOException- Throws:
java.io.IOException
-
float2rgbe
public static void float2rgbe(byte[] rgbe, float red, float green, float blue)Standard conversion from float pixels to rgbe pixels.
-
rgbe2float
public static void rgbe2float(float[] rgb, byte[] rgbe, int startRGBEOffset)Standard conversion from rgbe to float pixels. Note: Ward uses ldexp(col+0.5,exp-(128+8)). However we wanted pixels in the range [0,1] to map back into the range [0,1].
-
ldexp
public static double ldexp(double value, int exp)
-
hi
private static int hi(double x)
-
lo
private static int lo(double x)
-
fromhilo
private static double fromhilo(int hi, int lo)
-
frexp
private static RGBE.FracExp frexp(double x)
-
finite
private static boolean finite(double x)
-
copysign
private static double copysign(double x, double y)copysign(double x, double y)
copysign(x,y) returns a value with the magnitude of x and with the sign bit of y.
-
scalbn
private static double scalbn(double x, int n)scalbn (double x, int n)
scalbn(x,n) returns x* 2**n computed by exponent manipulation rather than by actually performing an exponentiation or a multiplication.
-
main
public static void main(java.lang.String[] args)
-
-