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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Highlighted
Developer
Posts: 187
Registered: ‎08-13-2008
My Device: Not Specified
Accepted Solution

convert screen capturing data to byte array?

Hi,

 

I am capturing the screen shot of the device screen as a bitmap data. Can i convert it to byte array?

 

Please help me out through this.

 

 

Thanks in advance

 

 

 

 

 

Developer
Posts: 17,026
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: convert screen capturing data to byte array?

bitmap.getARGB is used to copy the ARGB data into an bytearray.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 187
Registered: ‎08-13-2008
My Device: Not Specified

Re: convert screen capturing data to byte array?

Hi Simon,

 

Thanks for your immediate reply.

 

I am also trying this way to save the image as .bmp in device memory. i can able to save it, But i am not able to view this screen.bmp.

 

what is mistake i have done in this code. please help me out through this.

 

 

                  DataBuffer db = new DataBuffer();

String url = "file:///store/home/user/screenCapture/screen.bmp";
                    db.setBigEndian(true);
                                       
                    width = Display.getWidth();
                    height = Display.getHeight();
                   
                    Bitmap image = new Bitmap(width, height);
                    Display.screenshot(image, 0, 0, width, height);                   
                   
                    int[] rgbdata = new int[width*height];
                    image.getARGB(rgbdata, 0, width, 0, 0, width, height);       
                                      
                    for (int i = 0; i < (width*height); i++)                  
                    {
                        db.writeInt(rgbdata[i]);
                        //db.writeByte(rgbdata[i]);                       
                    }
                   
                   // db.rewind();

          ba = db.getArray();
               
                    try{
                        fconn = (FileConnection)Connector.open(url , Connector.READ_WRITE); 
                      
                        if(!fconn.exists()) {
                            fconn.create();
                            //fconn.mkdir();                       
                        }             
                        o = fconn.openOutputStream();                      
                        o.write(ba);
                    }
                    catch(Exception ee){
                        System.out.println("Exception in FileConnection : " + ee);
                    }
                    finally {
                        try {                              
                            o.close();
                            fconn.close();
                        }
                        catch(Exception e){
                            System.out.println("Could not close File Connection : " + e);
                        }
                    } 

 

 

Thanks in advance

Developer
Posts: 17,026
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: convert screen capturing data to byte array?

in my knowledge base i found a link to a similar question:
http://supportforums.blackberry.com/rim/board/message?board.id=java_dev&thread.id=736

i didn't try the forums search - did you? Smiley Wink
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter