Windsoarer
30th April 2009, 21:59
The problem I face is really simple : I'd like to implement some code to capture an OpenGl display on the screen to an image file.
It should be something like
Step 1 : NbBytes = size.width() * size.height() * screen_pixel_format/8;
Step 2 : uchar *pPixelData = new uchar[NbBytes];
Step 3 : glReadPixels(0,0,size.width(),size.height(),GL_BGR _EXT,GL_UNSIGNED_BYTE,pPixelData);
Step 4 : QImage Image(pPixelData, size.width(),size.height(), NbBytes/ size.height(), QImage::Format_RGB888);
Step 5 : Image.save(FileName);
Step 0 would be to find out what is the screen's pixel format, and which pixel format OpenGl is using : 8, 16, or 24 bits ? Is there way to get this information in Qt ?
Thanks
It should be something like
Step 1 : NbBytes = size.width() * size.height() * screen_pixel_format/8;
Step 2 : uchar *pPixelData = new uchar[NbBytes];
Step 3 : glReadPixels(0,0,size.width(),size.height(),GL_BGR _EXT,GL_UNSIGNED_BYTE,pPixelData);
Step 4 : QImage Image(pPixelData, size.width(),size.height(), NbBytes/ size.height(), QImage::Format_RGB888);
Step 5 : Image.save(FileName);
Step 0 would be to find out what is the screen's pixel format, and which pixel format OpenGl is using : 8, 16, or 24 bits ? Is there way to get this information in Qt ?
Thanks