| Reply | « Previous Thread | Next Thread » |
|
how to load image in java ?
i want to load image but i cant please help me ! javax.microedition.lcdui.Image image1; image1 = Image.createImage("C:/Nokia/Images/Pictuer/32.jpg"); |
|
You have to package the picture as part of the application, the phone/emulator don't have access to your computer's filesystem. Where exactly you need to put it depends on your build system, but usually you would have a "res" folder or something for your resources (like images and sounds). Then you load using the path inside the jar (so usually it would be something like "/32.jpg" or "/res/32.jpg", again, this depends on your build system).
shmoove |
|
if you want load image, you must put your image in "res" directory on your project. Than try this code :
javax.microedition.lcdui.Image image1; image1 = Image.createImage("/32.jpg"); |
| chinsuvent |
| View Public Profile |
| Find all posts by chinsuvent |
|
I dont think this work:
image1 = Image.createImage("/32.jpg"); J2me only support the png file. Try to get the inputstream using : this.getClass().getResourceAsStream(fileName); in your class file, then you can use the decoder to proecess. Hope it works. |
|
there are more than one way to create image
1- createImage(String name) : used only to createimage from a resource image in the same jar 2- createImage(InputStream stream) : neaded to create image from a stream ... that can be obtained by either this.getClass().getResourceAsStream(fileName) to get a file in the same jar or Connector.openConnection() to get a file on the file system if you have a (JSR75) implementation ..... i think that is what the question is asking about 3- createRGBImage(int[] rgb, int width, int height, boolean processAlpha) : used to create image from an int[] that contains the RGB values for the image points for any questions send me back amr_alhossary@hotmail.com |
| amr_alhossary |
| View Public Profile |
| Find all posts by amr_alhossary |
| Reply | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|
| Thread | Thread Starter | Forum | Replies | Last Post |
|---|---|---|---|---|
| When I load image from jpeg it awry | ramis55 | General Symbian C++ | 2 | 2005-11-29 13:25 |
| It takes time to load image on incoming call | rahulsingh | Symbian Tools & SDKs | 16 | 2005-07-05 09:24 |
| HELP: Mutable Image to Immutable Image? | rj_cybersilver | Mobile Java Media (Graphics & Sounds) | 1 | 2005-03-26 10:58 |
| PNG Image won't load | maaberge | Mobile Java General | 1 | 2003-11-16 19:13 |
| image failed to load | killarkai | Mobile Java Media (Graphics & Sounds) | 4 | 2003-07-25 14:07 |