unable to capture picture using camera in j2me polish?
- by SIVAKUMAR.J
I'm, developing a mobile app in j2me.Now im converting it into j2me polish.
In my app I capture a picture using camera in mobile phone. It works fine in j2me. But it does not work fine in j2me polish. I cannot resolve it.
The code snippet given below
public class VideoCanvas extends Canvas {
// private VideoMIDlet midlet;
// Form frm
Form frm=null;
public VideoCanvas(VideoControl videoControl) {
int width = getWidth();
int height = getHeight();
// this.midlet = midlet;
//videoControl.initDisplayMode(VideoControl.USE_DIRECT_VIDEO, this);
//Canvas canvas = StyleSheet.currentScreen;
//canvas = MasterCanvas.instance;
videoControl.initDisplayMode( VideoControl.USE_DIRECT_VIDEO,this);
try {
videoControl.setDisplayLocation(2, 2);
videoControl.setDisplaySize(width - 4, height - 4);
} catch (MediaException me) {}
videoControl.setVisible(true);
}
public VideoCanvas(VideoControl videoControl,Form ff) {
frm=ff;
int width = getWidth();
int height = getHeight();
// this.midlet = midlet;
Ticker ticker=new Ticker("B4 video controll init");
frm.setTicker(ticker);
//Canvas canvas = StyleSheet.currentScreen;
videoControl.initDisplayMode(VideoControl.USE_DIRECT_VIDEO,this);
ticker=new Ticker("after video controll init");
frm.setTicker(ticker);
try {
videoControl.setDisplayLocation(2, 2);
videoControl.setDisplaySize(width - 4, height - 4);
} catch (MediaException me) {}
videoControl.setVisible(true);
ticker=new Ticker("Device not supported");
frm.setTicker(ticker);
}
public void paint(Graphics g) {
int width = getWidth();
int height = getHeight();
g.setColor(0x00ff00);
g.drawRect(0, 0, width - 1, height - 1);
g.drawRect(1, 1, width - 3, height - 3);
}
}
In normal j2me the above code works correctly. But in j2me polish videoControl.initDisplayMode(VideoControl.USE_DIRECT_VIDEO,this) here this refers to VideoCanvas (which extends from javax.microedition.lcdui.Canvas). But it throws an "IllegalArgumentException - container should be canvas" like that. How to solve the issue?