Package com.drew.imaging.tiff
Class TiffReader
java.lang.Object
com.drew.imaging.tiff.TiffReader
Processes TIFF-formatted data, calling into client code via that
TiffHandler interface.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static intcalculateTagOffset(int ifdStartOffset, int entryNumber) Determine the offset of a given tag within the specified IFD.static voidprocessIfd(TiffHandler handler, RandomAccessReader reader, Set<Integer> processedIfdOffsets, int ifdOffset, int tiffHeaderOffset) Processes a TIFF IFD.private static voidprocessTag(TiffHandler handler, int tagId, int tagValueOffset, int componentCount, int formatCode, RandomAccessReader reader) voidprocessTiff(RandomAccessReader reader, TiffHandler handler, int tiffHeaderOffset) Processes a TIFF data sequence.
-
Constructor Details
-
TiffReader
public TiffReader()
-
-
Method Details
-
processTiff
public void processTiff(RandomAccessReader reader, TiffHandler handler, int tiffHeaderOffset) throws TiffProcessingException, IOException Processes a TIFF data sequence.- Parameters:
reader- theRandomAccessReaderfrom which the data should be readhandler- theTiffHandlerthat will coordinate processing and accept read valuestiffHeaderOffset- the offset withinreaderat which the TIFF header starts- Throws:
TiffProcessingException- if an error occurred during the processing of TIFF data that could not be ignored or recovered fromIOException- an error occurred while accessing the required data
-
processIfd
public static void processIfd(TiffHandler handler, RandomAccessReader reader, Set<Integer> processedIfdOffsets, int ifdOffset, int tiffHeaderOffset) throws IOException Processes a TIFF IFD. IFD Header:- 2 bytes number of tags
- 2 bytes tag type
- 2 bytes format code (values 1 to 12, inclusive)
- 4 bytes component count
- 4 bytes inline value, or offset pointer if too large to fit in four bytes
- Parameters:
handler- theTiffHandlerthat will coordinate processing and accept read valuesreader- theRandomAccessReaderfrom which the data should be readprocessedIfdOffsets- the set of visited IFD offsets, to avoid revisiting the same IFD in an endless loopifdOffset- the offset withinreaderat which the IFD data startstiffHeaderOffset- the offset withinreaderat which the TIFF header starts- Throws:
IOException- an error occurred while accessing the required data
-
processTag
private static void processTag(TiffHandler handler, int tagId, int tagValueOffset, int componentCount, int formatCode, RandomAccessReader reader) throws IOException - Throws:
IOException
-
calculateTagOffset
private static int calculateTagOffset(int ifdStartOffset, int entryNumber) Determine the offset of a given tag within the specified IFD.- Parameters:
ifdStartOffset- the offset at which the IFD startsentryNumber- the zero-based entry number
-