grabScreen only taking a fraction of the screen

So I have a small menu in my app with a “Take screenshot” button. The button callback has these 2 functions attached to it:

void ofApp::PrintScreenTakenCallback(string param){
    printScreenTakenCallback(0, 0, ofGetWindowWidth(), ofGetWindowHeight(), param);
}

void ofApp::printScreenTakenCallback(int x, int y, int width, int height, string param){
    ofImage screenImg;
    screenImg.allocate(width, height, OF_IMAGE_COLOR);
    screenImg.grabScreen(x,y,width,height);
    screenImg.saveImage(param + ".png");
}

This seems to be aright but this code is currently grabbing 1/4 of the image and blowing it up to fill the dimension of the image o.0

You can try “ofGetWidth()”, “ofGetHeight()” instead of "ofGetWindowWidth() ", "ofGetWindowHeight() " if you don’t mind something.

.
addtional comment
Did you checked actual value of " ofGetWindowWidth() " , " ofGetWindowHeight() " ?

example : cout << ofGetWindowWidth() << " , " << ofGetWindowHeight() << endl;

So, You can check actual value on console message.
It is correct of your app window size?

your app was possible to taken wrong value from your OS. I think.
(expect of reason : Retina Resolution , High DPI Desktop … etc)

I hope it helps.

I tried giving grabScreen the same dimensions I use on the ofSetupOpenGL and “ofGetWidth()”, “ofGetHeight()” , but I get the same result. If it matters, I’m running this in a Linux Mint machine. I’ll try to get a Windows one and check whether it makes a difference

Found a fix. It would seem that the issue is the code of ofGLRenderer.cpp.

Solution for reference: Problem with size of reproduced full-size grabScreen screenshot?

2 Likes