Showing an image from a byte[]

Hi
I have created an image element from a byte like:
myImage = Image.createImage(chartAsBytes, 0, chartAsBytes.length);
nUIImageElement to_add = new nUIImageElement(-1, myImage);
The image’s size is originally 640x400. But when I create it, it only has 73x13, and I have not seen how to resize it.
Do I have to create the image in some other way?

Many thanks
Javier

Hi Javier,

That should work exactly as it is - Image.createImage performs no rescaling. What’s the image format, and (out of interest) what is the value of “chartAsBytes.length” - if it comes down as about 1KB or something, this would suggest you’re not actually being fed the 640x400 image you’re expecting.

Regards,

Nick.

Hi Nick,
The image is a png, and I size of the array is 33889.
Is there any way to store the image locally when running Phoney to see if the image is correct? (similar to when there is a problem when creating the image, I have seen that a file is created in the root folder of the project).
Many thanks
Javier

Is it possible to just pull down the PNG just via a web browser or something? If it’s the same filesize, it would suggest it’s the same content.

Also, when you say you’re getting a 73x13 image, by the aspect ratio it sound like you’re not just getting some scaled version of what you were expecting?

Nick.

Well, it is almost the same size (probably not a good sign). The saved image from browser has 33898 bytes, and the one from Phoney has 33889 bytes. If I try with other images, I am always missing 9 bytes. Does this mean that the http response where I get the image is missing something?

Many thanks
Javier

Hmmm, it doesn’t sound promising. Is it worth embedding the downloaded version into the app and then doing a runtime byte-for-byte comparison to the console of what you’re getting versus what you expect to try and see where the differences are occurring? We’ve not seen any arbitrary 9-byte loss of data transmissions anywhere else,

Nick.

I’ll give that a try… But, If I directly use an HttpConnection instead of the HttpConnectionHandler, then I get the expected size and the image is shown correctly.
The only difference I can see between the two is that HttpConnectionHandler has a header “Connection: close” (if I set PARAM_MD_HTTPCONNECTION_DOWNLOAD_IN_CHUNKS to true I get an exception) and HttpConnection has “Connection: keep-alive”.

Javier

Hi Javier,

Do you have a test URL we can try against here to replicate this issue?

Regards,

Nick.