Class IFFUtil


  • final class IFFUtil
    extends java.lang.Object
    IFFUtil

    Bit rotate methods based on Sue-Ken Yap, "A Fast 90-Degree Bitmap Rotator," in GRAPHICS GEMS II, James Arvo ed., Academic Press, 1991, ISBN 0-12-064480-0.

    Version:
    $Id: IFFUtil.java,v 1.0 06.mar.2006 13:31:35 haku Exp$
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static long[][] RTABLE  
    • Constructor Summary

      Constructors 
      Constructor Description
      IFFUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) static void bitRotateCCW​(byte[] src, int srcPos, int srcStep, byte[] dst, int dstPos, int dstStep)
      Rotate bits counterclockwise.
      (package private) static void bitRotateCCW​(int[] src, int srcPos, int srcStep, byte[] dst, int dstPos, int dstStep)
      Rotate bits counterclockwise.
      (package private) static void bitRotateCW​(byte[] src, int srcPos, int srcStep, byte[] dst, int dstPos, int dstStep)
      Rotate bits clockwise.
      private static long[] rtable​(int n)
      Creates a rotation table
      (package private) static java.lang.String toChunkStr​(int chunkId)
      Converts an int to a four letter String.
      (package private) static int toInt​(byte[] bytes)
      Converts a byte array to an int.
      • Methods inherited from class java.lang.Object

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

      • RTABLE

        private static final long[][] RTABLE
    • Constructor Detail

      • IFFUtil

        IFFUtil()
    • Method Detail

      • rtable

        private static long[] rtable​(int n)
        Creates a rotation table
        Parameters:
        n - number of bits -1
        Returns:
        the rotation table
      • bitRotateCW

        static void bitRotateCW​(byte[] src,
                                int srcPos,
                                int srcStep,
                                byte[] dst,
                                int dstPos,
                                int dstStep)
        Rotate bits clockwise. The IFFImageReader uses this to convert pixel bits from planar to chunky. Bits from the source are rotated 90 degrees clockwise written to the destination.
        Parameters:
        src - source pixel data
        srcPos - starting index of 8 x 8 bit source tile
        srcStep - byte offset between adjacent rows in source
        dst - destination pixel data
        dstPos - starting index of 8 x 8 bit destination tile
        dstStep - byte offset between adjacent rows in destination
      • bitRotateCCW

        static void bitRotateCCW​(int[] src,
                                 int srcPos,
                                 int srcStep,
                                 byte[] dst,
                                 int dstPos,
                                 int dstStep)
        Rotate bits counterclockwise. The IFFImageWriter uses this to convert pixel bits from chunky to planar.
        Parameters:
        src - source pixel data (only lower 8 bits used)
        srcPos - starting index of 8 x 8 bit source tile
        srcStep - byte offset between adjacent rows in source
        dst - destination pixel data
        dstPos - starting index of 8 x 8 bit destination tile
        dstStep - byte offset between adjacent rows in destination
      • bitRotateCCW

        static void bitRotateCCW​(byte[] src,
                                 int srcPos,
                                 int srcStep,
                                 byte[] dst,
                                 int dstPos,
                                 int dstStep)
        Rotate bits counterclockwise. The IFFImageWriter uses this to convert pixel bits from chunky to planar.
        Parameters:
        src - source pixel data
        srcPos - starting index of 8 x 8 bit source tile
        srcStep - byte offset between adjacent rows in source
        dst - destination pixel data
        dstPos - starting index of 8 x 8 bit destination tile
        dstStep - byte offset between adjacent rows in destination
      • toInt

        static int toInt​(byte[] bytes)
        Converts a byte array to an int.
        Parameters:
        bytes - a byte array of length 4
        Returns:
        the bytes converted to an int
        Throws:
        java.lang.ArrayIndexOutOfBoundsException - if length is < 4
      • toChunkStr

        static java.lang.String toChunkStr​(int chunkId)
        Converts an int to a four letter String.
        Parameters:
        chunkId - the chunk identifier
        Returns:
        a String