Package gov.nih.mipav.model.file
Class FileRawChunk
java.lang.Object
gov.nih.mipav.model.file.FileBase
gov.nih.mipav.model.file.FileRawChunk
The class reads and writes raw files of all data types: boolean, byte, short, int, long, float, and double. For the
read process an offset can be passed as a parameter to identify the location in the file where the data starts. A
number of file formats while not "raw" have data at a specific location after a fixed length but unknown header and
therefore can be treated as raw.
- Version:
- 0.1 Sept 2, 1997
- Author:
- Matthew J. McAuliffe, Ph.D.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate intprivate intprivate BitSetDOCUMENT ME!private byte[]DOCUMENT ME!private double[]DOCUMENT ME!private float[]DOCUMENT ME!private int[]DOCUMENT ME!private long[]DOCUMENT ME!private short[]DOCUMENT ME!private intDOCUMENT ME!private intDOCUMENT ME!private DeflaterOutputStreamDOCUMENT ME!private FileInfoBaseDOCUMENT ME!private intprivate InflaterInputStreamDOCUMENT ME!private intUsed in reading and writing booleanprivate intprivate intDOCUMENT ME!static final intDOCUMENT ME!private booleanstatic final intDOCUMENT ME!private intUsed in reading and writing booleanprivate booleanprivate intDOCUMENT ME!Fields inherited from class gov.nih.mipav.model.file.FileBase
BIG_ENDIAN, bitsPerPixel, fileNames, LITTLE_ENDIAN, pBarVisible, raFile, READ, READ_WRITE -
Constructor Summary
ConstructorsConstructorDescriptionFileRawChunk(RandomAccessFile file, FileInfoBase fInfo) Raw reader/writer constructor.FileRawChunk(String fileName, FileInfoBase fInfo, int rwFlag, int compress) Compressed raw reader/writer constructor. -
Method Summary
Modifier and TypeMethodDescriptionfinal voidclose()Closes the file.voidfinalize()Prepares this class for cleanup.Gets the Bitset buffer (binary image).byte[]Gets the byte buffer (image).double[]Gets the double buffer (image).float[]Gets the float buffer (image).int[]gGets the integer buffer (image).long[]Gets the long buffer (image).short[]Gets the short buffer (image).voidreadImage(int type, long start, int length) This method reads a raw chunk from a file.voidsetBitsAllocated(int bitsAllocated) voidsetBitsStored(int bitsStored) voidsetHighBit(int highBit) voidsetImageFile(RandomAccessFile file, FileInfoBase fInfo) Sets the classes file handle to the past in the method.voidsetMinimumBitsMinus1(int minimumBitsMinus1) Used in reading and writing booleanvoidsetNumChannels(int numChannels) Sets the number of channels used in RGB files.voidsetPlanarConfig(int _planarConfig) Sets the planar configuration for RGB images.voidsetRGBAOrder(boolean RGBAOrder) DOCUMENT ME!voidsetShiftToDivide(int shiftToDivide) Used in reading and writing booleanvoidsetThreeByteInteger(boolean threeByteInteger) voidwriteBufferByte(byte[] buffer, int start, int end) This method writes a raw byte buffer to a file.voidwriteBufferDouble(double[] buffer, int start, int end, boolean endianess) This method writes a double buffer to a file.voidwriteBufferFloat(float[] buffer, int start, int end, boolean endianess) This method writes a float buffer to a file.voidwriteBufferInt(int[] buffer, int start, int end, boolean endianess) This method writes a int buffer to a file.voidwriteBufferLong(long[] buffer, int start, int end, boolean endianess) This method writes a int buffer to a file.voidwriteBufferRGB(int[] buffer, int start, int end) This method writes a RGB buffer to a file.voidwriteBufferRGB_USHORT(int[] buffer, int start, int end, boolean endianess) This method writes a RGB_USHORT buffer to a file.voidwriteBufferShort(short[] buffer, int start, int end, boolean endianess) This method writes a raw short buffer to a file.voidwriteBufferUByte(short[] buffer, int start, int end) This method writes a raw unsigned byte buffer to a file.voidwriteBufferUInt(long[] buffer, int start, int end, boolean endianess) This method writes an unisgned int buffer to a file.voidwriteBufferUShort(int[] buffer, int start, int end, boolean endianess) This method writes a raw unsigned short buffer to a file.voidwriteImage(ModelImage image, int start, int end) This method writes a raw image file (1D-5D).Methods inherited from class gov.nih.mipav.model.file.FileBase
addProgressChangeListener, bytesToDouble, bytesToFloat, bytesToInt, bytesToShort, doubleToBytes, fireProgressStateChanged, fireProgressStateChanged, fireProgressStateChanged, floatToBytes, getBufferDouble, getBufferFloat, getBufferInt, getBufferLong, getBufferShort, getBufferUShort, getDataType, getDouble, getFloat, getInt, getLong, getProgressChangeListeners, getRaFile, getSignedShort, getString, getUInt, getUnsignedByte, getUnsignedShort, intToBytes, isBigEndian, isProgressBarVisible, linkProgress, longToBytes, readDouble, readFloat, readInt, readLong, readShort, readString, readUnsignedShort, removeProgressChangeListener, setBigEndian, setBufferFloat, setBufferInt, setBufferLong, setBufferShort, setBufferString, setDataType, setEndianess, shortToBytes, writeBytes, writeDouble, writeFloat, writeInt, writeLong, writeShort
-
Field Details
-
RGB
public static final int RGBDOCUMENT ME!- See Also:
-
RRRGGGBBB
public static final int RRRGGGBBBDOCUMENT ME!- See Also:
-
bufferBitSet
DOCUMENT ME! -
bufferByte
private byte[] bufferByteDOCUMENT ME! -
bufferDouble
private double[] bufferDoubleDOCUMENT ME! -
bufferFloat
private float[] bufferFloatDOCUMENT ME! -
bufferInt
private int[] bufferIntDOCUMENT ME! -
bufferLong
private long[] bufferLongDOCUMENT ME! -
bufferShort
private short[] bufferShortDOCUMENT ME! -
bufferSize
private int bufferSizeDOCUMENT ME! -
compressionType
private int compressionTypeDOCUMENT ME! -
deflaterStream
DOCUMENT ME! -
fileInfo
DOCUMENT ME! -
inflaterStream
DOCUMENT ME! -
numChannels
private int numChannels -
planarConfig
private int planarConfigDOCUMENT ME! -
RGBAOrder
private boolean RGBAOrder -
type
private int typeDOCUMENT ME! -
minimumBitsMinus1
private int minimumBitsMinus1Used in reading and writing boolean -
shiftToDivide
private int shiftToDivideUsed in reading and writing boolean -
threeByteInteger
private boolean threeByteInteger -
bitsAllocated
private int bitsAllocated -
bitsStored
private int bitsStored -
highBit
private int highBit
-
-
Constructor Details
-
FileRawChunk
Raw reader/writer constructor.- Parameters:
file- random access file pointerfInfo- information that describes the image
-
FileRawChunk
Compressed raw reader/writer constructor.- Parameters:
fileName- the name of the file to read/writefInfo- information that describes the imagerwFlag- whether we are reading or writing the file (READ or WRITE)compress- the compression method to use (should not be none)
-
-
Method Details
-
close
Closes the file.- Throws:
IOException- DOCUMENT ME!
-
finalize
public void finalize()Prepares this class for cleanup. -
setMinimumBitsMinus1
public void setMinimumBitsMinus1(int minimumBitsMinus1) Used in reading and writing boolean- Parameters:
minimumBitsMinus1-
-
setThreeByteInteger
public void setThreeByteInteger(boolean threeByteInteger) -
setBitsAllocated
public void setBitsAllocated(int bitsAllocated) -
setBitsStored
public void setBitsStored(int bitsStored) -
setHighBit
public void setHighBit(int highBit) -
setShiftToDivide
public void setShiftToDivide(int shiftToDivide) Used in reading and writing boolean- Parameters:
shiftToDivide-
-
getBitSetBuffer
Gets the Bitset buffer (binary image).- Returns:
- the buffer
-
getByteBuffer
public byte[] getByteBuffer()Gets the byte buffer (image).- Returns:
- the buffer
-
getDoubleBuffer
public double[] getDoubleBuffer()Gets the double buffer (image).- Returns:
- the buffer
-
getFloatBuffer
public float[] getFloatBuffer()Gets the float buffer (image).- Returns:
- the buffer
-
getIntBuffer
public int[] getIntBuffer()gGets the integer buffer (image).- Returns:
- the buffer
-
getLongBuffer
public long[] getLongBuffer()Gets the long buffer (image).- Returns:
- the buffer
-
getShortBuffer
public short[] getShortBuffer()Gets the short buffer (image).- Returns:
- the buffer
-
readImage
This method reads a raw chunk from a file.- Parameters:
type- type of data that is to be readstart- points to where the data of the image is located.length- number of pixels to be read- Throws:
IOException- if there is an error reading the file
-
setImageFile
Sets the classes file handle to the past in the method.- Parameters:
file- random access file pointerfInfo- information that describes the image
-
setNumChannels
public void setNumChannels(int numChannels) Sets the number of channels used in RGB files.- Parameters:
numChannels- DOCUMENT ME!
-
setPlanarConfig
public void setPlanarConfig(int _planarConfig) Sets the planar configuration for RGB images.- Parameters:
_planarConfig- 0 indicates pixels are RGB, RGB chunky 1 indicates pixels are RRR, GGG, BBB planar
-
setRGBAOrder
public void setRGBAOrder(boolean RGBAOrder) DOCUMENT ME!- Parameters:
RGBAOrder- DOCUMENT ME!
-
writeBufferByte
This method writes a raw byte buffer to a file.- Parameters:
buffer- the image data bufferstart- start of data in the read image file in units of extents[0]*extents[1]end- end of data in the read image file in units of extents[0]*extents[1]- Throws:
IOException- DOCUMENT ME!
-
writeBufferDouble
public void writeBufferDouble(double[] buffer, int start, int end, boolean endianess) throws IOException This method writes a double buffer to a file.- Parameters:
buffer- the image data bufferstart- start of data in the read image file in units of extents[0]*extents[1]end- end of data in the read image file in units of extents[0]*extents[1]endianess- the endianess of the data- Throws:
IOException- DOCUMENT ME!
-
writeBufferFloat
public void writeBufferFloat(float[] buffer, int start, int end, boolean endianess) throws IOException This method writes a float buffer to a file.- Parameters:
buffer- the image data bufferstart- start of data in the read image file in units of extents[0]*extents[1]end- end of data in the read image file in units of extents[0]*extents[1]endianess- the endianess of the data- Throws:
IOException- DOCUMENT ME!
-
writeBufferInt
This method writes a int buffer to a file.- Parameters:
buffer- the image data bufferstart- start of data in the read image file in units of extents[0]*extents[1]end- end of data in the read image file in units of extents[0]*extents[1]endianess- the endianess of the data- Throws:
IOException- DOCUMENT ME!
-
writeBufferLong
public void writeBufferLong(long[] buffer, int start, int end, boolean endianess) throws IOException This method writes a int buffer to a file.- Parameters:
buffer- the image data bufferstart- start of data in the read image file in units of extents[0]*extents[1]end- end of data in the read image file in units of extents[0]*extents[1]endianess- the endianess of the data- Throws:
IOException- DOCUMENT ME!
-
writeBufferRGB
This method writes a RGB buffer to a file.- Parameters:
buffer- the image data bufferstart- start of data in the read image file in units of extents[0]*extents[1]end- end of data in the read image file in units of extents[0]*extents[1]- Throws:
IOException- DOCUMENT ME!
-
writeBufferRGB_USHORT
public void writeBufferRGB_USHORT(int[] buffer, int start, int end, boolean endianess) throws IOException This method writes a RGB_USHORT buffer to a file.- Parameters:
buffer- the image data bufferstart- start of data in the read image file in units of extents[0]*extents[1]end- end of data in the read image file in units of extents[0]*extents[1]endianess- the endianess of the data- Throws:
IOException- DOCUMENT ME!
-
writeBufferShort
public void writeBufferShort(short[] buffer, int start, int end, boolean endianess) throws IOException This method writes a raw short buffer to a file.- Parameters:
buffer- the image data bufferstart- start of data in the read image file in units of extents[0]*extents[1]end- end of data in the read image file in units of extents[0]*extents[1]endianess- the endianess of the data- Throws:
IOException- DOCUMENT ME!
-
writeBufferUByte
This method writes a raw unsigned byte buffer to a file.- Parameters:
buffer- image data bufferstart- start of data in the read image file in units of extents[0]*extents[1]end- end of data in the read image file in units of extents[0]*extents[1]- Throws:
IOException- DOCUMENT ME!
-
writeBufferUInt
public void writeBufferUInt(long[] buffer, int start, int end, boolean endianess) throws IOException This method writes an unisgned int buffer to a file.- Parameters:
buffer- the image data bufferstart- start of data in the read image file in units of extents[0]*extents[1]end- end of data in the read image file in units of extents[0]*extents[1]endianess- the endianess of the data- Throws:
IOException- DOCUMENT ME!
-
writeBufferUShort
public void writeBufferUShort(int[] buffer, int start, int end, boolean endianess) throws IOException This method writes a raw unsigned short buffer to a file.- Parameters:
buffer- the image data bufferstart- start of data in the read image file in units of extents[0]*extents[1]end- end of data in the read image file in units of extents[0]*extents[1]endianess- the endianess of the data- Throws:
IOException- DOCUMENT ME!
-
writeImage
This method writes a raw image file (1D-5D).- Parameters:
image- image model from which the data will be read.start- start of data in the read image file in units of extents[0]*extents[1]end- end of data in the read image file in units of extents[0]*extents[1]- Throws:
IOException- DOCUMENT ME!
-