@lethalrush wrote:
Hi, I am trying to save a screenshot to disk using an FBO but the background is always transparent. I’m sure I’m missing something simple.
Here is the code. (Note that I want to save screenshot at higher resolution than the screen, so grabScreen / ofSaveScreen won’t work for me- at least i don’t think so!)
void ofApp::setup(){ gui.setup(); screenshotFbo.allocate(3840, 2160); }
void ofApp::draw(){ if ( isCurrentlySavingScreenshot ) { screenshotFbo.begin(); ofClear(255, 255, 255, 0); } ofDrawCircle(ofGetWidth() / 2, ofGetHeight() / 2, seqRadius); if ( isCurrentlySavingScreenshot ) { // capture 4K screenshot! ofPixels pixels; screenshotFbo.readToPixels(pixels); ofImage img; img.setFromPixels(pixels); ofSaveImage(img, "screenshot " + ofGetTimestampString() + ".png"); isCurrentlySavingScreenshot = false; screenshotFbo.end(); screenshotFbo.draw(0, 0); } gui.draw(); }
void ofApp::keyPressed(int key){ if ( key == 'x' ) { // screenshot! isCurrentlySavingScreenshot = true; } }
Posts: 2
Participants: 2