Hi all, My midlet acts as server , 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.
A:
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.
funkybro
2010-02-11 10:55:57