无法在 J2ME Polish 中使用相机捕获图片?

发布于 2024-12-16 11:18:53 字数 2344 浏览 2 评论 0原文

我正在 J2ME 中开发移动应用程序。现在我将其转换为 J2ME Polish。在我的应用程序中,我使用手机中的相机拍摄照片。它在 J2ME 中运行良好。但它在 J2ME Polish 中不能正常工作。我无法解决它。

下面给出的代码片段

import javax.microedition.lcdui.Canvas;
import javax.microedition.media.control.VideoControl;
//...

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);
    }

}

在正常的 j2me 中,上面的代码可以正常工作。但是在j2me中,videoControl.initDisplayMode(VideoControl.USE_DIRECT_VIDEO,this)这里this指的是VideoCanvas(它扩展自javax.microedition.lcdui.Canvas)。但它会抛出一个“IllegalArgumentException - 容器应该是画布”,就像这样。如何解决问题?

I am developing a Mobile Application in J2ME. Now I am converting it into J2ME Polish. In my application, 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

import javax.microedition.lcdui.Canvas;
import javax.microedition.media.control.VideoControl;
//...

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

糖果控 2024-12-23 11:18:53

J2ME 和 J2ME 中的 Display 类是不同的。 J2ME 波兰语。我相信您收到此错误只是因为 Display 类。

将您的 Display 类更改为 Polish 的库 &你的问题将会得到解决。

The Display class is different in J2ME & J2ME Polish. I believe you are getting this error because of Display class only.

Change your Display class to Polish's library & your problem will be solved.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文