Class ThumbsDBImageReader

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private Catalog catalog  
      private int currentImage  
      private boolean loadEagerly  
      private javax.imageio.ImageReader reader  
      private Entry root  
      private static int THUMBNAIL_OFFSET  
      private java.awt.image.BufferedImage[] thumbnails  
      • Fields inherited from class javax.imageio.ImageReader

        availableLocales, ignoreMetadata, input, locale, minIndex, originatingProvider, progressListeners, seekForwardOnly, updateListeners, warningListeners, warningLocales
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void abort()  
      private static void addImage​(java.awt.Container pParent, javax.imageio.ImageReader pReader, int pImageNo, java.lang.String pName)  
      private static javax.imageio.ImageReader createJPEGReader​(ThumbsDBImageReaderSpi pProvider)  
      private static javax.swing.JFrame createWindow​(java.lang.String pTitle)  
      void dispose()  
      int getHeight​(int pIndex)  
      java.util.Iterator<javax.imageio.ImageTypeSpecifier> getImageTypes​(int pIndex)  
      int getNumImages​(boolean allowSearch)
      Default implementation that always returns 1.
      int getWidth​(int pIndex)  
      private void init()  
      private void init​(int pIndex)  
      private void initCatalog()  
      private void initReader​(int pIndex)  
      private void initReaderListeners()  
      boolean isLoadEagerly()  
      boolean isPresent​(java.lang.String pFileName)  
      static void main​(java.lang.String[] pArgs)  
      java.awt.image.BufferedImage read​(int pIndex, javax.imageio.ImageReadParam pParam)
      Reads the image data from the given input stream, and returns it as a BufferedImage.
      java.awt.image.BufferedImage read​(java.lang.String pName, javax.imageio.ImageReadParam pParam)
      Reads the image data from the given input stream, and returns it as a BufferedImage.
      protected void resetMembers()
      Resets all member variables.
      void setInput​(java.lang.Object input, boolean seekForwardOnly, boolean ignoreMetadata)
      Overrides setInput, to allow easy access to the input, in case it is an ImageInputStream.
      void setLoadEagerly​(boolean pLoadEagerly)
      Instructs the reader wether it should read and cache alle thumbnails in sequence, during the first read operation.
      • Methods inherited from class javax.imageio.ImageReader

        abortRequested, addIIOReadProgressListener, addIIOReadUpdateListener, addIIOReadWarningListener, canReadRaster, checkReadParamBandSettings, clearAbortRequest, computeRegions, getAspectRatio, getAvailableLocales, getDefaultReadParam, getFormatName, getImageMetadata, getInput, getLocale, getMinIndex, getNumThumbnails, getOriginatingProvider, getRawImageType, getSourceRegion, getStreamMetadata, getThumbnailHeight, getThumbnailWidth, getTileGridXOffset, getTileGridYOffset, getTileHeight, getTileWidth, hasThumbnails, isIgnoringMetadata, isImageTiled, isRandomAccessEasy, isSeekForwardOnly, processImageComplete, processImageProgress, processImageStarted, processImageUpdate, processPassComplete, processPassStarted, processReadAborted, processSequenceComplete, processSequenceStarted, processThumbnailComplete, processThumbnailPassComplete, processThumbnailPassStarted, processThumbnailProgress, processThumbnailStarted, processThumbnailUpdate, processWarningOccurred, processWarningOccurred, read, readAll, readAll, readAsRenderedImage, readerSupportsThumbnails, readRaster, readThumbnail, readTile, readTileRaster, removeAllIIOReadProgressListeners, removeAllIIOReadUpdateListeners, removeAllIIOReadWarningListeners, removeIIOReadProgressListener, removeIIOReadUpdateListener, removeIIOReadWarningListener, setInput, setInput, setLocale
      • Methods inherited from class java.lang.Object

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

      • root

        private Entry root
      • thumbnails

        private java.awt.image.BufferedImage[] thumbnails
      • reader

        private final javax.imageio.ImageReader reader
      • currentImage

        private int currentImage
      • loadEagerly

        private boolean loadEagerly
    • Constructor Detail

      • ThumbsDBImageReader

        public ThumbsDBImageReader()
    • Method Detail

      • createJPEGReader

        private static javax.imageio.ImageReader createJPEGReader​(ThumbsDBImageReaderSpi pProvider)
      • isLoadEagerly

        public boolean isLoadEagerly()
      • setLoadEagerly

        public void setLoadEagerly​(boolean pLoadEagerly)
        Instructs the reader wether it should read and cache alle thumbnails in sequence, during the first read operation.

        This is useful mainly if you need to read all the thumbnails, and you need them in random order, as it requires less repositioning in the underlying stream.

        Parameters:
        pLoadEagerly - true if the reader should read all thumbs on first read
      • read

        public java.awt.image.BufferedImage read​(int pIndex,
                                                 javax.imageio.ImageReadParam pParam)
                                          throws java.io.IOException
        Reads the image data from the given input stream, and returns it as a BufferedImage.
        Specified by:
        read in class javax.imageio.ImageReader
        Parameters:
        pIndex - the index of the image to read
        pParam - additional parameters used while decoding, may be null, in which case defaults will be used
        Returns:
        a BufferedImage
        Throws:
        java.lang.IndexOutOfBoundsException - if pIndex is out of bounds
        java.lang.IllegalStateException - if the input source has not been set
        java.io.IOException - if an error occurs during reading
      • read

        public java.awt.image.BufferedImage read​(java.lang.String pName,
                                                 javax.imageio.ImageReadParam pParam)
                                          throws java.io.IOException
        Reads the image data from the given input stream, and returns it as a BufferedImage.
        Parameters:
        pName - the name of the image to read
        pParam - additional parameters used while decoding, may be null, in which case defaults will be used
        Returns:
        a BufferedImage
        Throws:
        java.io.FileNotFoundException - if the given file name is not found in the "Catalog" entry of the CompoundDocument
        java.lang.IllegalStateException - if the input source has not been set
        java.io.IOException - if an error occurs during reading
      • abort

        public void abort()
        Overrides:
        abort in class javax.imageio.ImageReader
      • setInput

        public void setInput​(java.lang.Object input,
                             boolean seekForwardOnly,
                             boolean ignoreMetadata)
        Description copied from class: ImageReaderBase
        Overrides setInput, to allow easy access to the input, in case it is an ImageInputStream.
        Overrides:
        setInput in class ImageReaderBase
        Parameters:
        input - the ImageInputStream or other Object to use for future decoding.
        seekForwardOnly - if true, images and metadata may only be read in ascending order from this input source.
        ignoreMetadata - if true, metadata may be ignored during reads.
        See Also:
        ImageInputStream
      • init

        private void init​(int pIndex)
                   throws java.io.IOException
        Throws:
        java.io.IOException
      • initReader

        private void initReader​(int pIndex)
                         throws java.io.IOException
        Throws:
        java.io.IOException
      • initReaderListeners

        private void initReaderListeners()
      • init

        private void init()
                   throws java.io.IOException
        Throws:
        java.io.IOException
      • initCatalog

        private void initCatalog()
                          throws java.io.IOException
        Throws:
        java.io.IOException
      • getNumImages

        public int getNumImages​(boolean allowSearch)
                         throws java.io.IOException
        Description copied from class: ImageReaderBase
        Default implementation that always returns 1.
        Overrides:
        getNumImages in class ImageReaderBase
        Parameters:
        allowSearch - ignored, unless overridden
        Returns:
        1, unless overridden
        Throws:
        java.io.IOException - never, unless overridden
      • getWidth

        public int getWidth​(int pIndex)
                     throws java.io.IOException
        Specified by:
        getWidth in class javax.imageio.ImageReader
        Throws:
        java.io.IOException
      • getHeight

        public int getHeight​(int pIndex)
                      throws java.io.IOException
        Specified by:
        getHeight in class javax.imageio.ImageReader
        Throws:
        java.io.IOException
      • getImageTypes

        public java.util.Iterator<javax.imageio.ImageTypeSpecifier> getImageTypes​(int pIndex)
                                                                           throws java.io.IOException
        Specified by:
        getImageTypes in class javax.imageio.ImageReader
        Throws:
        java.io.IOException
      • isPresent

        public boolean isPresent​(java.lang.String pFileName)
      • main

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

        private static javax.swing.JFrame createWindow​(java.lang.String pTitle)
      • addImage

        private static void addImage​(java.awt.Container pParent,
                                     javax.imageio.ImageReader pReader,
                                     int pImageNo,
                                     java.lang.String pName)
                              throws java.io.IOException
        Throws:
        java.io.IOException