Saving frames with transparent background?

Hello all, is there a way to save a frame with transparent background? I never managed to do this in Processing, and scared that OpenFrameworks will be as challenging. ofFrameSave() saves frames with grey background by default.

Thank you

If you have a RGBA image, I believe you can ofSaveImage and set the filename to something.png, it’ll keep transparency (haven’t checked recently but this worked for me at some point).

Note that you need to grab from a RGBA ofFbo to ofPixels (readToPixels) and then save it. If you call ofSaveFrame it may be that you’re grabbing RGB and not alpha.

You can draw to ofFbo whatever you want and afterwards save it to png file.
Here is a simple code:


		ofFbo fbo;
		fbo.allocate(img.getWidth(), img.getHeight(), GL_RGBA);  // GL_RGBA is important

		ofClear(255, 255, 255, 0); // 0 is important
		img.draw(0, 0);

		ofPixels pix;
		ofSaveImage(pix, "outImg.png", OF_IMAGE_QUALITY_BEST);

Both replies above solved it for me. The only thing left is to figure out how to save individual frames as images… chuckleplant you are right, ofSaveFrame saves as RGB, not alpha.

This is not working. I will let you know if I figure this out.
ofSaveImage(pix, “outImg”+counter+".png", OF_IMAGE_QUALITY_BEST);

Try to use ofToString(counter)

@Louisa I think that you have replied to this topic in another post :wink:

yes, the conversation ended in post Convert int to char

so sorry!!!