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: 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: 16,986
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

Highlighted
Developer
Posts: 16,986
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