"intro to processing " Processing to eclipse
in
Integration and Hardware
•
8 months ago
Hi ,
I have been working my way through the tutorials with Eclipse. My compiler has thrown this error up -->>
Exception in thread "Animation Thread" java.lang.NullPointerException
at tutorial2.draw(tutorial2.java:36)
at processing.core.PApplet.handleDraw(PApplet.java:2142)
at processing.core.PGraphicsJava2D.requestDraw(PGraphicsJava2D.java:193)
at processing.core.PApplet.run(PApplet.java:2020)
at java.lang.Thread.run(Unknown Source)
I reckon the problem is pretty straight forward and that I am missing something obvious , Bellow is the code ..... has anyone come across this already ??
Would appreciate anyhelp
thanks
Steve.
import java.awt.color.ColorSpace;
import processing.core.*;
public class tutorial2 extends PApplet
{
PImage img = loadImage("Picture1.jpg");
public void setup()
{
//load the image and put it in a 400*400 box.
size(400,400);
}
public void draw()
{
//computer i would like to talk to the pixels
img.loadPixels();
//run through the picture Identifyign the RED : Green : Blue colours
for(int y = 0; y < height; y++)
{
for(int x = 0; x < width; x++)
{
int loc = x + y*width;
///these functions identify the colour involved
float r = red(img.pixels[loc]);
float g = green(img.pixels[loc]);
float b = blue(img.pixels[loc]);
//image processing would go here
//set the display pixel to the image pixel
pixels[loc] = color(r,g,b);
}
}
updatePixels();
}
}
1