i have some question about OF 007,. I have seen a new class ofPixels. is it like “pixels” in Processing? the method set is the same in Processing?
thanke you in advance

yes i think so, although pixels in processing is for getting the pixels from the screen right?

ofPixels is a class to stores the pixels from things like an ofImage, ofVideoGrabber/Player…

so you can do:

ofImage img;  
ofPixels pix = img.getPixelsRef();  
ofColor c = pix.getColor(x,y);  

that is actually making a copy of the pixels in the ofImage, if you want to alter the original pixels in the image use ofPixelsRef instead

thank’s @arturo for the reply but i’was talking about this (in ofPixel.h):

void set(PixelType val);  
	void set(int channel,PixelType val);  

and in Processing:

set(x, y, color)  
set(x, y, image)  

or is similar to this in OF 0.07:

void setFromPixels(const PixelType * newPixels,int w, int h, int channels);  
	void setFromPixels(const PixelType * newPixels,int w, int h, ofImageType type);  

can you explain these ?
thanke you for your attention.

it’s been a long time since i don’t use processing so don’t know exactly what the methods you are pointing do, but i guess


is similar to setColor(x,y,color) in OF

set(x,y,image) puts an image in that position in the screen?

the all you have to do is create an ofImage and call draw(x,y)

void set(PixelType val); sets the same value in all the ofPixel contents, you can use it to set everything to 0 for example

void set(int channel,PixelType val); does the same but only for one channel, like set the red channel to 255

void setFromPixels(const PixelType * newPixels,int w, int h, int channels);

allows to pass an array of unsigned char to an ofPixels

now,it is all clear , thank’s for the answer! :slight_smile: