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
nikita18
Posts: 144
Registered: ‎08-18-2012
My Device: Blackberry Curve 8520
My Carrier: Vodafone
Accepted Solution

Convert Screenshot in Bitmap to Image file?

I am using below code to take screenshot of Blackberry.

 

public static Bitmap getScreenShot() {
Bitmap bitmap;
bitmap = new Bitmap(Display.getWidth(), Display.getHeight());
Display.screenshot(bitmap);
try {
FileConnection file = (FileConnection)Connector.open("file:///store/home/user/img.bmp");
if(!file.exists()){
file.create();
}
DataOutputStream out = file.openDataOutputStream();
out.write(getBytesFromBitmap());    //returns bytes from the bitmap object
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return bmp;
}

 

I want to convert this Bitmap object to a file of any file format: .bmp/.png/.jpg etc. Is there any way I can achieve this? 

Please help.

Thanks.

 

Please use plain text.
Developer
nikita18
Posts: 144
Registered: ‎08-18-2012
My Device: Blackberry Curve 8520
My Carrier: Vodafone

Re: Convert Screenshot in Bitmap to Image file?

solved this..i was not closing my outputstream.. :smileyhappy:

Please use plain text.