Quantcast
Channel: openFrameworks - Latest posts
Viewing all articles
Browse latest Browse all 40524

Erase the pixels of an image with a custom shape

$
0
0

the easiest way to do this now is to use an fbo, clear it towhite and draw to it any shape as you r "eraser" in black. then set that fbo's texture as the alpha mask for the image you want toset parts as transparent:

//.h
ofImage img;
ofFbo fbo;

//setup
img.load(...);
fbo.allocate(img.getWidth(), img.getHeight(), GL_LUMINANCE)
img.getTexture().setAlphaMask(fbo.getTexture());
fbo.begin();
ofClear(255,255);
fbo.end();

//draw
fbo.begin();
ofSetColor(0);
//draw something
fbo.end();

ofSetColor(255);
img.draw();

Viewing all articles
Browse latest Browse all 40524

Trending Articles