[SOLVED] Copy ofImage with alpha mask not working


If I apply an alpha mask to an ofImage, when I make a copy of it the mask is not applied to the copy. Is there a way to keep the transparent pixels in the copy? A bit like “applying” the mask for good?

I’m trying to save some frames from a video source masked with ofxCv::ContourFinder polylines in a vector. This is my code (simplified):

vector<ofImage> images; // where I want to store the images
ofImage img; // used for masking
ofVideograbber vidgrabber; // video source
ofFbo mask; // the mask

// draw a shape with ofxCv countour finder polylines 
// -- will save you that part

img.setFromPixels(vidgrabber.getPixels()); // copy current camera frame
img.getTexture().setAlphaMask(mask.getTexture()); // apply mask
images.push_back(img); // add to vector


I found a workaround. Draw the masked image in another FBO and add the result of that to the vector.