I am digging into a problem that I have in downloading, saving and retrieving images on certain phone types.
My Images are held remotely and are downloaded via servlets and then stored on the phone using J2ME RMS.
This works fine for Nokia, Sony, Blackberry and most other PDA devices, However I have problems with LG and Samsung phones.
On looking at this problem I am confronted with a fairly basic problem.
If you examine the byte information in the actual PNG image data in memory it can contain values such as 89 (Hex Byte) which equates to 137 (decimal) this is the % symbol (default ascci).
Retrieving the information from the server using a stream ( in = new BufferedInputStream(new FileInputStream(fin)) returns a stream of integers (int) and the values returned are OK i.e 137 comes back as 137
However if you try to convert this int to a Byte you will get a negative value (-119) obviously because int can only have a value up to 127 and when the most significant bit is set it becomes negative.
My question is how can you convert the downloaded PNG image data to a byte array without corrupting it??
Obviously some phones including Nokia can manage this corruption and still display the image, but others (including the Sun standard colour-phone emulator do not)
It is also possible that I am doing something completely stupid. If so could someone reply with a few lines of code showing how to do this properly.