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

Posts: 133
Registered: ‎07-20-2009
My Device: Not Specified

Problem of Screen shot and save as png file

Dear all,


I want to make a function to take a screen shot and save as png file in sd card. I have write some code is work on the simulator. But in the device only can save a whole white color image. anyone can help?


  public void screenShot(){

    int width = Display.getWidth();

    int height = Display.getHeight();



      .currentScoreScreen = new Bitmap(width, height);

      Display.screenshot(currentScoreScreen, 0, 0, width, height);


    }catch(Exception e){

      System.out.println("inter capture error: " + e.getMessage());





  public void highestScreenShotStore(){ 

    int width = Display.getWidth();

    int height = Display.getHeight();


      FileConnection fconn = (FileConnection) Connector.open("file:///" + directory + name + ".png");


      if (!fconn.exists()){




      PNGEncodedImage fullImage = PNGEncodedImage.encode(currentScoreScreen);


      OutputStream os = fconn.openOutputStream();





    }catch (Exception e) {

      System.out.println("Output file error: " + e.getMessage());




BlackBerry Development Advisor
Posts: 15,753
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Problem of Screen shot and save as png file

What BlackBerry Smartphone model and BlackBerry handheld software version are you testing on?  You can find this under Options, About on the BlackBerry Smartphone.  Is any exception thrown within your code?
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker