Join Now
Quality Rating:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)
Expertise Level:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)

This page was last modified 08:40, 25 September 2007.

How to receive an image from the server

From Forum Nokia Wiki

If you want to receive an image from the server (like a PNG file) with Java ME you should use this code:

// This snippet only works if the server send the image length
 
HttpConnection c = (HttpConnection) Connector.open("http://www.mydomain.com/myimage.png");
DataInputStream response = new DataInput(c.openInputStream());
byte[] receivedImage = new byte[c.getLength()];
response.readFully(receivedImage);
response.close();
 
// We have now the image in a byte array.
// We have to transform it in a LCUI Image object
 
Image im;
im = Image.createImage(receivedImage, 0, receivedImage.length);
 
// Now you can use this image to draw it on Canvas or store in RMS
Related Discussions
Thread Thread Starter Forum Replies Last Post
MaoscBufferCopied is not called. huangkuan Symbian Media (Graphics & Sounds) 3 2007-02-14 15:48
Receive data from a web site vxml team General Symbian C++ 15 2007-07-20 05:26
Sending plain text through socket xchewy Symbian Networking & Messaging 15 2008-03-13 13:02
J2ME end-to-end transactions Wilterdt Mobile Java General 6 2006-08-15 23:08
Question about Images in byte array format wise-owl Mobile Java Media (Graphics & Sounds) 2 2006-11-06 11:14
 
Powered by MediaWiki
     
     RDF Facets:
     
     
     qfnZtopicQUqfnTopicZjavaQ
     qfnZtypeQUqfnTypeZCommunityContentQ
     qfnZtypeQUqfnTypeZWebpageQ
     qfnZtypeQUqfnTypeZWikiContentQ
     qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX