Using Palleteimage - Motorola C370 Series Technical Manual

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

Advertisement

8
Gaming API and Sound
public void setTransparentIndex(int index) throws
IndexOutOfBoundsException
that reference the transparent index in the palette are not drawn when the image is
rendered. The effects of the new transparent index will be reflected in the next Image
object that is created by calling getImage().
public int getPaletteSize() - Gets the number of entries in the
palette.
public int getPaletteEntry(int index) throws
IndexOutOfBoundsException
method returns the current color value of the entry (0xRRGGBB format).
public void setPaletteEntry(int index, int color)
throws
palette. The color must be specified using the MIDP color format (0xRRGGBB, the
upper 8 bits are ignored). The effects of the new palette will be reflected in the next
Image object that is created by calling getImage().
public int[] getPalette() – Gets the entire palette as an array of
ints, each one representing a 24-bit RGB value. The method returns a new int array
each time it is called, so this method should be used sparingly to avoid creating
excessive garbage.
public void setPalette(int[] newPalette) throws
ArrayIndexOutOfBoundsException, NullPointerException,
IllegalArgumentException
data must be specified using MIDP color format (0xRRGGBB, the upper 8 bits are
ignored). The size of the new palette must be at least as large as the value returned
by getPaletteSize(); additional palette entries, if present, are ignored. The
effects of the new palette will be reflected in the next Image object that is created by
calling getImage().

Using PalleteImage

PalleteImage
capabilities of the device. It also enables reuse of image data by allowing the developer to
change the color scheme. For example, a racing game may use a single
PaletteImage
series of
PaletteImage raceCar = new PaletteImage("car.png");
// Set the car color to red and retrieve the Image
raceCar.setPaletteEntry(0, 0xFF0000);
Image redRaceCar = raceCar.getImage();
// Set the car color to blue and retrieve the Image
IndexOutOfBoundsException
enables a developer to adjust the colors of an image to match the
of a car; the developer may then tweak the palette and generate a
of differently colored cars, as seen below:
Images
– Sets the current transparent index. Pixels
- Gets the specified entry in the palette. The
– Sets the specified entry in the
- Sets the palette data for this image. The palette
47

Advertisement

Table of Contents
loading

This manual is also suitable for:

C450 seriesC550 series

Table of Contents