Unable to stream image from midlet to browser?
My midlet acts as s开发者_Go百科erver , when i request any resource from midlet it must transferred to browser and displayed. Here i am able to transfer html files,but i am unable to transfer image through OutputStream. I am converting image to byte array also.
You're a bit light on detail here! I assume:
- you have converted your J2ME
Image
to anint[]
usingImage.getRGB()
- you are successfully sending the
int
array to wherever it needs to go, through your output stream (for example, by iterating through eachint
in the array, and sending it usingDataOutput.writeInt()
) - you are successfully reconstructing this array at the server end
- you are having difficulty converting the data back to an image at the server end
One way of doing this is to use BufferedImage
on the server. You'll need to send the image's width and height to the server, along with the int
array.
Then create a BufferedImage
as follows:
BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
img.setRGB(0, 0, width, height, intArray, 0, width);
HTH.
精彩评论