Motorola C370, C550, C450 Using PalleteImage, Public void setTransparentIndexint index throws

Page 47

8

Gaming API and Sound

public void setTransparentIndex(int index) throws

IndexOutOfBoundsException – Sets the current transparent index. Pixels 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 - Gets the specified entry in the palette. The method returns the current color value of the entry (0xRRGGBB format).

public void setPaletteEntry(int index, int color) throws IndexOutOfBoundsException – Sets the specified entry in the 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 - Sets the palette data for this image. The palette 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 enables a developer to adjust the colors of an image to match the 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 of a car; the developer may then tweak the palette and generate a series of Images of differently colored cars, as seen below:

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

47

Image 47
Contents Technical Manual Table of Contents Lcdui JAD Attributes Disclaimer IntroductionPurpose AudienceReferences Acronym Description Revision HistoryDefinitions, Abbreviations, Acronyms Date Name ReasonDocument Overview Introduction Java 2 Platform, Micro Edition J2ME J2ME IntroductionResources Available Motorola J2ME PlatformJava VM Description DisplayNetworking File & RMSIntroduction to Development Developing and Packaging J2ME ApplicationsGuide to Development in J2ME Page Downloading Applications OTA ProcedureInstallation Program and Data space notes Exiting Applications Java Application Installer/De-Installer JaidStarting Applications Downloading MIDlets Error ChecksLaunching Web Session for Http Download XML Screen Renderings BombMan is back, now on your Taichi series of handsets Taichi handset New Games MIDlet Lifecycle Application ManagementMIDlet Suite Installation MIDlet Suite De-installation DestroyApp MIDlet Suite UpdatingCaller Purpose MethodStartApp or the pauseApp Using startApp MIDlet Control of MIDlet State Transitions Java SystemPage Network Connections Network APIClass Descriptions URL Format IOException when it detects a time-out conditionImplementation Notes TCP SocketsUDP Sockets Network API Description LcduiLcdui Class Hierarchy Gaming API and SoundFunctional Description Gaming API containing a sound API Using BackgroundMusicBackgroundMusic Class BackgroundMusic MethodsGameScreen Fields GameScreen ClassPublic int getKeyStates GameScreen MethodsInformation, disabling key events can improve performance GameScreen Using GameScreenImageUtil Methods ImageUtil ClassImageUtil Fields RgbData Using ImageUtilPalleteImage Methods PalleteImage ClassPalleteImage Constructor Public void setTransparentIndexint index throws Using PalleteImagePlayField Class Using Static and Animated TilesPlayField Constructor Using SpritesDefining View Windows 2N+1 2N + Public void addSpriteSprite s throws PlayField MethodsPage Public boolean collidesWithAnyTileSprite s throws PlayField Using PlayFieldSoundEffect Methods Using SoundEffectSoundEffect Class Sprite ClassSprite Constructor Animation FramesSprite Drawing Sprite Methods Page Public final void drawGraphics g throws Sprites Using SpriteFileFormatNotSupportedException Java Gaming Sound API Java Gaming Sound APIMax Midi Extension Support FileFormatNotSupportedException ConstructorsVibe and Backlight API Vibe and BacklightCreating a Message OverviewPermissions Sending a MessageJAD Attributes JAD AttributesMandatory attributes for manifest files MIDlet-Name RecordStore Record Management SystemClass Description Code ExamplesCaveats TipsPhonebook Access API Phonebook AccessSample of code to create object of PhoneBookRecord class Phonebook Access API PermissionsSimmemory Sample of code for calling of ‘getMaxEmailLength ’ method Sample of code for calling of ‘isPrimaryint speedNo’ method Sample of code for calling of ‘getNumberCategories’ method Sample of code for calling of ‘setCategoryView’ method Sample of code for calling of ‘getUsedRecords’ method Int index = ReceivedRecord.getRecord1 Intelligent Keypad Text Entry API ITAPKey Mapping for the C370, C450, and C550 Appendix a Key MappingCenter Select END Available Memory Appendix B Memory Management CalculationAppendix C Online FAQC370, C450, and C550 Spec Sheets Appendix D Spec SheetsReferences Purchase Motorola Developer Information ToolsDocumentation Motorola Developer Information Tools Motorola, Inc
Related manuals
Manual 110 pages 1.04 Kb