Possible to manipulate pixels in an ofTexture?

Hi,

I’m wondering if it’s possible to manipulate the data in an ofTexture. I don’t see any methods for doing this, as in ofImage. Is the only way to convert the texture to an ofImage, manipulate it, then get the texture reference again?

Miles

The best option I could find in this case is having 2 seperate objects: 1 ofTexture and 1 ofPixels.

ofTexture texture;
ofPixels texturepixels;

//loading texture into ofPixels
ofLoadImage(texturepixels, "texturepath");

//processing the pixels
...

//put pixels into texture
texture.loadData(texturepixels.getPixels(), texturepixels.getWidth(), texturepixels.getHeight(), GL_RGBA);

Then you can process the pixels and invoke loadData again.

1 Like

Depending on what your goal is, this is often down with a shader and an FBO. The shader might read and process the pixels from the texture and then render those modified pixels to an FBO or another texture.

1 Like

Thanks for the help @Rancs and @bakercp. :slight_smile: