We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › System.arraycopy on Image problem
Page Index Toggle Pages: 1
System.arraycopy on Image problem (Read 480 times)
System.arraycopy on Image problem
Mar 17th, 2006, 1:57pm
 
Hi there! We've a little problem with system.arraycopy. We're trying to copy pixels to an image, here's the code:

Code:

loadPixels();
System.arraycopy(pixels,0,control.Estats[control.EstatActual].fons.pixels,0,control.Estats[control.EstatActual].fons.pixels.length);

This works, but just one time. The problem is that the second time we try to do this, it doesn't copy the pixels, and we had to do:

Code:

control.Estats[control.EstatActual].fons = null;
control.Estats[control.EstatActual].fons = new PImage(width,height);
loadPixels();
System.arraycopy(pixels,0,control.Estats[control.EstatActual].fons.pixels,0,control.Estats[control.EstatActual].fons.pixels.length);


This works, but since we've a lot of images, this takes too much memory, and we need to optimize as much as posible.

Any idea why do we need to do a new image everytime We must do a arraycopy?

Thanks!
Re: System.arraycopy on Image problem
Reply #1 - Mar 17th, 2006, 3:11pm
 
call updatePixels() before drawing the image after changes.
Re: System.arraycopy on Image problem
Reply #2 - Mar 21st, 2006, 12:04am
 
Hi fry. Problem is not here, as this is something we already tried. Problem keeps beeing the same, image doesn't copy the pixels.

The problem is taht if we do:
imagevar = null;
imagevar = new PImage();

there's a memory increment of 7 or 8 mb, and we don't really know how to free that memory so memory keeps stable... but the image copy.

So it's like we do an extreme overload of memory, or we can't copy the images... any idea of our problem?

Thanks!
Page Index Toggle Pages: 1