We are about to switch to a new forum software. Until then we have removed the registration on this forum.
If i use loadPixels() in setup it's fine. If i use it in draw i get a IndexOutOfBoundsException: 0. Am i doing something wrong?
PImage img;
void setup() {
img = loadImage("test_02.png");
size(img.width, img.height, OPENGL);
// here it's fine
img.loadPixels();
}
void draw() {
image(img, 0, 0);
// here index out of bounds
//img.loadPixels();
text(frameRate, 20, 20);
}
Answers
yes.
move loadImage() after size() - the data paths don't get initialized until size() is called
size() should be the first thing in setup().
I always recommend to use
loadImage after size (since without size processing doesn't know the path)
maybe that has an impact on loadPixels ?
I am too late...
then you need to put the values for size in manually from the image
I used it like that so many times and it always worked. Anyway, i moved it after size but i still have the problem.
Here the image:
It's working fine for me @ Processing 2.0.2 w/ 64-bit OpenJDK 7.51 in Lubuntu 13.04!
hmm...
probably it's no good to do it 60 times per second anyway...
you should load it only when it changes
maybe set your memory higher in the preferences?
Mine is set to 1024 MiB btW! o->
Mine is set to 2048. If i set the framerate to 1 i still have the problem. I also made a small image of 512x256 but still the error. I'm on processing 2.1.2 on max os x 10.9.2.
Here is the complete log:
It only happens in OpenGL, i will report it as a issue on github.
Use Processing v2.0.3 for now! ;;)
Ok good to know. Why do you use 2.0.2 btw and not 2.1.2?
Only when I see a version where folks stop complaining about nasty bugs I take the courage to finally upgrade! ;)
Actually I coulda been using v2.0.3. But the diffs. are so lil' from v2.0.2 that I didn't bug to upgrade to! :P
I believe 2.03 was the most bugged for me (OpenGl speaking). My memory was always filling like a counter until it was out of memory.
95% I use JAVA2D! @-)
I think i will follow you with that :) https://github.com/processing/processing/issues/2494
p.s. codeanticode in case you ever watch this. I love the work you're doing and i'm amazed by the performance of processing with OpenGL!