我想在黑莓设备上使用 J2ME MIDlet 类显示 PNG 图像

发布于 2024-12-24 23:00:07 字数 129 浏览 1 评论 0原文

我正在尝试使用 J2ME MIDlet 类而不是黑莓 RIMlet 类在 OS 5.0 的黑莓设备上显示 PNG 图像。我可以使用 J2ME MIDlet 代替 RIMlet 吗?由于黑莓支持 J2ME,它是否与黑莓兼容?我可以从中获取图像吗?

I am trying to display a PNG image on blackberry device for OS 5.0 using J2ME MIDlet class instead of a blackberry RIMlet class. Can I use J2ME MIDlet instead of RIMlets? Would it be compatible with blackberry as blackberry do support J2ME? Can I get the image from it?

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

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

发布评论

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

评论(4

拿命拼未来 2024-12-31 23:00:07

要在 BlackBerry® 设备的屏幕上显示图像,请创建一个 Image 对象并通过调用 static Image.createImage() 方法填充它。提供图像的位置作为参数。

请参阅在黑莓设备上使用 J2ME MIDlet 类显示 PNG 图像

To display an image on the screen of a BlackBerry® device, create an Image object and populate it by calling the static Image.createImage() method. Provide the location of the image as a parameter.

refer display an PNG image using J2ME MIDlet classes on blackberry device

生来就爱笑 2024-12-31 23:00:07

我可以使用 J2ME MIDlet 代替 RIMlet...

,但是有一些优点,如前面提到的 此处。

如果您想使用 MIDlet,这里是一个使用的示例图像项目,

import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;

public class ImageItemMIDlet extends MIDlet implements CommandListener{
  private Command exit;
  private ImageItem imageItem;
  private Image image;
  private Display display;
  private Form form;

  public ImageItemMIDlet(){
  try{
  image = Image.createImage("/yourImage.png");
  } catch (Exception e){ }
  imageItem = new ImageItem("This is the IMAGE_ITEM Application", 
  image, ImageItem.LAYOUT_DEFAULT, "image");
  }

  public void startApp(){
  form = new Form("ImageItem Example");
  display = Display.getDisplay(this);
  exit = new Command("Exit", Command.EXIT, 1);
  form.append(imageItem);
  form.addCommand(exit);
  form.setCommandListener(this);
  display.setCurrent(form);
  }

  public void pauseApp(){}

  public void destroyApp(boolean unconditional){
  notifyDestroyed();
  }

  public void commandAction(Command c, Displayable d){
  String label = c.getLabel();
  if(label.equals("Exit")){
  destroyApp(true);
  }
  }
} 

Can i use J2ME MIDlet instead of RIMlets...

YES, but there are certain advantages like mentioned here.

and if you want to go with MIDlet, here is an example using ImageItem,

import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;

public class ImageItemMIDlet extends MIDlet implements CommandListener{
  private Command exit;
  private ImageItem imageItem;
  private Image image;
  private Display display;
  private Form form;

  public ImageItemMIDlet(){
  try{
  image = Image.createImage("/yourImage.png");
  } catch (Exception e){ }
  imageItem = new ImageItem("This is the IMAGE_ITEM Application", 
  image, ImageItem.LAYOUT_DEFAULT, "image");
  }

  public void startApp(){
  form = new Form("ImageItem Example");
  display = Display.getDisplay(this);
  exit = new Command("Exit", Command.EXIT, 1);
  form.append(imageItem);
  form.addCommand(exit);
  form.setCommandListener(this);
  display.setCurrent(form);
  }

  public void pauseApp(){}

  public void destroyApp(boolean unconditional){
  notifyDestroyed();
  }

  public void commandAction(Command c, Displayable d){
  String label = c.getLabel();
  if(label.equals("Exit")){
  destroyApp(true);
  }
  }
} 
清醇 2024-12-31 23:00:07

public class Midlet 扩展 MIDlet {

public Display display;

public void startApp() {

    Canvas obj = new DrawImage();

    display = Display.getDisplay(this);
    display.setCurrent(obj);

}

public void pauseApp() {
}

public void destroyApp(boolean unconditional) {
}


public class DrawImage extends Canvas{

    int width = getWidth();
    int height = getHeight();

    protected void paint(Graphics g) {
        try {

            System.out.println("111111");
            Image image = Image.createImage("/Waterfall.png");
            if(image != null)
                g.drawImage(image, 0, 0, Graphics.TOP | Graphics.LEFT);
            else
                System.out.println("2222");
        } catch (IOException ex) {
            System.out.println(ex);
        }   
    }  
}   

}

public class Midlet extends MIDlet {

public Display display;

public void startApp() {

    Canvas obj = new DrawImage();

    display = Display.getDisplay(this);
    display.setCurrent(obj);

}

public void pauseApp() {
}

public void destroyApp(boolean unconditional) {
}


public class DrawImage extends Canvas{

    int width = getWidth();
    int height = getHeight();

    protected void paint(Graphics g) {
        try {

            System.out.println("111111");
            Image image = Image.createImage("/Waterfall.png");
            if(image != null)
                g.drawImage(image, 0, 0, Graphics.TOP | Graphics.LEFT);
            else
                System.out.println("2222");
        } catch (IOException ex) {
            System.out.println(ex);
        }   
    }  
}   

}

陈年往事 2024-12-31 23:00:07

最好将 Midlet 与画布一起使用来在画布上显示,因为如果您将 Midlet 与 Form 一起使用,那么它会显示图像,但它也会在表单背景中显示移动主题。如果您使用画布,您还可以使用背景图像作为正面图像。
谢谢

Its good to use Midlet with canvas to show on canvas because if you use Midlet with Form then its show image but its also showing the theme of mobile in background of form. If you use canvas you can use also background image for your front image.
Thanks

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