com.flagstone.transform.util.image
Class ImageFilter

java.lang.Object
  extended by com.flagstone.transform.util.image.ImageFilter

public final class ImageFilter
extends Object

ImageFilter contains a set of convenience methods for processing the pixels in an image.


Constructor Summary
ImageFilter()
           
 
Method Summary
 byte[] adjustScan(int imgWidth, int imgHeight, byte[] img)
          Adjust the width of each row in an image so the data is aligned to a 16-bit word boundary when loaded in memory.
 void applyAlpha(byte[] img)
          Apply the level for the alpha channel to the red, green and blue colour channels for encoding the image so it can be added to a Flash movie.
 byte[] invertRGB(byte[] image, int width, int height)
           
 byte[] merge(byte[] img, byte[] colors)
          Concatenate the colour table and the image data together.
 byte[] mergeAlpha(byte[] img, byte[] colors)
          Concatenate the colour table and the image data together.
 void orderABGR(byte[] img)
          Reorder the image pixels from RGBA to ABGR.
 void orderAlpha(byte[] img)
          Reorder the image pixels from RGBA to ARGB.
 byte[] packColors(int imgWidth, int imgHeight, byte[] img)
          Convert an image with 32-bits for the red, green, blue and alpha channels to one where the channels each take 5-bits in a 16-bit word.
 byte[] removeAlpha(byte[] image)
           
 void reverseRGB(byte[] image)
           
 void reverseRGBA(byte[] image)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ImageFilter

public ImageFilter()
Method Detail

removeAlpha

public byte[] removeAlpha(byte[] image)

invertRGB

public byte[] invertRGB(byte[] image,
                        int width,
                        int height)

reverseRGB

public void reverseRGB(byte[] image)

reverseRGBA

public void reverseRGBA(byte[] image)

packColors

public byte[] packColors(int imgWidth,
                         int imgHeight,
                         byte[] img)
Convert an image with 32-bits for the red, green, blue and alpha channels to one where the channels each take 5-bits in a 16-bit word.

Parameters:
imgWidth - the width of the image in pixels.
imgHeight - the height of the image in pixels.
img - the image data.
Returns:
the image data with the red, green and blue channels packed into 16-bit words. Alpha is discarded.

adjustScan

public byte[] adjustScan(int imgWidth,
                         int imgHeight,
                         byte[] img)
Adjust the width of each row in an image so the data is aligned to a 16-bit word boundary when loaded in memory. The additional bytes are all set to zero and will not be displayed in the image.

Parameters:
imgWidth - the width of the image in pixels.
imgHeight - the height of the image in pixels.
img - the image data.
Returns:
the image data with each row aligned to a 16-bit boundary.

orderAlpha

public void orderAlpha(byte[] img)
Reorder the image pixels from RGBA to ARGB.

Parameters:
img - the image data.

orderABGR

public void orderABGR(byte[] img)
Reorder the image pixels from RGBA to ABGR.

Parameters:
img - the image data.

applyAlpha

public void applyAlpha(byte[] img)
Apply the level for the alpha channel to the red, green and blue colour channels for encoding the image so it can be added to a Flash movie.

Parameters:
img - the image data.

merge

public byte[] merge(byte[] img,
                    byte[] colors)
Concatenate the colour table and the image data together.

Parameters:
img - the image data.
colors - the colour table.
Returns:
a single array containing the red, green and blue (not alpha) entries from the colour table followed by the red, green, blue and alpha channels from the image. The alpha defaults to 255 for an opaque image.

mergeAlpha

public byte[] mergeAlpha(byte[] img,
                         byte[] colors)
Concatenate the colour table and the image data together.

Parameters:
img - the image data.
colors - the colour table.
Returns:
a single array containing entries from the colour table followed by the image.


Copyright © 2002-2010 Flagstone Software Ltd.. All Rights Reserved.