Class IIOUtil

java.lang.Object
com.twelvemonkeys.imageio.util.IIOUtil

public final class IIOUtil extends Object
IIOUtil
Version:
$Id: IIOUtil.java,v 1.0 May 8, 2008 3:04:54 PM haraldk Exp$
  • Constructor Details

    • IIOUtil

      private IIOUtil()
  • Method Details

    • createStreamAdapter

      public static InputStream createStreamAdapter(ImageInputStream pStream)
      Creates an InputStream adapter that reads from an underlying ImageInputStream. The input stream will read until the end of pStream.
      Parameters:
      pStream - the stream to read from.
      Returns:
      an InputStream reading from pStream.
    • createStreamAdapter

      public static InputStream createStreamAdapter(ImageInputStream pStream, long pLength)
      Creates an InputStream adapter that reads from an underlying ImageInputStream. The input stream will read until the end of pStream, or at most pLength bytes has been read.
      Parameters:
      pStream - the stream to read from.
      pLength - the maximum number of bytes that can be read from pStream.
      Returns:
      an InputStream reading from pStream.
    • createStreamAdapter

      public static OutputStream createStreamAdapter(ImageOutputStream pStream)
      Creates an OutputStream adapter that writes to an underlying ImageOutputStream.

      Note: The adapter is buffered, and MUST be properly flushed/closed after use, otherwise data may be lost.

      Parameters:
      pStream - the stream to write to.
      Returns:
      an OutputSteam writing to pStream.
    • fakeSubsampling

      public static Image fakeSubsampling(Image pImage, IIOParam pParam)
    • getSourceRegion

      public static Rectangle getSourceRegion(IIOParam pParam, int pSrcWidth, int pSrcHeight)
    • fakeAOI

      public static BufferedImage fakeAOI(BufferedImage pImage, Rectangle pSourceRegion)
    • deregisterProvider

      public static <T> void deregisterProvider(ServiceRegistry registry, IIOServiceProvider provider, Class<T> category)
      THIS METHOD WILL BE MOVED/RENAMED, DO NOT USE.
      Parameters:
      registry - the registry to unregister from.
      provider - the provider to unregister.
      category - the category to unregister from.
    • lookupProviderByName

      public static <T> T lookupProviderByName(ServiceRegistry registry, String providerClassName, Class<T> category)
      THIS METHOD WILL BE MOVED/RENAMED, DO NOT USE.
      Parameters:
      registry - the registry to lookup from.
      providerClassName - name of the provider class.
      category - provider category
      Returns:
      the provider instance, or null if not found
    • getNormalizedReaderFormatNames

      public static String[] getNormalizedReaderFormatNames()
      Returns a sorted array of format names, that can be read by ImageIO. The names are all upper-case, and contains no duplicates.
      Returns:
      a normalized array of Strings.
      See Also:
    • getNormalizedWriterFormatNames

      public static String[] getNormalizedWriterFormatNames()
      Returns a sorted array of format names, that can be written by ImageIO. The names are all upper-case, and contains no duplicates.
      Returns:
      a normalized array of Strings.
      See Also:
    • normalizeNames

      private static String[] normalizeNames(String[] names)
    • subsampleRow

      public static void subsampleRow(byte[] srcRow, int srcPos, int srcWidth, byte[] destRow, int destPos, int samplesPerPixel, int bitsPerSample, int samplePeriod)
    • subsampleRow

      public static void subsampleRow(short[] srcRow, int srcPos, int srcWidth, short[] destRow, int destPos, int samplesPerPixel, int bitsPerSample, int samplePeriod)
    • subsampleRow

      public static void subsampleRow(int[] srcRow, int srcPos, int srcWidth, int[] destRow, int destPos, int samplesPerPixel, int bitsPerSample, int samplePeriod)
    • subsampleRow

      public static void subsampleRow(float[] srcRow, int srcPos, int srcWidth, float[] destRow, int destPos, int samplesPerPixel, int bitsPerSample, int samplePeriod)
    • subsampleRow

      public static void subsampleRow(double[] srcRow, int srcPos, int srcWidth, double[] destRow, int destPos, int samplesPerPixel, int bitsPerSample, int samplePeriod)
    • copyStandardParams

      public static <T extends IIOParam> T copyStandardParams(IIOParam source, T destination)
      Copies all the standard param values from source to destination.

      Typical use (in some imaginary FooImageWriter class):

      ImageWriteParam param = ...
      FooImageWriteparam fooParam = param instanceof FooImageWriteParam
           ? (FooImageWriteParam) param
           : copyStandardParams(param, getDefaultWriteParam());
      
      May also be useful for ImageReaders that delegate reading to other plugins (like a TIFF plugin delegating JPEG format decoding to a JPEGImageReader).
      Type Parameters:
      T - the plugin specific subclass of IIOParam
      Parameters:
      source - the source parameter, may be null
      destination - the destination parameter
      Returns:
      destination
      Throws:
      NullPointerException - if destination is null
    • copyImageWriteParams

      private static void copyImageWriteParams(ImageWriteParam source, ImageWriteParam destination)
    • copyImageReadParams

      private static void copyImageReadParams(ImageReadParam source, ImageReadParam destination)
    • copyIIOParams

      private static void copyIIOParams(IIOParam source, IIOParam destination)