存储大图我甲肝书面这是继代码...如何通过J2ME
package hello;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import java.io.*;
public class Immutable extends MIDlet implements CommandListener {
private Display display;
private Form form;
private Command exit;
private Image image;
private ImageItem imageItem;
public Immutable() throws IOException
{
display = Display.getDisplay(this);
exit = new Command("Exit", Command.EXIT, 1);
form = new Form("Immutable Image Example");
form.addCommand(exit);
form.setCommandListener(this);
try
{
image = Image.createImage("/hello/minion.png");
imageItem = new ImageItem("This is the IMAGE_ITEM Application",
image,ImageItem.LAYOUT_NEWLINE_BEFORE |ImageItem.LAYOUT_LEFT |
ImageItem.LAYOUT_NEWLINE_AFTER, "My Image");
form.append(imageItem);
}
catch (java.io.IOException error)
{
Alert alert = new Alert("Error", "Cannot load minion.png.",null, null);
alert.setTimeout(Alert.FOREVER);
alert.setType(AlertType.ERROR);
display.setCurrent(alert);
}
}
public void startApp()
{
display.setCurrent(form);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
public void commandAction(Command command, Displayable Displayable)
{
if (command == exit)
{
destroyApp(false);
notifyDestroyed();
}
}
}
现在这个形象命名minion.png为32KB,像素尺寸为803x825的。在这种情况下,图像没有完全加载。我已经在仿真器上尝试过,也在诺基亚3110上试过。它给出的错误是“内存不足”。
同样的事情与另一个大小6kb和像素96x96的图像很好地运行。
请提出一些想法来存储一个大的图像。 thnx提前...
我的移动设备有256mb的毫米卡,但仍显示相同的错误。实际上我想做一个城市导航项目,因为一个大的图像是一个需求。 PLZ帮助我。 – user651109 2011-03-09 15:06:14
256MB是你在存储方面,但是miage正在加载到内存中,这绝对是很少的 – 2011-03-09 15:56:41
所以没有任何方式来显示50kb大小的图像?甚至模拟器不是加载整个图像,只是边界。 – user651109 2011-03-09 16:11:19