Ways to copy pixels from ofFbo to ofImage?

Hi, I’m trying to copy pixels from ofFbo to ofImage.
I know one way to do this is as below.

ofPixels pixels;
fbo.getTexture().readToPixels(pixels);
img.setFromPixels(pixels); 

But unfortunately this way is problematic on iOS.
https://forum.openframeworks.cc/t/ofimage-setfrompixels-causes-crash-on-ios

So I’m looking for other ways to copy pixels from ofFbo to ofImage.
Is there any alternative way to do the same?
Thank you!

do you need Texture?
If not. You can try…

fbo.readToPixels(pixels);
1 Like

Thank you. That fixed the problem.

also depending what you are using this for, downloading the texture into pixels is pretty slow. if you want to put it into an ofImage to save it that would be a case where it makes sense but then it’s better to do:

fbo.readToPixels(pixels);
ofSaveImage("image.png", pixels);

that way you are not reuploading the pìxels to a texture again

if all you want is to have another copy of the image to draw it then, using a second fbo and drawing the first one into it is much faster than reading the pixels back and reuploading them again

1 Like