Class RGBE
- java.lang.Object
-
- com.twelvemonkeys.imageio.plugins.hdr.RGBE
-
final class RGBE extends java.lang.Object
This 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 http://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 class
RGBE.FracExp
static class
RGBE.Header
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String
exposureString
private static java.lang.String
gammaString
private static double
huge
private static double
tiny
private static double
two54
private static double
twom54
private static int
VALID_EXPOSURE
private static int
VALID_GAMMA
private static int
VALID_PROGRAMTYPE
private static java.util.regex.Pattern
widthHeightPattern
-
Constructor Summary
Constructors Constructor Description RGBE()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description 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.private static boolean
finite(double x)
static void
float2rgbe(byte[] rgbe, float red, float green, float blue)
Standard conversion from float pixels to rgbe pixels.private static RGBE.FracExp
frexp(double x)
private static double
fromhilo(int hi, int lo)
private static int
hi(double x)
static double
ldexp(double value, int exp)
private static int
lo(double x)
static void
main(java.lang.String[] args)
static RGBE.Header
readHeader(java.io.DataInput in)
static void
readPixels(java.io.DataInput in, float[] data, int numpixels)
Simple read routine.static void
readPixelsRaw(java.io.DataInput in, byte[] data, int offset, int numpixels)
static void
readPixelsRawRLE(java.io.DataInput in, byte[] data, int offset, int scanline_width, int num_scanlines)
static void
rgbe2float(float[] rgb, byte[] rgbe, int startRGBEOffset)
Standard conversion from rgbe to float pixels.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.
-
-
-
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.IOException
Simple 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)
-
-