• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Drawing Image Doubles Memory Consumption

 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are the images files static which you are loading from the File System ? If yes please try

Image image;
public void init() {
// Load image
image = getImage(getDocumentBase(), "image.gif");
}
public void paint(Graphics g) {
// Draw image
} g.drawImage(image, 0, 0, this);
[ February 15, 2007: Message edited by: Harjit Singh ]
 
Can you shoot lasers out of your eyes? Don't look at this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic