public class JpegSegmentReader
extends java.lang.Object
JPEG files are composed of a sequence of consecutive JPEG 'segments'. Each is identified by one of a set of byte
values, modelled in the JpegSegmentType
enumeration. Use readSegments
to read out the some
or all segments into a JpegSegmentData
object, from which the raw JPEG segment byte arrays may be accessed.
Modifier and Type | Field and Description |
---|---|
private static byte |
MARKER_EOI
Private, because one wouldn't search for it.
|
private static byte |
SEGMENT_IDENTIFIER
The 0xFF byte that signals the start of a segment.
|
private static byte |
SEGMENT_SOS
Private, because this segment crashes my algorithm, and searching for it doesn't work (yet).
|
Modifier | Constructor and Description |
---|---|
private |
JpegSegmentReader() |
Modifier and Type | Method and Description |
---|---|
static JpegSegmentData |
readSegments(java.io.File file,
java.lang.Iterable<JpegSegmentType> segmentTypes)
Processes the provided JPEG data, and extracts the specified JPEG segments into a
JpegSegmentData object. |
static JpegSegmentData |
readSegments(SequentialReader reader,
java.lang.Iterable<JpegSegmentType> segmentTypes)
Processes the provided JPEG data, and extracts the specified JPEG segments into a
JpegSegmentData object. |
private static final byte SEGMENT_IDENTIFIER
private static final byte SEGMENT_SOS
private static final byte MARKER_EOI
private JpegSegmentReader() throws java.lang.Exception
java.lang.Exception
public static JpegSegmentData readSegments(java.io.File file, java.lang.Iterable<JpegSegmentType> segmentTypes) throws JpegProcessingException, java.io.IOException
JpegSegmentData
object.
Will not return SOS (start of scan) or EOI (end of image) segments.
file
- a File
from which the JPEG data will be read.segmentTypes
- the set of JPEG segments types that are to be returned. If this argument is null
then all found segment types are returned.JpegProcessingException
java.io.IOException
public static JpegSegmentData readSegments(SequentialReader reader, java.lang.Iterable<JpegSegmentType> segmentTypes) throws JpegProcessingException, java.io.IOException
JpegSegmentData
object.
Will not return SOS (start of scan) or EOI (end of image) segments.
reader
- a SequentialReader
from which the JPEG data will be read. It must be positioned at the
beginning of the JPEG data stream.segmentTypes
- the set of JPEG segments types that are to be returned. If this argument is null
then all found segment types are returned.JpegProcessingException
java.io.IOException