Show image with data as byte[]

65 views
Skip to first unread message

Deepak Singh

unread,
Feb 8, 2012, 2:11:10 PM2/8/12
to google-we...@googlegroups.com

Hi All,

I ahve an image data as byte array.
byte[] imageData = x.getBytes();

I need to show it on my html page and am getting this data along with other data through Rpc.

What is the way to do it?

Thanks 
Deepak Singh

Jens

unread,
Feb 8, 2012, 2:32:45 PM2/8/12
to google-we...@googlegroups.com
You can represent the byte data using base64 and then create a Data URI using the base64 string but IE8 only supports up to 32kb of data via Data URI (IE6/7 are not supported): http://en.wikipedia.org/wiki/Data_URI_scheme

If the base64 representation of your image is bigger than 32kb and you want to support IE8 and probably also IE6/7 you need a servlet that returns your byte array with the correct content type header. That way the browser can directly display the image using your servlet url, just like any other image.
So instead of returning the byte array in your RPC call you will just return the image url.

-- J.

Deepak Singh

unread,
Feb 8, 2012, 2:45:05 PM2/8/12
to google-we...@googlegroups.com
So if i use the servlet to return the image data by setting it into response, the will be refreshed for every images . Am i right ?

Thanks
Deepak


-- J.

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/t50HV00QE-IJ.
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.



--
Deepak Singh

Deepak Singh

unread,
Feb 8, 2012, 2:46:10 PM2/8/12
to google-we...@googlegroups.com
Sorry.. Pls read as :

the 'page' will be refreshed
--
Deepak Singh
Reply all
Reply to author
Forward
0 new messages