ImageUtil Class

ImageUtil provides static methods useful to the manipulation of Image objects. Specifically, it provides methods for setting and getting RGB values, and also provides the ability to create a scaled instance of an existing Image.

ImageUtil Fields

The ImageUtil class defines the following fields:

public static final int SCALE_AREA - Area scaling method.

public static final int SCALE_REPLICATE - Replicate scaling method.

public static final int SCALE_SMOOTH - Smooth scaling method.

ImageUtil Methods

The ImageUtil class defines the following methods:

public static void getPixels(Image src, int x, int y, int width, int height, int[] rgbData) throws ArrayIndexOutOfBoundsException – Gets RGB pixel data from the specified region of the source image. The data is stored in the provided int array in row-major order using the standard 24-bit color format (0xRRGGBB). Note that the color information stored in the image may be subject to the capabilities of the device's display. The rgbData must be instantiated previously calling this method, according to pixel amount that the user is requiring to the method. The parameters are the following: src - the source Image to retrieve the pixel data from; x - the horizontal location of left edge of the region; y - the vertical location of the top edge of the region; width - the width of the region; height - the height of the region; height - the height of the region; and rgbData - the array in which the pixel data is to be stored.

public static void getPixels(Image src,

int[] rgbData) throws ArrayIndexOutOfBoundsException

Gets RGB pixel data from the entirety of the source image. The data is stored in the provided int array in row-major order using the standard 24-bit color format (0xRRGGBB). Note that the color information stored in the image may be subject to the capabilities of the device's display. The rgbData must be instantiated previously calling this method, according to pixel amount that the user is requiring to the method. The parameters are the following: src - the source Image to retrieve the pixel data from; and rgbData - the array in which the pixel data is to be stored.

public static void setPixels(javax.microedition.lcdui.Image dest, int x, int y, int width, int height, int[] rgbData) throws ArrayIndexOutOfBoundsException, IllegalArgumentException – Sets RGB pixel data in specified region of the destination image. The data must be stored in the int array in row-major order using the standard

Page 44
Image 44
Motorola C370, C550, C450 technical manual ImageUtil Class, ImageUtil Fields, ImageUtil Methods