Java me 如何在J2ME中使用快照减少要显示的图像的尺寸(1600x1200到640x480或小于该尺寸)

Java me 如何在J2ME中使用快照减少要显示的图像的尺寸(1600x1200到640x480或小于该尺寸),java-me,j2mepolish,Java Me,J2mepolish,此代码用于以缩略图格式显示图像。 我遇到了一个问题(内存不足),当一个图像包含1600 x 1200以上的维度时。 我使用的是40系列和60系列J2ME手机 请帮我解决我的问题,谢谢。 这是我的密码: int sourceWidth = image.getWidth(); int sourceHeight = image.getHeight(); int thumbWidth = width; int thumbHeight = height; if

此代码用于以缩略图格式显示图像。 我遇到了一个问题(内存不足),当一个图像包含1600 x 1200以上的维度时。 我使用的是40系列和60系列J2ME手机

请帮我解决我的问题,谢谢。 这是我的密码:

    int sourceWidth = image.getWidth();
    int sourceHeight = image.getHeight();

    int thumbWidth = width;
    int thumbHeight = height;

    if (thumbHeight == -1)
        thumbHeight = thumbWidth * sourceHeight / sourceWidth;

    Image thumb = Image.createImage(thumbWidth, thumbHeight);
    Graphics graph = thumb.getGraphics();

    for (int y = 0; y < thumbHeight; y++) {
        for (int x = 0; x < thumbWidth; x++) {
            graph.setClip(x, y, 1, 1);
            int dx = x * sourceWidth / thumbWidth;
            int dy = y * sourceHeight / thumbHeight;
            graph.drawImage(image, x - dx, y - dy, Graphics.TOP | Graphics.LEFT);
        }
    }

    Image immutableThumb = Image.createImage(thumb);

    return immutableThumb;
int sourceWidth=image.getWidth();
int sourceHeight=image.getHeight();
int thumbWidth=宽度;
int thumbHeight=高度;
如果(拇指高度==-1)
thumbHeight=thumbWidth*sourceHeight/sourceWidth;
Image thumb=Image.createImage(拇指宽度、拇指高度);
Graphics graph=thumb.getGraphics();
对于(int y=0;y
能否避免一次加载整个图像

能否将图像拆分为四个800x600图像,并创建四个320x240迷你缩略图,以便彼此相邻显示

如果4仍然不起作用,试试16


只要准备好调用Image.createImage()即可触发垃圾收集暂停。

许多相机在图片的exif数据中保存缩略图,这样相机就可以快速显示缩略图,而无需缩小全尺寸图像

从理论上讲,这种技术在JavaME中也是可行的,如果您在google上搜索它,您可以找到许多关于如何使用它的指南:

不过我必须承认,我以前试过的时候从来没有成功过,我想那是在索尼爱立信的爱诺上。 一个问题是(和往常一样,几乎不管你看什么话题),不同的公司采用不同的方式。这自然使得实现通用的“无处不在的代码”变得相当困难