12-10-2010 05:48 AM
I have and requirement to capture the blackberry screenshot. I can do it using the class net.rim.device.api.system.Display as follows:
Bitmap screenBitmap=new Bitmap(Display.getWidth(),Display.getHeight()); Display.screenshot(screenBitmap);
But in case of touch screen devices when the on-screen keyboard is visible the above code only takes the screen shot of the screen above the on-screen keyboard and fails to take the screen shot of the on-screen keyboard.
So I am requesting your valuable feedback on how I can get screen shot of the full screen, including the on-screen keyboard when it is visible.
Thanks and Regards
Solved! Go to Solution.
12-10-2010 05:54 AM - edited 12-10-2010 06:01 AM
I think when the on-screen keyboard is visible
Display.getHeight() will return actual height - height of virtual keyboard.
so for that don't evaluate Display.getHeight() every time.
Edit: i have tested on storm
when on- screen keyboard is not there height is 480
and when on- screen keyboard is there height is 248
12-10-2010 06:07 AM
You can store the value of Display.getHeight() in a static variable before getting the keyboard on the screen. i.e.
static int temp=Display.getHeight();
after that initialize the Bitmap with,
Bitmap screenBitmap=new Bitmap(Display.getWidth(),temp);
12-15-2010 07:31 AM
Based on your suggestion I changed the code so that height is retrieved only once when the on-screen keyboard is not visible, as mentioned by Vivart, the height is 480 in this case.
Now when the on-screen keyboard is visible if I pass the following code:
Bitmap screenBitmap=new Bitmap(Display.getWidth(),orginalHeight); Display.screenshot(screenBitmap);
the second line is throwing IllegalArgumentException. Here the originalHeight=480 which was retrieved when the on-screen keyboard was not visible.
The second line is only executing when I give Display.getHeight() while creating the Bitmap object but with this the on-screen keyboard is not captured as screen shot.
Need your valuable help and feedback on this.
12-15-2010 07:40 AM
try this code
Bitmap screenBitmap=new Bitmap(Display.getWidth(),orginalHeight); Display.screenshot(screenBitmap,0,0,Display.getWid