×
Namespaces

Variants
Actions
(Difference between revisions)

Get Web Image in MIDlet

From Nokia Developer Wiki
Jump to: navigation, search
r60600 (Talk | contribs)
(Created page with "Category:Java MECategory:Series 40 MIDlet usually uses web image which can be get via <pre>private String url; private byte[] data; private int datalength; private Data...")
 
hamishwillee (Talk | contribs)
m (Hamishwillee - Bot addition of Template:ArticleMetaData)
Line 1: Line 1:
[[Category:Java ME]][[Category:Series 40]]
+
{{ArticleMetaData
 +
|sourcecode= <!-- Link to example source code e.g. [[Media:The Code Example ZIP.zip]] -->
 +
|installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) -->
 +
|devices= <!-- Devices tested against - e.g. ''devices=Nokia 6131 NFC, Nokia C7-00'') -->
 +
|sdk= <!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Nokia Qt SDK 1.1]) -->
 +
|platform= <!-- Compatible platforms - e.g. Symbian^1 and later, Qt 4.6 and later -->
 +
|devicecompatability= <!-- Compatible devices e.g.: All* (must have internal GPS) -->
 +
|dependencies= <!-- Any other/external dependencies e.g.: Google Maps Api v1.0 -->
 +
|signing=<!-- Signing requirements - empty or one of: Self-Signed, DevCert, Manufacturer -->
 +
|capabilities=<!-- Capabilities required by the article/code example (e.g. Location, NetworkServices. -->
 +
|keywords= <!-- APIs, classes and methods (e.g. QSystemScreenSaver, QList, CBase -->
 +
|id= <!-- Article Id (Knowledge base articles only) -->
 +
|language=<!-- Language category code for non-English topics - e.g. Lang-Chinese -->
 +
|review-by=<!-- After re-review: [[User:username]] -->
 +
|review-timestamp=<!-- After re-review: YYYYMMDD -->
 +
|update-by=<!-- After significant update: [[User:username]]-->
 +
|update-timestamp=<!-- After significant update: YYYYMMDD -->
 +
|creationdate=20110602
 +
|author=[[User:R60600]]
 +
}}[[Category:Java ME]][[Category:Series 40]]
  
 
MIDlet usually uses web image which can be get via
 
MIDlet usually uses web image which can be get via

Revision as of 03:23, 7 November 2011

Article Metadata
Article
Created: r60600 (02 Jun 2011)
Last edited: hamishwillee (07 Nov 2011)

MIDlet usually uses web image which can be get via

private String url;
private byte[] data;
private int datalength; 
private DataInputStream dis;
private HttpConnection hc;
url = "http://xx/xx.gif" /* or "http://xx/xx.jpg" */
try {
hc = (HttpConnection)Connector.open(url);
datalength = (int)hc.getLength();
dis = hc.openDataInputStream();
data = new byte[datalength];
dis.readFully(data);
if (datalength > 0) 
image = Image.createImage(data, 0, datalength); 
}catch (java.io.IOException x){}

If the image object is created successfully,it can be displayed by usual way. Such like in Canvas

protected void paint(Graphics g)
{
g.drawImage(image,0, 0, Graphics.LEFT|Graphics.TOP);
}
11 page views in the last 30 days.
×