i am create a blackberry camera Application in this App i am use automatic image capturing feature according to my requirement.but one more thing i will try here but till now i am not get success.i try second thing is when camera is running it not show whatever he captureing on the screen but capture that particular thing.And i got success not able to show it on the screen but after that when i check my picture it not draw only 0 kb .jpeg file is create.I try to hide camera using background image but not effective.Means when camera is running i want to cover my screen with other image no can understand my camera is on but capture image. i am going through this code.
public class ImageCaptureDemo extends UiApplication
{
public static void main(String[] args)
{
ImageCaptureDemo app = new ImageCaptureDemo();
app.enterEventDispatcher();
}
public ImageCaptureDemo()
{
pushScreen(new ImageCaptureDemoScreen());
}
class ImageCaptureDemoScreen extends MainScreen
{
Timer timer ;
Player _p;
VideoControl _videoControl;
Bitmap back_ground=Bitmap.getBitmapResource("loadingImage.png");
Field videoField=null;
public ImageCaptureDemoScreen()
{
super();
setTitle("Main Screen BackGround");
try
{
_p = javax.microedition.media.Manager.createPlayer("capture://video?encoding=jpeg&width=240&height=160");
_p.realize();
_p.prefetch();
_videoControl = (VideoControl) _p.getControl("VideoControl");
if (_videoControl != null)
{
videoField = (Field) _videoControl.initDisplayMode (VideoControl.USE_GUI_PRIMITIVE, "net.rim.device.api.ui.Field");
HorizontalFieldManager H=new HorizontalFieldManager()
{
public void paint(Graphics graphics) {
//Draw the background image and then call paint.
graphics.clear();
graphics.drawBitmap(0, 0,480, 240, back_ground, 0, 0);
super.paint(graphics);
}
protected void sublayout( int maxWidth, int maxHeight)
{
int width = 240;//240
int height = 180;//180
super.sublayout( width, height);
setExtent( width, height);
}
};
if(videoField != null)
{
H.add(this.videoField);
add(H);
System.out.println("VideoField===="+videoField);
}
_p.start();
System.out.println("VideoField"+videoField);
}
}
catch(Exception e)
{
Dialog.alert(e.toString());
}
timer = new Timer();
timer.schedule(new CountDown(), 2000);
}
public class CountDown extends TimerTask {
public void run() {
DismissThread dThread = new DismissThread();
}
}
public void dismiss() {
timer.cancel();
invokeAction(ACTION_INVOKE);
_videoControl.setVisible(false);
}
public class DismissThread implements Runnable {
public void run() {
dismiss();
}
}
protected boolean invokeAction(int action)
{
boolean handled = super.invokeAction(action);
if(!handled)
{
if(action == ACTION_INVOKE)
{
try
{
String encoding1 = "encoding=jpeg&width=640&height=480&quality=normal";
byte[] rawImage = _videoControl.getSnapshot(encoding1);
System.out.println("byte[]=="+rawImage);
FileConnection conn = (FileConnection)Connector.open("file:///SDCard/BlackBerry/pictures/"+System.currentTimeMillis()+".jpeg", Connector.READ_WRITE);
conn.create();
OutputStream out = conn.openOutputStream();
out.write(rawImage);
out.flush();
out.close();
conn.close();
}
catch(Exception e)
{
_p.close();
Dialog.alert(e.toString());
}
}
}
return handled;
}
}
}
please help me it necessary for my project. Thanks in Advance