10-07-2011 08:36 AM
I am working with blackberry os 4.2.I am taking a snapshot using a video player in my app and showing a preview of the image in my screen.But unfortunately, the image is shown fine on the simulator(Blackberry Tour 9630) but on the phone that screen is never displayed.I attach the code below:
This is how i initialize the camera:
private byte initializeCamera()
player = Manager.createPlayer( "capture://video?encoding=jpeg&width="+width+"&height="+height+"&quality=normal");
//width and height are retrieved from the encoding.Anything <=640x480 is selected.
_videoControl = (VideoControl)player.getControl( "VideoControl");
if (_videoControl != null)
// Create the video field as a GUI primitive (as opposed to a// direct video, which can only be used on platforms with LCDUI support.
_videoField = (Field) _videoControl.initDisplayMode (VideoControl.USE_GUI_PRIMITIVE, "net.rim.device.api.ui.Field");
"ERROR 2" + e.getClass() + ": "+ e.getMessage());
And when the user clicks i implement this function:
raw = _videoControl.getSnapshot( null);
// layThisSet();// addComponents();
The createImageScreen function passes the byhte array to another screen class which does the display as follows:
Bitmap bm = Bitmap.createBitmapFromBytes(raw, 0, -1, 1 );
int scalingWidth = (int) Math.ceil((bm.getWidth()*2.0)/(Display.getWidth()*1.0));
int scalingHeight = (int) Math.ceil((bm.getHeight()*5.0)/(Display.getHeight()*2.0));
Bitmap scaledImage = Bitmap.createBitmapFromBytes(raw, 0, -1, scaling );
imageField= new BitmapField( image );
This code works fine and the image is displayed correctly on the simulator but not on the device the execution seems to reach only till the first Bitmap.createBitmapBytes() above.Please help.This is very important for my project.
Solved! Go to Solution.
10-09-2011 03:50 PM
10-11-2011 02:42 PM
Support for capturing a screen shot was added in BlackBerry device software version 4.3.0. It is not supported in 4.2.