java-me - 修复启动画面图像以在 j2me 中显示

标签 java-me nokia midp lcdui jsr75

在我的 j2me 应用程序中,我尝试了 Canvas ,它在诺基亚手机上运行良好,但不能在三星上运行。为此,我必须切换到某种表格,在这两种情况下都有效,但唯一的问题是大小,如果我创建较小的图像以适合两个手机屏幕,一个(三星)显示可以,但其他(诺基亚)留下更多空间反之亦然。

我需要有可以拉伸(stretch)图像的代码,并且只需将其修复为我基本上通过 form.getHeight()form.getWidth() 获得的屏幕尺寸> 属性(property)。我想知道是否有 Image.createImage(width, height) 属性那么为什么它不将其拉伸(stretch)到我提供的值?

我的代码如下

try {
        System.out.println("Height: " + displayForm.getHeight());
        System.out.println("Width: " + displayForm.getWidth());
        Image img1 = Image.createImage("/bur/splashScreen1.PNG");
        img1.createImage(displayForm.getHeight(), displayForm.getWidth()); 
        displayForm.append(new ImageItem(null, img1, Item.LAYOUT_CENTER, null));
    } catch (Exception ex) {
    }

图片enter image description here

最佳答案

单个图像无法适合所有屏幕。但更多就可以了。
较小的 Logo 图像应小于 96x54,因为这是最小的屏幕分辨率。该图像的分辨率可达 128x128,没有任何问题。不过,分辨率越高,它看起来就越小。
较大的 Logo 图像应比 128x128 稍大,并且最大可使用 240x320。 下面的代码给出了如何实现这一点的示例。

import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.Graphics;

class Splash extends javax.microedition.lcdui.Canvas {

  Image logo;

  Splash () {
    if (getWidth() <= 128) {
      // sl stands for Small Logo and does not need to have a file extension
      // this will use less space on the jar file
      logo = Image.createImage("/sl");
    } else {
      // bl stands for Big Logo
      logo = Image.createImage("/bl");
    }
  }

  protected void paint (Graphics g) {
    // With these anchors your logo image will be drawn on the center of the screen.
    g.drawImage(logo, getWidth()/2, getHeight()/2, Graphics.HCENTER | Graphics.VCENTER);
  }
}

http://smallandadaptive.blogspot.com.br/2008/10/showing-splash.html中所示

关于java-me - 修复启动画面图像以在 j2me 中显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13696843/

相关文章:

java-me - 您必须在类路径运行时异常中的 LWUIT 之前包含平台端口

java - J2ME RecordStore 中的数据不会跨 session 持续存在

java - 什么在 MIDP 编程中相当于 swing-application 的 JButton?

blackberry - 在将 LWUIT 与 Blackberry 一起使用时,在 TextField 上设置最大大小时会出现此错误吗?

java - 诺基亚错误代码 217 - jar list 行尾

java-me - 向 j2me 应用程序添加图标

java-me - 我们可以在j2me中的Canvas上垂直绘制文本吗

youtube - RTSP流无法在诺基亚40系列手机中使用

python S60应用接入

java - j2me 短信接收在模拟器中工作但在诺基亚 n91 中不起作用?