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.
Page Index Toggle Pages: 1
Syntax issue (Read 1074 times)
Syntax issue
Apr 28th, 2010, 7:34am
 
Hi all, I'm new to the community and it's been my first year to experiment with Processing.

Im in the middle of a Media Art course, one of the subjects that Im currently investigating is Glitches be it purpously done or random.
I've tried to write a script but it seems to have a problem and I can't figure it out.

Could you help me out here ?



for(int i=0; i<10; 1++)(
 byte b() = LoadBytes("");
 for (int z=1000; z<b,lenght=1000; z=z+int(random(1500)))(
   b[z]=byte(int(random(254)));
   )
   saveBytes("___out_"+i+".jpeg", b);
)
Re: Syntax issue
Reply #1 - Apr 28th, 2010, 8:29am
 
Could it be LoadBytes should loadBytes, case is important Angry
Re: Syntax issue
Reply #2 - Apr 28th, 2010, 9:13am
 
martin_p wrote on Apr 28th, 2010, 8:29am:
Could it be LoadBytes should loadBytes, case is important Angry



Well this is where the file should be inputted, yet nothing happends.
Re: Syntax issue
Reply #3 - Apr 28th, 2010, 9:15am
 
for(int i=0; i<10; 1++)( -> i++

byte b() = LoadBytes("");
Syntax is incorrect. If LoadBytes is supposed to return an array of bytes, it should be:
byte[] b = LoadBytes("");

The ,lenght=1000 part in the for loop is suspicious too: remove it, it isn't used anyway.
Re: Syntax issue
Reply #4 - Apr 28th, 2010, 9:19am
 
Beside, if you randomly change bytes in a .jpg file, you will only get a corrupted file (which cannot be opened by any image viewer), not a file with altered pixels (don't forget data is compressed, and you must not touch metadata).

You have to load the image, randomize pixels in it, and save as image.
Re: Syntax issue
Reply #5 - Apr 28th, 2010, 9:22am
 
PhiLho  wrote on Apr 28th, 2010, 9:15am:
for(int i=0; i<10; 1++)( -> i++

byte b() = LoadBytes("");
Syntax is incorrect. If LoadBytes is supposed to return an array of bytes, it should be:
byte[] b = LoadBytes("");

The ,lenght=1000 part in the for loop is suspicious too: remove it, it isn't used anyway.


Thanks, the lenght was indeed not really used.
Thanks for the correction, yet it still gives me "expecting RPAREN, found 'b'"
Re: Syntax issue
Reply #6 - Apr 28th, 2010, 7:11pm
 
for(int i=0; i<10; i++)(

should be

for(int i=0; i<10; i++){

Actually you're using () instead of {} in quite a few places...
Re: Syntax issue
Reply #7 - Apr 29th, 2010, 2:34am
 
This Topic was moved here from Programs by PhiLho.
Page Index Toggle Pages: 1