Motorola C550 User Manual
8
Gaming API and Sound
Gaming API and Sound
45
24-bit color format (0xRRGGBB). The method parameters are the following:
dest
-
The mutable destination Image whose pixels will be set;
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; and
rgbData
- The
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
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
parameters are
dest
- The mutable destination Image whose pixels will be set, and
rgbData
- The array of RGB pixel values.
•
public static Image getScaleImage(javax.microedition.lcdui.Image src, int width,
int height, int method) throws IllegalArgumentException – Creates a scaled version of
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
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:
supported by the device. The method parameters are the following:
src
- the source
Image;
width
- the width, in pixels, of the new Image,
height
- the height, in
pixels, of the new Image, and
method
- The desired method to be used to scale the
image data (see the item 0).
Using ImageUtil
The following code sample uses an image (tank.png) to create a data structure
(
(
rgbData
) to stores the RGB pixel data. The
rgbData
is used to draw the same
image.
The following is a code sample to show implementation of
rgbData
:
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
data
for (i=0;i<tank.getHeight();i++) {
for (j=0;j<tank.getWidth();j++) {
g.setColor(rgbData[i*tank.getWidth() + j]);
g.fillRect(j,i,1,1);