Whats wrong with this code? I'm getting a broken icon image in
webview.
Bitmap page = loader.getPage(0);
ByteArrayOutputStream out = new ByteArrayOutputStream();
page.compress(Bitmap.CompressFormat.PNG, 100, out);
byte arrayData[] = out.toByteArray();
try {
String data = new String(arrayData, 0, arrayData.length,
"UTF-8");
mWebView.loadData(data, "image/png", "UTF-8");
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
On Sep 24, 11:33 am, rukiman <[email protected]> wrote:
> Am I able to use theloadData() function and just pass in the the raw
> byte data for a PNG if I make the encoding UCS-16 ?
>
> How can I convert a Bitmap to a String so I can pass intoloadData() ?
>
> On Sep 23, 2:53 pm, rukiman <[email protected]> wrote:
>
> > I have an instance of Bitmap that I want to load into the WebView. How
> > can I do this? I do not want to call webview.loadUrl() as the image is
> > already loaded from the file into memory . I am trying to optimize my
> > code.
>
> > I can see webview.loadData() however, seems like I have to encode
> > Bitmap into UTF-8?? I have two questions:
>
> > 1) How can I use webview.loadData() from a Bitmap instance?
>
> > 2) Is there a way I can tell WebView to load the instance of Bitmap
> > without having to encode the bitmap at all? For optimization purposes?
>
> > Thanks for your help.
--~--~---------~--~----~------------~-------~--~----~
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]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---