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 & HelpPrograms › help with PImage <-- noob Q
Page Index Toggle Pages: 1
help with PImage <-- noob Q (Read 1094 times)
help with PImage <-- noob Q
Oct 6th, 2006, 6:12am
 
Hi all,

I just began learning Processing. For starters wanted to write out an image file.

Wrote the following code:

 //Test image creation and output


PImage testImage;
int i;

testImage=createImage(100, 100, RGB);
for(i=0; i=testImage.pixels.length; i++)
{
 img.pixels[i] = color(0,0,0);
}

testImage.save("testMe.jpg");

Here are the errors that got thrown at me:

/tmp/build54599.tmp/Temporary_1449_3681.java:7:11:7:36: Semantic Error: No applicable overload for a method with signature "createImage(int, int, int)" was found in type "java.awt.Component". Perhaps you wanted the overloaded version "java.awt.Image createImage(int $1, int $2);" instead?

/tmp/build54599.tmp/Temporary_1449_3681.java:8:10:8:34: Semantic Error: The type of this expression, "int", is not "boolean".

/tmp/build54599.tmp/Temporary_1449_3681.java:10:3:10:5: Semantic Error: No accessible field named "img" was found in type "Temporary_1449_3681".

/tmp/build54599.tmp/Temporary_1449_3681.java:13:1:14:9: Semantic Error: These statements are unreachable.


I am not quite sure why this would be a problem unless RGB is not defined. Any ideas?

              thank you,
                                      dima
Re: help with PImage <-- noob Q
Reply #1 - Oct 7th, 2006, 7:42pm
 
You need to change this:

Code:
img.pixels[i] = color(0,0,0); 


to this:
Code:
testImage.pixels[i] = color(0,0,0); 


I did this and the applet exported a nice little image, all black, for me.

Cheers,
tk
Re: help with PImage <-- noob Q
Reply #2 - Oct 8th, 2006, 4:32pm
 
First of all thnx for the reply.

Second, sorry for posting brken code. I was cutting and pasting from a couple of places and obvously did something stupid. Got some sleep. fixed both object call and messed up for loop.

...and finally I still get:

/tmp/build49175.tmp/Temporary_1106_7912.java:7:11:7:36: Semantic Error: No applicable overload for a method with signature "createImage(int, int, int)" was found in type "java.awt.Component". Perhaps you wanted the overloaded version "java.awt.Image createImage(int $1, int $2);" instead?

I'm running Processing 115 on MacBook Pro (intel)

java version "1.4.2_09"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_09-239)
Java HotSpot(TM) Client VM (build 1.4.2-66, mixed mode)

thank you,
              dima
Re: help with PImage <-- noob Q
Reply #3 - Oct 8th, 2006, 5:14pm
 
Your error is generated by version 115. Download 118.
Code:

PImage testImage;
int i;

testImage=createImage(100, 100, RGB);
for(i = 0; i < testImage.pixels.length; i++)
{
testImage.pixels[i] = color(0,0,0);
}

testImage.save("testMe.jpg");
Re: help with PImage <-- noob Q
Reply #4 - Oct 8th, 2006, 7:00pm
 
ah, yeah sorry, i forgot to mention i was running 118.

cheers,
tk
Re: help with PImage <-- noob Q
Reply #5 - Oct 8th, 2006, 7:47pm
 
Thank very much!

Switching to 118 totally worked.

Here's klean kode just in case people are looking for it:

Code:

//Test image creation and output


PImage testImage;
int i;

testImage=createImage(100, 100, RGB);

for(i=0; i<testImage.pixels.length; i++)
{
testImage.pixels[i] = color(255,0,0);
}

testImage.save("testMe.jpg");




one quesion that I still have about this little experiment:

Can I supress the window poping up behavior? Don't really needit here since I am writing out to a file.



thank you,
               dima
Page Index Toggle Pages: 1