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

#1

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();


	#ifndef TARGET_OPENGLES
	if(isVFlipped()){
		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.

6 Likes
#3

you saved my day

#4

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

#5

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