glReadPixels and save to image

Posted by Julius Petraška on Stack Overflow See other posts from Stack Overflow or by Julius Petraška
Published on 2012-10-09T15:30:18Z Indexed on 2012/10/09 15:37 UTC
Read the original article Hit count: 280

Filed under:
|
|

I have app, where user drags and drops image, and it is being redrawn with OpenGL for some aviable processing. Everything works. And when user wants to save his image it works like that:

glReadPixels -> NSBitmapImageRep -> NSData -> Write to file

This works too. Almost. With some images it is not working as it should work.

For example:

.png

when I open and save this image: enter image description here

I get:
enter image description here

And if I open and save this image: enter image description here

I get:
enter image description here

.jpg

If I open and save:
enter image description here

I get:
enter image description here

And when I open and save:
enter image description here

I get:
enter image description here

So sometimes images saves badly. Why is it happening?

© Stack Overflow or respective owner

Related posts about objective-c

Related posts about osx