Hi,

the code you posted refers to mBitmapScreenshot once, how did you
instantiate this, what is it content ? black maybe...

your code also refers to screenshot but the only time you access is
when you attempt to compress it into a byte array, what is it
content ? black maybe...

Regards

PS you won't get much help here, if you can't be bothered to check
your own code...

On Sep 9, 4:40 pm, Ajeet Singh <[email protected]> wrote:
> Hi All,
>
> I am trying to get the webview's content on a bitmap so that i can
> save it as a image. But I am unable to so. I am getting the BLACK
> image save instead. All content is missing :(
>
> Anybody can help me regarding this.
>
> Here is my code
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> //create a webview
> WebView w = new WebView(this);
>
> //Loads the url
> w.loadUrl("http://www.yahoo.com";);
>
> //After loading completely, take its picture
> Picture picture = w.capturePicture();
>
> //Create a new canvas
> Canvas mCanvas = new Canvas();
>
> //Draw the Picture into the Canvas
> picture.draw(mCanvas);
>
> //Create a Bitmap
> Bitmap sreenshot = Bitmap.createBitmap(picture.getWidth(),
> picture.getHeight(),Config.ARGB_8888);
>
> //copy the content fron Canvas to Bitmap
> mCanvas.drawBitmap(mBitmapScreenshot, 0, 0, null);
>
> //Save the Bitmap to local filesystem
> if(sreenshot != null) {
>         ByteArrayOutputStream mByteArrayOpStream = new
> ByteArrayOutputStream();
>         screenshot.compress(Bitmap.CompressFormat.JPEG, 90,
> mByteArrayOpStream);
>         try {
>                 fos = openFileOutput("yahoo.jpg",
> MODE_WORLD_WRITEABLE);
>                 fos.write(mByteArrayOpStream.toByteArray());
>                 fos.close();
>         } catch (FileNotFoundException e) {
>                 e.printStackTrace();
>         } catch (IOException e) {
>                 e.printStackTrace();
>         }
>
> }
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> Thanks,
> AJ
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to