Hi,
I want to use an array instead of an ArrayList, but I'm not sure if I got the manual right. Is it right that I must define the arrays number of elements in advance?
In the case of my script I know the maximum number of possible elements that could emerge. But I'm not sure if they will. So is it possible to set an arrays size to the maximum number of possible elements and if the array is not filled completly to trim it down to it's real size?
I'm new to Processing, so I hope this goes to the right board.
I'm adding pixels from an image array to an arrayList called pixel. My purpose is to sort all the pixels in a special way. After I've ensured where to place them in the img.pixels array I'm storring them in a arrayList called pixel (just because Processing doesn't seem to perform basic array operations like pop, push, slice, etc.).
pixel.add(where, img.pixels[x]);
First Question: Is it a problem if I leave some positions in the arrayList void? i.e.: [0] = 1, [1]= nothing in here, [2]=3 ... and so on... because the values don't come in a correct order from 0 to n. Processing isn't complaining about it, but I'm not sure.
I'm trying to apply the arrayList pixel to the pixels array of my image. But neither the arraylist.toarray method nor img.pixels[x] = pixel.get(x); works. It tells me that I cant assign an object to an integer, which sounds logical to me.
Second Question: How do I convert a Object delivered by the get() Method into an integer?