2

In my application I am loading some HTML content in BrowserField. I want to get the browser content as a Bitmap. I used following code.

Display.screenshot(Display.getWidth(), Display.getHeight());

But getting full screen. I need to take particular BrowserField as a Bitmap.

How can I achieve this?

Nate
  • 31,017
  • 13
  • 83
  • 207
prakash
  • 644
  • 4
  • 21
  • Get the position of the BrowserField in Screen. Then use the position, and dimension of the BrowserField to extract desired area from the captured screenshot. – Rupak Nov 07 '12 at 17:38
  • Hi Rupak can you explain bit more.. – prakash Nov 08 '12 at 05:27
  • i tried this way.. int h = mWebView.getHeight(); int w = mWebView.getWidth(); bitmap = new Bitmap(w, h); Display.screenshot(bitmap, 0, 0, w, h); but i got java.lang.IllegalArgumentException – prakash Nov 08 '12 at 05:28
  • 1
    That's because BrowserField is bigger that screen. You probably need dimensions of manager that holds this browser field. As well don't forget left corner coordinates – Eugen Martynov Nov 08 '12 at 07:07
  • i can get the left,right top, bottom of the Browser field from my manager... how can i drow the bitmap.. i got only empty bitmap – prakash Nov 08 '12 at 07:20
  • My Browser filed is bigger then the screen. i need to take full browser field as bitmap or image.. how can i achieve this... – prakash Nov 08 '12 at 07:26
  • I think you cann't get the screenshot of the whole screen using `Display.screenshot(..`. Let me know if you are able to get the screenshot of the whole screen. – Rupak Nov 08 '12 at 09:53
  • 1
    @Rupak, I remember there was limitation with Bitmap fields. You can't create or bitmap bigger than screen size or when you ask it's graphics it throws some weird Exception – Eugen Martynov Nov 08 '12 at 11:32
  • I tried that Rupak mentioned.. but still i cant get the full webview content... – prakash Nov 08 '12 at 11:40
  • 1
    I don't thing this is going to be possible. For one, you're definitely not going to get the whole website in using a screenshot. I would suggest using server-side scripting to convert the website into an image. – Nico Nov 23 '12 at 11:42
  • ya you are right ... i tried lot... – prakash Nov 23 '12 at 13:36

0 Answers0