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 [email protected]
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