huy
huy

Reputation: 4904

Save image data from glReadPixels to JPEG

I have a piece of code that uses glReadPixels to capture byte images from frame buffer (code below), now how do I save that into a jpeg file?

char* pdata = new char[width * height * 4]; // 4 is for RGBA
glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, pdata);

Upvotes: 1

Views: 2830

Answers (1)

Nicol Bolas
Nicol Bolas

Reputation: 474126

I would suggest downloading libjpeg. Or any one of a number of image processing libraries. DevIL (which hasn't been updated recently, but certainly works), FreeImage, etc.

Upvotes: 4

Related Questions