PDA

View Full Version : Image from byte array



gcorgnet
25 Nov 2007, 2:02 PM
Hi,

I am sorry if this question sounds silly ...

I have a gif image returned from a ASP.NET WebService as a byte array. Something like:


"{data:[68,174,66,96,130,...]}"What I would like to do is recreate the image on the client side and display it in the browser.

I searched through the forum but couldn't find anything about this issue.

I know this question can be borderline to be Ext-related but I figured someone could point me in the right direction

Thanks a lot

Guillaume

evant
25 Nov 2007, 4:21 PM
I don't think this is something you can do with javascript, why not change your web service to return the image itself?

efege
25 Nov 2007, 4:47 PM
There's a recent thread (http://extjs.com/forum/showthread.php?t=18744&highlight=binary) which might have some relevance.

gcorgnet
25 Nov 2007, 6:36 PM
I don't think this is something you can do with javascript, why not change your web service to return the image itself?

Well, I have Multipage TIFF on the server and I want to retrieve only the requested page. So the idea is that the WS gets the requested page and encode it in a JSON string.


There's a recent thread (http://extjs.com/forum/showthread.php?t=18744&highlight=binary) which might have some relevance.

Thanks a lot for your links. This was very helpful and I have now something to work with.

I'll update this thread with issues I have found.

Guillaume

devnull
26 Nov 2007, 9:18 AM
You really need to construct the image url and render it as part of an image element in the page. your asp script can easily enough return just the page you want as its own fully formed image. Even if reconstructing the image from binary data in javascript is possible, it is gonna be painfully slow so its just not a good idea.

gcorgnet
26 Nov 2007, 12:04 PM
You really need to construct the image url and render it as part of an image element in the page. your asp script can easily enough return just the page you want as its own fully formed image. Even if reconstructing the image from binary data in javascript is possible, it is gonna be painfully slow so its just not a good idea.

Thanks for the tip.
I managed to reconstruct image (about 50k) on the fly and put in inline in my HTML page using javascript. Image won't show up in IE though, only FF... Performance was very acceptable ...

However I think I am gonna have a look at your suggestion.

Guillaume