Motorola C550, C450, C370 technical manual Using ImageUtil, RgbData

Page 45

8

Gaming API and Sound

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 row-major order using the standard 24-bit color format (0xRRGGBB). The method 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 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: 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

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);

45

Image 45
Contents Technical Manual Table of Contents Lcdui JAD Attributes Purpose IntroductionAudience DisclaimerReferences Definitions, Abbreviations, Acronyms Revision HistoryDate Name Reason Acronym DescriptionDocument Overview Introduction Java 2 Platform, Micro Edition J2ME J2ME IntroductionResources Available Motorola J2ME PlatformNetworking Description DisplayFile & RMS Java VMDeveloping and Packaging J2ME Applications Guide to Development in J2MEIntroduction to Development Page OTA Procedure InstallationDownloading Applications Program and Data space notes Java Application Installer/De-Installer Jaid Starting ApplicationsExiting Applications Error Checks Launching Web Session for Http DownloadDownloading MIDlets 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 conditionTCP Sockets UDP SocketsImplementation Notes Network API Description LcduiLcdui Gaming API and Sound Functional DescriptionClass Hierarchy BackgroundMusic Class Using BackgroundMusicBackgroundMusic Methods Gaming API containing a sound APIGameScreen Fields GameScreen ClassPublic int getKeyStates GameScreen MethodsInformation, disabling key events can improve performance GameScreen Using GameScreenImageUtil Class ImageUtil FieldsImageUtil Methods RgbData Using ImageUtilPalleteImage Class PalleteImage ConstructorPalleteImage Methods Public void setTransparentIndexint index throws Using PalleteImagePlayField Class Using Static and Animated TilesUsing Sprites Defining View WindowsPlayField Constructor 2N+1 2N + Public void addSpriteSprite s throws PlayField MethodsPage Public boolean collidesWithAnyTileSprite s throws PlayField Using PlayFieldSoundEffect Class Using SoundEffectSprite Class SoundEffect MethodsAnimation Frames Sprite DrawingSprite Constructor Sprite Methods Page Public final void drawGraphics g throws Using Sprite FileFormatNotSupportedExceptionSprites Max Midi Extension Support Java Gaming Sound APIFileFormatNotSupportedException Constructors Java Gaming Sound APIVibe and Backlight API Vibe and BacklightCreating a Message OverviewPermissions Sending a MessageJAD Attributes JAD AttributesMandatory attributes for manifest files MIDlet-Name Class Description Record Management SystemCode Examples RecordStoreCaveats 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 SheetsMotorola Developer Information Tools DocumentationReferences Purchase Motorola Developer Information Tools Motorola, Inc
Related manuals
Manual 110 pages 1.04 Kb