This code is use for displaying an image in a Thumbnail format. And i got a problem (Out of Memory) when an image contain a dimension of 1600 x 1200 up. I'm using Series 40 and Series 60 J2ME Phones.
Kindly help me of my problem, Thanks.
Here is My code:
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;