so, i want to take an inventory of a bunch of my pixels in an array, and loadPixels() seems to generate that array fine, but I can’t figure out how to read that data, much less use it with other code.
any idea how to convert it all into rgb values I (and other bits of code) can use? preferably en masse?
Color information is stored in what’s referred to as a packed 32-bit integer, representing alpha, red, green and blue. Processing provides convenience methods that allow you to extract both hsb and rgb color information:-
get(x, y); // returns a color value from pixel array at a coordinate
color c = get(x, y);
alpha(c);
red(c);
blue(c);
green(c)
hue(c);
saturation(c);
brightness(c);
Although if you want to do this efficiently you may need learn about bitwise operations.
You can use get to get the color at a particular x, y coordinates in the pixel array, the reference is your friend.
so I need to make a second array copying data from the first with get (x y) for each pixel rather than operating on the data in the loadPixels array. okay!
If you told us what you wanted to do with the colors we could help you more, it is quite possible you don’t need to do individual pixel manipulation at all, when you can do things like apply a filter to graphics object or blend. For crazy weird stuff someone might have already created a glsl filter you could use that’s probably a bit advanced.
reading the color data, modifying sounds with it. the sounds bit was pretty intuitive and the documentation got me where I was going up until the part where i might base something on the total amount of red in the left side of the image minus the amount of blue in the top right corner