How can I get a Image over http connections ?

How to draw a image in midp canvas which get from http connection ?thanks.
[95 byte] By [jun_w] at [2007-9-26 8:55:55]
# 1

For a preexisting image:

Image img = Image.createImage("/image.png"); //load the image

Displaying the image depends on whether you are using a Form or a Canvas. For a Form you simply append the image to the form:

form.append(img);

It will be displayed in the order that you appended it to the form.

For a Canvas you must use the Graphics object to put it on the screen:

g.drawImage(img, x, y, anchor);

The drawing of an image in a Canvas is normally done in the canvas.paint(Graphics g) method.

To access the PNG file it must be packaged into the MIDlet suite's JAR file. Otherwise, you download it as a binary using HTTP. If your images

are in an "images" directory then your code would look something like this:

Image image = null;

try

{

image = Image.createImage( "/images/foo.png" );

}

catch(IOException e)

{

}

mfali at 2007-7-1 19:54:46 > top of Java-index,Java Mobility Forums,Consumer and Commerce...