Class RGBE
java.lang.Object
com.twelvemonkeys.imageio.plugins.hdr.RGBE
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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static class
static class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final String
private static final String
private static final double
private static final double
private static final double
private static final double
private static final int
private static final int
private static final int
private static final Pattern
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate 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
static RGBE.Header
readHeader
(DataInput in) static void
readPixels
(DataInput in, float[] data, int numpixels) Simple read routine.static void
readPixelsRaw
(DataInput in, byte[] data, int offset, int numpixels) static void
readPixelsRawRLE
(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 Details
-
VALID_PROGRAMTYPE
private static final int VALID_PROGRAMTYPE- See Also:
-
VALID_GAMMA
private static final int VALID_GAMMA- See Also:
-
VALID_EXPOSURE
private static final int VALID_EXPOSURE- See Also:
-
gammaString
- See Also:
-
exposureString
- See Also:
-
widthHeightPattern
-
two54
private static final double two54- See Also:
-
twom54
private static final double twom54- See Also:
-
huge
private static final double huge- See Also:
-
tiny
private static final double tiny- See Also:
-
-
Constructor Details
-
RGBE
RGBE()
-
-
Method Details
-
readHeader
- Throws:
IOException
-
readPixels
Simple read routine. Will not correctly handle run length encoding.- Throws:
IOException
-
readPixelsRaw
public static void readPixelsRaw(DataInput in, byte[] data, int offset, int numpixels) throws IOException - Throws:
IOException
-
readPixelsRawRLE
public static void readPixelsRawRLE(DataInput in, byte[] data, int offset, int scanline_width, int num_scanlines) throws IOException - Throws:
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
-
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
-