|
Author |
Topic: nullpointer exception on new BImage(w,h) (Read 496 times) |
|
elout
|
nullpointer exception on new BImage(w,h)
« on: Oct 10th, 2003, 6:46pm » |
|
this gives a me a nullpointer exception Code: // p5 v.0065 BImage a; void setup() { size(200, 200); BImage a= new BImage(32,32); } void loop() { for (int i=0;i<32*32;i++) { a.pixels[i]=(int) random(255); } image(a, 0, 0, width, height); } |
| although this works Code: // p5 v.0065 void setup() { size(200, 200); } void loop() { BImage a= new BImage(32,32); for (int i=0;i<32*32;i++) { a.pixels[i]=(int) random(255); } image(a, 0, 0, width, height); } |
|
|
|
|
|
arielm
|
Re: nullpointer exception on new BImage(w,h)
« Reply #1 on: Oct 11th, 2003, 12:56am » |
|
not a bug in processing this time, it's because you declare "a" as a global variable, but inside setup(), you assign a value to a local variable, also named "a" (but not the same one!) solution: inside setup(), remove "BImage" before "BImage a =..."
|
« Last Edit: Oct 11th, 2003, 12:57am by arielm » |
|
Ariel Malka | www.chronotext.org
|
|
|
|