Using Imageutil - Motorola C370 Series Technical Manual

J2me developer guide
Hide thumbs Also See for C370 Series:
Table of Contents

Advertisement

8
Gaming API and Sound
24-bit color format (0xRRGGBB). The method parameters are the following:
The mutable destination Image whose pixels will be set;
left edge of the region;
- The width of the region;
array of RGB pixel values.
public static void setPixels(javax.microedition.lcdui.Image dest, int[] rgbData) throws
ArrayIndexOutOfBoundsException, IllegalArgumentException – Sets RGB pixel data
in the entirety of the destination image. The data must be stored in the int array in
row-major order using the standard 24-bit color format (0xRRGGBB). The method
parameters are
rgbData
public static Image getScaleImage(javax.microedition.lcdui.Image src, int width,
int height, int method) throws IllegalArgumentException – Creates a scaled version of
the source image using the desired scaling method. All platforms must implement the
SCALE_REPLICATE scaling method; other scaling methods may be optionally
supported. SCALE_REPLICATE is used if the requested scaling method is not
supported by the device. The method parameters are the following:
Image;
pixels, of the new Image, and
image data (see the item 0).

Using ImageUtil

The following code sample uses an image (tank.png) to create a data structure
(
rgbData
image.
The following is a code sample to show implementation of
rgbData
try {
Image tank = Image.createImage("tank.png");
} catch(Exception e) {
// The image can't be loaded
}
// creates a data structure to stores the RGB pixel data from Image
int rgbData[] = new int[tank.getHeight()*tank.getWidth()];
// Stores the RGB pixel data from Image
ImageUtil.getPixels(tank,rgbData);
// Draws the image pixel by pixel with the respective RGB pixel
data
for (i=0;i<tank.getHeight();i++) {
for (j=0;j<tank.getWidth();j++) {
- The vertical location of the top edge of the region;
y
height
- The mutable destination Image whose pixels will be set, and
dest
- The array of RGB pixel values.
- the width, in pixels, of the new Image,
width
) to stores the RGB pixel data. The
g.setColor(rgbData[i*tank.getWidth() + j]);
g.fillRect(j,i,1,1);
- The height of the region; and
height
- The desired method to be used to scale the
method
is used to draw the same
rgbData
rgbData
dest
- The horizontal location of
x
width
- The
rgbData
- the source
src
- the height, in
:
-
45

Advertisement

Table of Contents
loading

This manual is also suitable for:

C450 seriesC550 series

Table of Contents