ofImage grabScreen distorting colours

Hi Everyone,

I have been running some old code that I previously wrote for v0.9.8, in v0.11.0, and have noticed some issues around the use ofImage.grabScreen(), ofImage.resize() and ofImage.getPixels().

When I grab the screen using ofImage.grabScreen() and then resize it using ofImage.resize(), the colours are getting distorted. It seems like red and blue have been swapped. Also, the image is cropped/corrupted towards the bottom (see example below).

I’ve isolated the issue in an example project (based on emptyExample) which has the following code:

void ofApp::setup(){
void ofApp::draw(){
    image.draw(0, 0);
void ofApp::keyReleased(int key){
    ofImage imageResized;
    imageResized.grabScreen(0, 0, 678, 1024);
    imageResized.resize(424, 640);

This is the resulting resized image (after doing ofImage.grabScreen() and ofImage.resize()):

(The original is here: https://unsplash.com/photos/FsXq3xu72bs)

I’d appreciate any ideas about what might be going wrong or how I can fix this.


if you don’t call resize are the colors ok?

Yes, if I don’t call resize the colours are OK. Also, it’s only happening after doing a grabScreen. If I just load an image, then resize it, the colours are fine. (In my actual code I’m using grabScreen to get the output from a shader.)

Not sure if it matters but I’m doing this on a Mac (10.14).

this sounds like a bug, can you open an issue on github?

Thanks. I’ve opened a new issue on GitHub: https://github.com/openframeworks/openFrameworks/issues/6528

You can change the line 1917 of “ofGLRenderer.cpp”.

auto pixelFormat = OF_PIXELS_RGBA;

Thanks. That works for the example code I outlined above but not for my original problem which uses grabScreen() to get the output from a shader.