ofTexture to ofImage


Hi @ all,

  1. I am loading a png file
  2. copieng the manipulated pixels to a ofTexture
  3. Than i want to save that image, but therefore i need an ofImage

By the way, is there a good way how to manipulate an ofImage Pixels? i tried the getPixel reference and thought that it changes will affect the original image, but it does nothing.

i am a bit confused at the moment, hope to hear some hints tomorrow morning :slight_smile:

nice evening.


Problem almost solved :wink:


I’d copy the pixels to an ofImage rather than an ofTexture. Every ofImage has an ofTexture (unless you tell it not to use one). So you can upload the pixels to the image using setPixels(), then update() to load them to the texture for drawing, and saveImage() for saving to a file.


I cant make setPixels() work:

src/testApp.cpp|116|error: ‘ofImage’ has no member named ‘setPixels’|

I actually try to get 4 smaller picture put together to one big saved image.



I think it’s ofImage::setColor, you have to iterate over all pixels. The info above is probably from an old version of OF


For those googling and looking for a solution how to save an ofTexture to a file (via ofImage):

ofPixels pixels;

ofImage image;

where texture is an ofTexture instance.

This also works if you want to save the contents of an Fbo to a file. Just switch out the texture reference with the Fbo one:

ofPixels pixels;

ofImage image;


How to copy fontTexture to ofImage?