Package org.sunflow.image.writers
Class EXRBitmapWriter
- java.lang.Object
-
- org.sunflow.image.writers.EXRBitmapWriter
-
- All Implemented Interfaces:
BitmapWriter
public class EXRBitmapWriter extends java.lang.Object implements BitmapWriter
-
-
Field Summary
Fields Modifier and Type Field Description private intchannelSizeprivate bytechannelTypeprivate byte[]comprbufprivate intcompressionprivate java.io.RandomAccessFilefileprivate java.lang.Stringfilenameprivate static byteFLOATprivate static intFLOAT_SIZEprivate static byteHALFprivate static intHALF_SIZEprivate static intNO_COMPRESSIONprivate static intOE_EXR_VERSIONprivate static intOE_MAGICprivate static intOE_TILED_FLAGprivate static intRLE_COMPRESSIONprivate static intRLE_MAX_RUNprivate static intRLE_MIN_RUNprivate long[][]tileOffsetsprivate longtileOffsetsPositionprivate inttileSizeprivate inttilesXprivate inttilesYprivate byte[]tmpbufprivate static intZIP_COMPRESSION
-
Constructor Summary
Constructors Constructor Description EXRBitmapWriter()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcloseFile()Close the file, this completes the bitmap writing process.private static intcompress(int tp, byte[] in, int inSize, byte[] out)voidconfigure(java.lang.String option, java.lang.String value)This method will be called before writing begins.voidopenFile(java.lang.String filename)Open a handle to the specified file for writing.private static intrleCompress(byte[] in, int inLen, byte[] out)private voidwriteEXRTile(int tileX, int tileY, int w, int h, Color[] tile, float[] alpha)voidwriteHeader(int width, int height, int tileSize)Write the bitmap header.private voidwriteRGBAHeader(int w, int h, int tileSize)voidwriteTile(int x, int y, int w, int h, Color[] color, float[] alpha)Write a tile of data.private voidwriteTileOffsets()
-
-
-
Field Detail
-
HALF
private static final byte HALF
- See Also:
- Constant Field Values
-
FLOAT
private static final byte FLOAT
- See Also:
- Constant Field Values
-
HALF_SIZE
private static final int HALF_SIZE
- See Also:
- Constant Field Values
-
FLOAT_SIZE
private static final int FLOAT_SIZE
- See Also:
- Constant Field Values
-
OE_MAGIC
private static final int OE_MAGIC
- See Also:
- Constant Field Values
-
OE_EXR_VERSION
private static final int OE_EXR_VERSION
- See Also:
- Constant Field Values
-
OE_TILED_FLAG
private static final int OE_TILED_FLAG
- See Also:
- Constant Field Values
-
NO_COMPRESSION
private static final int NO_COMPRESSION
- See Also:
- Constant Field Values
-
RLE_COMPRESSION
private static final int RLE_COMPRESSION
- See Also:
- Constant Field Values
-
ZIP_COMPRESSION
private static final int ZIP_COMPRESSION
- See Also:
- Constant Field Values
-
RLE_MIN_RUN
private static final int RLE_MIN_RUN
- See Also:
- Constant Field Values
-
RLE_MAX_RUN
private static final int RLE_MAX_RUN
- See Also:
- Constant Field Values
-
filename
private java.lang.String filename
-
file
private java.io.RandomAccessFile file
-
tileOffsets
private long[][] tileOffsets
-
tileOffsetsPosition
private long tileOffsetsPosition
-
tilesX
private int tilesX
-
tilesY
private int tilesY
-
tileSize
private int tileSize
-
compression
private int compression
-
channelType
private byte channelType
-
channelSize
private int channelSize
-
tmpbuf
private byte[] tmpbuf
-
comprbuf
private byte[] comprbuf
-
-
Method Detail
-
configure
public void configure(java.lang.String option, java.lang.String value)Description copied from interface:BitmapWriterThis method will be called before writing begins. It is used to set common attributes to file writers. Currently supported keywords include:- "compression"
- "channeltype": "byte", "short", "half", "float"
- Specified by:
configurein interfaceBitmapWriter
-
openFile
public void openFile(java.lang.String filename) throws java.io.IOExceptionDescription copied from interface:BitmapWriterOpen a handle to the specified file for writing. If the writer buffers the image and writes it on close, then the filename should be stored.- Specified by:
openFilein interfaceBitmapWriter- Parameters:
filename- filename to write the bitmap to- Throws:
java.io.IOException- thrown if an I/O error occurs
-
writeHeader
public void writeHeader(int width, int height, int tileSize) throws java.io.IOException, java.lang.UnsupportedOperationExceptionDescription copied from interface:BitmapWriterWrite the bitmap header. This may be defered if the image is buffered for writing all at once on close. Note that if tile size is positive, data sent to this class is guarenteed to arrive in tiles of that size (except at borders). Otherwise, it should be assumed that the data is random, and that it may overlap. The writer should then either throw an error or start buffering data manually.- Specified by:
writeHeaderin interfaceBitmapWriter- Parameters:
width- image widthheight- image heighttileSize- tile size or 0 if the image will not be sent in tiled form- Throws:
java.io.IOException- thrown if an I/O error occursjava.lang.UnsupportedOperationException- thrown if this writer does not support writing the image with the supplied tile size
-
writeTile
public void writeTile(int x, int y, int w, int h, Color[] color, float[] alpha) throws java.io.IOExceptionDescription copied from interface:BitmapWriterWrite a tile of data. Note that this method may be called by more than one thread, so it should be made thread-safe if possible.- Specified by:
writeTilein interfaceBitmapWriter- Parameters:
x- tile x coordinatey- tile y coordinatew- tile widthh- tile heightcolor- color dataalpha- alpha data- Throws:
java.io.IOException- thrown if an I/O error occurs
-
closeFile
public void closeFile() throws java.io.IOExceptionDescription copied from interface:BitmapWriterClose the file, this completes the bitmap writing process.- Specified by:
closeFilein interfaceBitmapWriter- Throws:
java.io.IOException- thrown if an I/O error occurs
-
writeRGBAHeader
private void writeRGBAHeader(int w, int h, int tileSize) throws java.io.IOException- Throws:
java.io.IOException
-
writeTileOffsets
private void writeTileOffsets() throws java.io.IOException- Throws:
java.io.IOException
-
writeEXRTile
private void writeEXRTile(int tileX, int tileY, int w, int h, Color[] tile, float[] alpha) throws java.io.IOException- Throws:
java.io.IOException
-
compress
private static final int compress(int tp, byte[] in, int inSize, byte[] out)
-
rleCompress
private static final int rleCompress(byte[] in, int inLen, byte[] out)
-
-