java.lang.Object
com.twelvemonkeys.imageio.plugins.hdr.RGBE

final class RGBE extends 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 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 Classes
    Modifier and Type
    Class
    Description
    (package private) static class 
     
    static class 
     
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private 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
    Constructor
    Description
     
  • Method Summary

    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(String[] args)
     
     
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • RGBE

      RGBE()
  • Method Details

    • readHeader

      public static RGBE.Header readHeader(DataInput in) throws IOException
      Throws:
      IOException
    • readPixels

      public static void readPixels(DataInput in, float[] data, int numpixels) throws IOException
      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

      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(String[] args)