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: 49
Registered: ‎03-06-2009
My Device: Not Specified
Accepted Solution

How to convert rgb565 byte[] data to EncodedImage or bitmap

Hi all I am playing an video and I want to get snapshot of video as

 

byte [] byteArr = videoControl.getSnapshot("encoding=rgb565");

 

I try to get Bitmap as

 

image = EncodedImage.createEncodedImage(byteArr, 0, byteArr.length);

bitmap = image.getBitmap();

                     

but It throws an Exception as IllegalArgumentException.

I get an array of double length that of screenWidth*ScreenHeight, may be because of rgb565

 

How can I convert byte[] to Bitmap. 

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

Re: How to convert rgb565 byte[] data to EncodedImage or bitmap

Did you try something like this...

 

Bitmap bitmap = Bitmap.createBitmapFromBytes( raw, 0, raw.length, 7);


Use Search. "Accept Solution" If the problem is resolved.
Developer
Posts: 49
Registered: ‎03-06-2009
My Device: Not Specified

Re: How to convert rgb565 byte[] data to EncodedImage or bitmap

I try your suggession change scale from 1 to 7 but throw me same exception.
Developer
Posts: 3,951
Registered: ‎07-15-2008
My Device: Not Specified

Re: How to convert rgb565 byte[] data to EncodedImage or bitmap

ok, lets wait for Experts and RIM Development advisor to find is it possible to take the snapshot while video is playing.

Use Search. "Accept Solution" If the problem is resolved.
Developer
Posts: 49
Registered: ‎03-06-2009
My Device: Not Specified

Re: How to convert rgb565 byte[] data to EncodedImage or bitmap

I solve the problem of getting bitmap by constructing like

 

bitmap = new Bitmap(Bitmap.ROWWISE_16BIT_COLOR,Graphics.getScreenWidth(),Graphics.getScreenHeight(),byteArr);

 

Highlighted
New Developer
Posts: 15
Registered: ‎08-29-2009
My Device: Not Specified

Re: How to convert rgb565 byte[] data to EncodedImage or bitmap

I tried using 

Bitmap bitmap = new Bitmap(Bitmap.ROWWISE_16BIT_COLOR,videoControl.getDisplayWidth(),videoControl.getDisplayHeight(),snapShotBA);

 

But the problem it only works if the videoControl.setDisplayWidth(w,h) is called where h is equal to any value, and w is equal to the full canvas width, if it is less even by one pixel, I get the following exception:

 

java.lang.IllegalArgumentException: Invalid bitmap size.

 

Any ideas?

 

Regards