Hi,
I am using the below code for zooming the images.but its taking lot of time.Is threre any other Optimised code for this?
If yes tell me how?
Code i am using................
private Image createThumbnail(Image image,int w)
{
int sourceWidth = image.getWidth();
int sourceHeight = image.getHeight();
int thumbWidth = w;
int thumbHeight = -1;
if (thumbHeight == -1)
thumbHeight = thumbWidth * sourceHeight / sourceWidth;
Image thumb = Image.createImage(thumbWidth, thumbHeight);
Graphics g = thumb.getGraphics();
for (int y = 0; y < thumbHeight && y<screen_height; y++)
{
for (int x = 0; x < thumbWidth && x<screen_width; x++)
{
g.setClip(x, y, 1, 1);
int dx = x * sourceWidth / thumbWidth;
int dy = y * sourceHeight / thumbHeight;
g.drawImage(image, x - dx, y - dy, Graphics.LEFT | Graphics.TOP);
}
}
Image immutableThumb = Image.createImage(thumb);
return immutableThumb;
}
This code is working well but taking a lot of time with increasing the Image size.
if i try to use the code with Image.getRGB then i am getting out of memory Exception at creation of 2-dimensional integer array.
i.e..,
int rgb[][]= temp.getRGB(rgb,0,temp.getWidth(),0,0,temp.getWidth(),temp.getHeight());
can u suggest me the better solution for this?
