After hacking around a bit, I found out what the issue is.  My base64
string being sent is correct; I test this by directly encoding the
base64 string into html using <img src="data:image/jpeg;base64,/9j/
4AAQ....."/> where the complete jpeg is embedded in base64.  I tested
the Base64 string I'm sending to the webview in firefox and it worked.

The WebView isn't loading base64 image/jpeg's properly, but if I embed
the base64 string into the html, it will show up properly.

Hacky, but it works for now.

On Apr 2, 11:34 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> I have a byte array storing a JPEG that I'm trying to display in a
> WebView using WebView.loadData(String, mime, encoding), but I can't
> seem to get it to work properly.  I've tried reading it in as a basic
> string in ISO-8859-1, and in Base64 (using
> org.apache.commons.codec.binary.Base64, since there doesn't seem to be
> a Base64 encoder in android although they claim there's one in the
> android.util package).  My code:
>
> byte[] imagedata = new byte[jpeg_size];
> System.arraycopy(binary_file, offset, imagedata, 0, jpeg_size);
> try
> {
>   byte[] encodedData = Base64.encodeBase64(imagedata);
>   String imageString = new String(encodedData);
>   wv.loadData(imageString, "image/jpeg", "base64");}
>
> catch (Exception e)
> {
>   Log.e("error", e.toString());
>
> }
>
> I've analyzed the byte array that imagedata contains, and it's
> starting with the standard jpeg start (FF D8 FF E0 00 10), followed by
> 'JFIF', so I'm pretty sure it's not an error in the binary_file or in
> the imagedata.  However, my webview is only displaying a blue "X" (a
> broken image).
>
> Anyone have any ideas?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to