Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
Posts: 117
Registered: ‎02-12-2009
My Device: Not Specified
Accepted Solution

Context menu coming in screenshot by using Display.Screenshot

Hi All,

 

I have a Menu Item. On click of that i am taking screenshot, but i am getting the context menu also in screenshot. I want to get only the screenshot for the screen behind context menu.

 

Any pointers for this?

 

Thanks in advance,

Sandeep

Developer
Posts: 3,951
Registered: ‎07-15-2008
My Device: Not Specified

Re: Context menu coming in screenshot by using Display.Screenshot

If it is on Video Play then you can use getSnapshot. If it is other option, suggestion is to provide that functionality on particular key(Example Space etc..) so the user press that key and perform the screenshot.

Use Search. "Accept Solution" If the problem is resolved.
Developer
Posts: 19,624
Registered: ‎07-14-2008
My Device: Not Specified

Re: Context menu coming in screenshot by using Display.Screenshot

Agree 100% with BBDeveloper. 

 

However, if you really want to use a Menu, then you are going to have to wait till after the menu has been replaced before taking the snapshot.  You could try (and I'm not saying this would work, I have not tested it) setting a flag in the menu item, and then overriding onExposed() to test the flag and take the snapshot.  This assumes that onExposed is called after the screen repaint to replace the menu.

 

Just a thought, might work, but I would go with BBDeveloper's suggestion if you can.

Developer
Posts: 117
Registered: ‎02-12-2009
My Device: Not Specified

Re: Context menu coming in screenshot by using Display.Screenshot

Thanks for you replies,

 

I tried to have timer option also to wait for some time before taking screenshot didnt work. 

 

Then i tried following option, it worked. I added a repaint call before taking a screenshot. Is this a right method to do it?

 

 

// Added this line before taking screenshot

UiApplication.getUiApplication().repaint(); Display.screenshot(bitmap,0,0,Display.getWidth(),Display.getHeight());

 

I will also explore the options mentioned by you.

 

Thanks,

Sandeep

 

New Developer
Posts: 14
Registered: ‎03-10-2009
My Device: Not Specified

Re: Context menu coming in screenshot by using Display.Screenshot

Hi,

 I also developed one small application in which i want to take the screen shot of the current screen. But, i am not getting anything. 

 Which method we have to follow

can we go for a raw image

   b1 = new Bitmap(360, 480);

or can we go for a image from our file system with the dimensions equal to the blackberry simulator dimensions

   b1 = Bitmap.getBitmapResource("myimg.png");

I am using the following method to take the screenshot.

Display.screenshot(b1);

and iam using the following to convert it into bytes

int[] argb = new int[b1.getWidth() * b1.getHeight()];
b1.getARGB(argb, 0, b1.getWidth(), 0, 0, b1.getWidth(), b1.getHeight());
// Returns a byte array containing the encoded data for this EncodedImage
byte[] array = integersToBytes(argb);

and using the FileConnection to save the image.

But iam not getting anything in the specified images folder which iam writing using FileConnection.

Please tell me what went wrong with this.

Developer
Posts: 117
Registered: ‎02-12-2009
My Device: Not Specified

Re: Context menu coming in screenshot by using Display.Screenshot

Hi,

 

Are you getting any exception, try debugging you will be able to find out the step at which program fails. Display.screenshot works fine, returns bitmap variable, and we should be able to save that to file. And there might be issue with encoding also. Search PNGEncoder, you will get some info on forum.

 

Thanks,

Sandeep

Developer
Posts: 177
Registered: ‎01-21-2009
My Device: 9900
My Carrier: Vodafone

Re: Context menu coming in screenshot by using Display.Screenshot

Wrap Display.snapshot in an invokeLater
Regular Contributor
Posts: 51
Registered: ‎01-13-2011
My Device: 9800
My Carrier: vodaphone

Re: Context menu coming in screenshot by using Display.Screenshot

Hi sandeep 

Its good solution ..

Thanx

Vishal Lakhmapurkar
New Contributor
Posts: 5
Registered: ‎09-07-2011
My Device: Blackberry Bold 9700
My Carrier: Telekom

Re: Context menu coming in screenshot by using Display.Screenshot

I am getting the context menu only in os version 6 and 7, in os 5 i am getting only the screenshot for the screen behind the context menu