Hey guys,
i am using an
applet to display images (i would of placed this question under applet, but it is memory consumption)
So the issue is that i have this image, which is stored inside an Image instance. When i am trying to render on a canvas, the memory consumption would double, and then, i end up having two different instances of the pixels of the image (saw that using a memory profiler - one of them is img.source.pixels, the other is img.imagerep.biRaster.data). This is critical since some images come in 20MB pixel size, so now i am ending up with 40MB per image (double size)
the code i am using to draw the image is using double buffering relying on an Graphics object (offg) which references the image through the
offg = offImage.getGraphics();
and then drawing using the drawImage to draw the image instance (parent.imageDataArray[imgNo].getCurrentImage())
offg.drawImage(parent.imageDataArray[imgNo].getCurrentImage(),
(int) x[imgNo],
(int) y[imgNo],
(int) w[imgNo],
(int) h[imgNo],
this);
Even without double buffering, i still get the double memory consumption. Is the drawImage making another copy of the image in memory, causing therefore the duplication of memory usage. And is there a way to draw the image while avoiding this?
Thanks a lot guys
Best,
Mohammad