Class JPEGSegmentUtil

java.lang.Object
com.twelvemonkeys.imageio.metadata.jpeg.JPEGSegmentUtil

public final class JPEGSegmentUtil extends Object
JPEGSegmentUtil
Version:
$Id: JPEGSegmentUtil.java,v 1.0 24.01.11 17.37 haraldk Exp$
  • Field Details

  • Constructor Details

    • JPEGSegmentUtil

      private JPEGSegmentUtil()
  • Method Details

    • readSegments

      public static List<JPEGSegment> readSegments(ImageInputStream stream, int marker, String identifier) throws IOException
      Reads the requested JPEG segments from the stream. The stream position must be directly before the SOI marker, and only segments for the current image is read.
      Parameters:
      stream - the stream to read from.
      marker - the segment marker to read
      identifier - the identifier to read, or null to match any segment
      Returns:
      a list of segments with the given app marker and optional identifier. If no segments are found, an empty list is returned.
      Throws:
      IIOException - if a JPEG format exception occurs during reading
      IOException - if an I/O exception occurs during reading
    • readSegments

      public static List<JPEGSegment> readSegments(ImageInputStream stream, Map<Integer,List<String>> segmentIdentifiers) throws IOException
      Reads the requested JPEG segments from the stream. The stream position must be directly before the SOI marker, and only segments for the current image is read.
      Parameters:
      stream - the stream to read from.
      segmentIdentifiers - the segment identifiers
      Returns:
      a list of segments with the given app markers and optional identifiers. If no segments are found, an empty list is returned.
      Throws:
      IIOException - if a JPEG format exception occurs during reading
      IOException - if an I/O exception occurs during reading
      See Also:
    • isRequested

      private static boolean isRequested(JPEGSegment segment, Map<Integer,List<String>> segmentIdentifiers)
    • containsSafe

      private static boolean containsSafe(JPEGSegment segment, Map<Integer,List<String>> segmentIdentifiers)
    • isImageDone

      private static boolean isImageDone(JPEGSegment segment)
    • asNullTerminatedAsciiString

      static String asNullTerminatedAsciiString(byte[] data, int offset)
    • asAsciiString

      static String asAsciiString(byte[] data, int offset, int length)
    • readSOI

      static void readSOI(ImageInputStream stream) throws IOException
      Throws:
      IOException
    • readSegment

      static JPEGSegment readSegment(ImageInputStream stream, Map<Integer,List<String>> segmentIdentifiers) throws IOException
      Throws:
      IOException
    • isKnownJPEGMarker

      public static boolean isKnownJPEGMarker(int marker)
    • main

      public static void main(String[] args) throws IOException
      Throws:
      IOException