Class JPEGSegmentUtil


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

      Fields 
      Modifier and Type Field Description
      static java.util.List<java.lang.String> ALL_IDS  
      static java.util.Map<java.lang.Integer,​java.util.List<java.lang.String>> ALL_SEGMENTS  
      static java.util.Map<java.lang.Integer,​java.util.List<java.lang.String>> APP_SEGMENTS  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private JPEGSegmentUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) static java.lang.String asAsciiString​(byte[] data, int offset, int length)  
      (package private) static java.lang.String asNullTerminatedAsciiString​(byte[] data, int offset)  
      private static boolean containsSafe​(JPEGSegment segment, java.util.Map<java.lang.Integer,​java.util.List<java.lang.String>> segmentIdentifiers)  
      private static boolean isImageDone​(JPEGSegment segment)  
      static boolean isKnownJPEGMarker​(int marker)  
      private static boolean isRequested​(JPEGSegment segment, java.util.Map<java.lang.Integer,​java.util.List<java.lang.String>> segmentIdentifiers)  
      static void main​(java.lang.String[] args)  
      (package private) static JPEGSegment readSegment​(javax.imageio.stream.ImageInputStream stream, java.util.Map<java.lang.Integer,​java.util.List<java.lang.String>> segmentIdentifiers)  
      static java.util.List<JPEGSegment> readSegments​(javax.imageio.stream.ImageInputStream stream, int marker, java.lang.String identifier)
      Reads the requested JPEG segments from the stream.
      static java.util.List<JPEGSegment> readSegments​(javax.imageio.stream.ImageInputStream stream, java.util.Map<java.lang.Integer,​java.util.List<java.lang.String>> segmentIdentifiers)
      Reads the requested JPEG segments from the stream.
      (package private) static void readSOI​(javax.imageio.stream.ImageInputStream stream)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • ALL_IDS

        public static final java.util.List<java.lang.String> ALL_IDS
      • ALL_SEGMENTS

        public static final java.util.Map<java.lang.Integer,​java.util.List<java.lang.String>> ALL_SEGMENTS
      • APP_SEGMENTS

        public static final java.util.Map<java.lang.Integer,​java.util.List<java.lang.String>> APP_SEGMENTS
    • Constructor Detail

      • JPEGSegmentUtil

        private JPEGSegmentUtil()
    • Method Detail

      • readSegments

        public static java.util.List<JPEGSegment> readSegments​(javax.imageio.stream.ImageInputStream stream,
                                                               int marker,
                                                               java.lang.String identifier)
                                                        throws java.io.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:
        javax.imageio.IIOException - if a JPEG format exception occurs during reading
        java.io.IOException - if an I/O exception occurs during reading
      • readSegments

        public static java.util.List<JPEGSegment> readSegments​(javax.imageio.stream.ImageInputStream stream,
                                                               java.util.Map<java.lang.Integer,​java.util.List<java.lang.String>> segmentIdentifiers)
                                                        throws java.io.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:
        javax.imageio.IIOException - if a JPEG format exception occurs during reading
        java.io.IOException - if an I/O exception occurs during reading
        See Also:
        ALL_SEGMENTS, APP_SEGMENTS, ALL_IDS
      • isRequested

        private static boolean isRequested​(JPEGSegment segment,
                                           java.util.Map<java.lang.Integer,​java.util.List<java.lang.String>> segmentIdentifiers)
      • containsSafe

        private static boolean containsSafe​(JPEGSegment segment,
                                            java.util.Map<java.lang.Integer,​java.util.List<java.lang.String>> segmentIdentifiers)
      • isImageDone

        private static boolean isImageDone​(JPEGSegment segment)
      • asNullTerminatedAsciiString

        static java.lang.String asNullTerminatedAsciiString​(byte[] data,
                                                            int offset)
      • asAsciiString

        static java.lang.String asAsciiString​(byte[] data,
                                              int offset,
                                              int length)
      • readSOI

        static void readSOI​(javax.imageio.stream.ImageInputStream stream)
                     throws java.io.IOException
        Throws:
        java.io.IOException
      • readSegment

        static JPEGSegment readSegment​(javax.imageio.stream.ImageInputStream stream,
                                       java.util.Map<java.lang.Integer,​java.util.List<java.lang.String>> segmentIdentifiers)
                                throws java.io.IOException
        Throws:
        java.io.IOException
      • isKnownJPEGMarker

        public static boolean isKnownJPEGMarker​(int marker)
      • main

        public static void main​(java.lang.String[] args)
                         throws java.io.IOException
        Throws:
        java.io.IOException