Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.sun.jimi.core.util
Class JimiUtil

    java.lang.Object
      |
      +--com.sun.jimi.core.util.JimiUtil

public class JimiUtil
extends java.lang.Object

This class contains several general utility methods which didnt really fit anywhere else.

The methods in this class are all static and hold no state.

This method uses an odd filename to create Error Image objects and Error ImageProducers which is a bit of a kludgey way to do it.

Field Summary
`static boolean` | `TRUE`

Constructor Summary
`JimiUtil()`

Method Summary
`static JimiRasterImage` | `asJimiRasterImage(JimiImage ji)` Take a JimiImage which is really a raster image and return the JimiRasterImage object for it.
`static byte` | `countBitsSet(int val)` This assumes that bits are set contiguously
`static void` | `expandOneBitPixels(byte[] input, byte[] output, int count)`
`static void` | `expandOneBitPixels(byte[] input, byte[] output, int count, int inputOffset, int outputOffset)`
`static void` | `expandOneBitPixelsToBW(byte[] input, int[] output, int count, int inputOffset, int outputOffset)`
`static void` | `expandPixels(int bitSize, byte[] in, byte[] out, int outLen)`
`static boolean` | `flagSet(int flaggedValue, int flag)`
`static boolean` | `flagsSet(int flaggedValue, int flags)`
`static byte[]` | `getChannelWidths(java.awt.image.ColorModel cm)`
`static java.awt.Image` | `getErrorImage()`
`static java.awt.image.ImageProducer` | `getErrorImageProducer()`
`static boolean` | `isCompatibleWithJavaVersion(int major, int minor)`
`static boolean` | `isRGBDefault(java.awt.image.ColorModel cm)` Currently this method is a bit dumb in that it assumes that the rgb default color model is a DirectColorModel.
`static void` | `packOneBitPixels(byte[] in, int inByte, byte[] out, int base, int outPixel, int len)` This is more general version of JimiUtil.packPixels() but restricted for 1 bit pixels.
`static void` | `packPixels(int[] in, int sindex, byte[] out, int dindex, int len)` Take pixels from buf each of depth 'depth' and stored in the least significant bits of byte.
`static int` | `packPixels(int depth, byte[] in, byte[] out)` Take pixels from buf each of depth 'depth' and stored in the least significant bits of byte.
`static void` | `pixelDepthChange(int depth, byte[] buf, int newDepth)` Designed to change the bit depth representation of pixel data.
`static void` | `runCommands(java.util.Vector commands)` Run commands contained in a Vector of Runnables.
`static JimiImageFactory` | `stripStamping(JimiImageFactory imageFactory)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### TRUE

    public static final boolean TRUE

Constructor Detail

### JimiUtil

    public JimiUtil()

Method Detail

### isRGBDefault

    public static boolean isRGBDefault(java.awt.image.ColorModel cm)

  Currently this method is a bit dumb in that it assumes that the rgb default color model is a DirectColorModel.
  Parameters:
    `cm` - color model to check if its rgb default color model
  Returns:
    true of the parameter color model is the same as the rgb default color model

### getChannelWidths

    public static byte[] getChannelWidths(java.awt.image.ColorModel cm)

  Parameters:
    `cm` - color model to retrieve the individual channel widths.
  Returns:
    an array filled in with the widths of the channels. in the color model. Always returns 4 element array with widths of the ALPHA, RED, GREEN, BLUE channels respectively filled in in order.

### countBitsSet

    public static byte countBitsSet(int val)

  This assumes that bits are set contiguously
  Parameters:
    `val` - count the bits set in this variable
  Returns:
    the number of bits set in the integer val

### getErrorImage

    public static java.awt.Image getErrorImage()

  Returns:
    Image which was created with an Error state.

### getErrorImageProducer

    public static java.awt.image.ImageProducer getErrorImageProducer()

  Returns:
    Image Producer which can only output an error to any Image Consumer registered with it.

### expandPixels

    public static void expandPixels(int bitSize,
                                    byte[] in,
                                    byte[] out,
                                    int outLen)

  Parameters:
    `bitSize` - the number of bits each pixel takes up in the bitpacked input array. can only be 1, 2 or 4.
    `in` - input array of bit packed pixels
    `out` - output array for expanded pixels. The size of this array determines how many pixels are retrieved from in and expanded.
    `outLen` - number of bytes to expand into the the out buffer.

### expandOneBitPixels

    public static void expandOneBitPixels(byte[] input,
                                          byte[] output,
                                          int count,
                                          int inputOffset,
                                          int outputOffset)

### expandOneBitPixelsToBW

    public static void expandOneBitPixelsToBW(byte[] input,
                                              int[] output,
                                              int count,
                                              int inputOffset,
                                              int outputOffset)

### expandOneBitPixels

    public static void expandOneBitPixels(byte[] input,
                                          byte[] output,
                                          int count)

### packOneBitPixels

    public static void packOneBitPixels(byte[] in,
                                        int inByte,
                                        byte[] out,
                                        int base,
                                        int outPixel,
                                        int len)

  This is more general version of JimiUtil.packPixels() but restricted for 1 bit pixels. This method copies 1 bit pixels from in[] to out[] and putting 8 1 bit pixels into each out[] byte.
  Parameters:
    `in` - the source array containing one-pixel-per-byte
    `inByte` - starting byte-index in source
    `out` - the buffer to pack 8-bit-per-pixel bytes into
    `base` - the starting byte-index in out
    `outPixel` - the bit-index of the first pixel to copy to
    `len` - how many pixels [1 pixel per byte] of data from 'in' to copy

### packPixels

    public static void packPixels(int[] in,
                                  int sindex,
                                  byte[] out,
                                  int dindex,
                                  int len)

  Take pixels from buf each of depth 'depth' and stored in the least significant bits of byte. Then pack several of them into each output byte array. This method only handles pixel depths that pack evenly into bytes - 1, 2, 4, 8 pixel depth of 8 is supported as a straight copy. The pixels are packed to most significant bits of outputs bytes first.
  Parameters:
    `depth` - depth of each pixel in buffer buf
    `in` - input set of pixels
    `out` - the output buffer for packed pixels. The processing continues until all pixels in the input buf are output to out[]
  Returns:
    the number of bytes used of in output to out. This includes any trailing bytes which may only be partially used.

### packPixels

    public static int packPixels(int depth,
                                 byte[] in,
                                 byte[] out)

  Take pixels from buf each of depth 'depth' and stored in the least significant bits of byte. Then pack several of them into each output byte array. This method only handles pixel depths that pack evenly into bytes - 1, 2, 4, 8 pixel depth of 8 is supported as a straight copy. The pixels are packed to most significant bits of outputs bytes first.
  Parameters:
    `depth` - depth of each pixel in buffer buf
    `in` - input set of pixels
    `out` - the output buffer for packed pixels. The processing continues until all pixels in the input buf are output to out[]
  Returns:
    the number of bytes used of in output to out. This includes any trailing bytes which may only be partially used.

### pixelDepthChange

    public static void pixelDepthChange(int depth,
                                        byte[] buf,
                                        int newDepth)

  Designed to change the bit depth representation of pixel data. Convert from depth bits per pixel representations in a byte upto newDepth bits per pixel representation. depth must be < newDepth. Example use for converting 2 bit grayscale image pixels into 8 bit grayscale image pixels equivalent.
  Parameters:
    `depth` - size of the pixel data stored in each entry in buf
    `buf` - buffer of one pixel per byte[] data to be modified so that pixel
    `newDepth` - the depth to convert each pixel to in buf.

### asJimiRasterImage

    public static JimiRasterImage asJimiRasterImage(JimiImage ji)

  Take a JimiImage which is really a raster image and return the JimiRasterImage object for it. This is useful when the object itself is a proxy and you want to get to the wrapped image.

### flagSet

    public static boolean flagSet(int flaggedValue,
                                  int flag)

### flagsSet

    public static boolean flagsSet(int flaggedValue,
                                   int flags)

### stripStamping

    public static JimiImageFactory stripStamping(JimiImageFactory imageFactory)

### isCompatibleWithJavaVersion

    public static boolean isCompatibleWithJavaVersion(int major,
                                                      int minor)

### runCommands

    public static void runCommands(java.util.Vector commands)

  Run commands contained in a Vector of Runnables.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD