# Showing an image from a byte\[\]

**URL:** <https://techcommunity.softwareag.com/t/showing-an-image-from-a-byte/100317>\
**Category:** Forum\
**Tags:** mobile\
**Created:** [February 1, 2012, 5:05pm UTC](https://techcommunity.softwareag.com/t/showing-an-image-from-a-byte/100317 "2012-02-01T17:05:00Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Javier\_Gallego](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/javier_gallego/32/77_2.png) [@Javier\_Gallego](https://techcommunity.softwareag.com/u/Javier_Gallego)\
**Post date:** [February 1, 2012, 5:05pm UTC](https://techcommunity.softwareag.com/t/showing-an-image-from-a-byte/100317/1 "2012-02-01T17:05:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [February 1, 2012, 5:07pm UTC](https://techcommunity.softwareag.com/t/showing-an-image-from-a-byte/100317/2 "2012-02-01T17:07:29Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Javier\_Gallego](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/javier_gallego/32/77_2.png) [@Javier\_Gallego](https://techcommunity.softwareag.com/u/Javier_Gallego)\
**Post date:** [February 1, 2012, 5:11pm UTC](https://techcommunity.softwareag.com/t/showing-an-image-from-a-byte/100317/3 "2012-02-01T17:11:13Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [February 1, 2012, 5:19pm UTC](https://techcommunity.softwareag.com/t/showing-an-image-from-a-byte/100317/4 "2012-02-01T17:19:23Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Javier\_Gallego](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/javier_gallego/32/77_2.png) [@Javier\_Gallego](https://techcommunity.softwareag.com/u/Javier_Gallego)\
**Post date:** [February 1, 2012, 6:29pm UTC](https://techcommunity.softwareag.com/t/showing-an-image-from-a-byte/100317/5 "2012-02-01T18:29:55Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [February 1, 2012, 6:50pm UTC](https://techcommunity.softwareag.com/t/showing-an-image-from-a-byte/100317/6 "2012-02-01T18:50:59Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Javier\_Gallego](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/javier_gallego/32/77_2.png) [@Javier\_Gallego](https://techcommunity.softwareag.com/u/Javier_Gallego)\
**Post date:** [February 1, 2012, 7:11pm UTC](https://techcommunity.softwareag.com/t/showing-an-image-from-a-byte/100317/7 "2012-02-01T19:11:59Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [February 1, 2012, 10:32pm UTC](https://techcommunity.softwareag.com/t/showing-an-image-from-a-byte/100317/8 "2012-02-01T22:32:06Z")

</div>

Hi Javier,

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

Regards,

Nick.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [April 2, 2021, 3:01pm UTC](https://techcommunity.softwareag.com/t/showing-an-image-from-a-byte/100317/9 "2021-04-02T15:01:51Z")

</div>


