Wrong color saved when using ofImage.save jpeg after using ofImage.grabscreen within v0.10.0

version0.10.0, win10, visualstudio 2017

I tried screen capture.

ofImage image;
image.allocate(1080, 1920, OF_IMAGE_COLOR);
image.grabScreen(0, 0, 1080, 1920);
image.save("screenshot/tmp/last.jpg", OF_IMAGE_QUALITY_LOW);

As a result, the image was saved with R and B replaced with each other.
So I rewrote the code of ofGLRenderer.cpp.

void ofGLRenderer::saveScreen(int x, int y, int w, int h, ofPixels & pixels){
	int sh = getViewportHeight();

		y = sh - y;
		y -= h; // top, bottom issues
	auto pixelFormat = OF_PIXELS_BGRA;

change this.

auto pixelFormat = OF_PIXELS_RGB;

Then, this problem was solved.


you saved my day

Thank you, a life saver. Maybe consider for a Pull Request?

No, but I would be happy if you do it.
Because I don’t have GitHub account yet.

This worked for me as well. Thanks! Has this been posted to some way @skvj @takayuki?

I came across this thread because of the same issue, which still seems to exist in v.0.11.0. I figured out another workaround without having to modify the framework. Hope somebody finds this useful!

ofImage img;
string imgPath = "somepath/";
img.grabScreen( 0, 0, ofGetWidth(), ofGetHeight() );
ofPixels & pixels = img.getPixels();
pixels.swapRgb();   // fix inverted R and B channels
string pic = imgPath+"screenshot.jpg";
ofSaveImage(pixels, pic, OF_IMAGE_QUALITY_BEST);