MIDP 1.0 will do. The data comes into the stream as an array of bytes and you use that array in the createImage() method:
Code:
/*-----------------------------------------------------------------
* Open an http connection and download a png file
* into a byte array.
*-----------------------------------------------------------------*/
private Image getImage(String url) throws IOException
{
ContentConnection connection = (ContentConnection) Connector.open(url);
DataInputStream iStrm = connection.openDataInputStream();
Image im = null;
try
{
// ContentConnection includes a length method
byte imageData[];
length = (int) connection.getLength();
if (length != -1)
{
imageData = new byte[length];
// Read the png into an array
iStrm.readFully(imageData);
}
else // Length not available...
{
ByteArrayOutputStream bStrm = new ByteArrayOutputStream();
int ch;
while ((ch = iStrm.read()) != -1)
bStrm.write(ch);
imageData = bStrm.toByteArray();
bStrm.close();
}
// Create the image from the byte array
im = Image.createImage(imageData, 0, imageData.length);
}
finally
{
// Clean up
if (iStrm != null)
iStrm.close();
if (connection != null)
connection.close();
}
return (im == null ? null : im);
}
shmoove