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 › problems with pixels
Page Index Toggle Pages: 1
problems with pixels (Read 317 times)
problems with pixels
Jun 28th, 2006, 8:58am
 
Hi there!

Having an issue with changing the pixel value - i'm trying to randomly map a change of pixels from one image to another.
I've managed to get it work once - but can't seem to make it an iterative process.  Any ideas?

PImage myImage;
PImage secondIMG;
int prec;

void setup() {
 size(400, 400);
 myImage = loadImage("atest.jpg");
 secondIMG = loadImage("btest.jpg");
 int prec = 1;
}  

void draw() {
 background(255);
 loadPixels();
 println(prec);
 for(int i=0; i<(200*200); i++) {
   if(int(random(200))<prec) {
     secondIMG.pixels[i] = myImage.pixels[i];
   }
 }
 if (prec>300) {
   prec=1;
 }
 prec++;
 updatePixels();
 image(secondIMG, 0 ,0, 200, 200);
}

Re: problems with pixels
Reply #1 - Jun 28th, 2006, 9:17am
 
You have do update the pixelsArray of your image. If you call updatePixels() you update the pixels of your screen, but to update image pixelsarray you must call secondIMG.updatePixels(). And you dont need do call the loadPixels add the begin of the draw function.
Re: problems with pixels
Reply #2 - Jun 29th, 2006, 2:34am
 
of course - I knew it was something simple!

Thanks eskimoblood!
Cheesy
Page Index Toggle Pages: 1