PDA

View Full Version : Printing OpenGL objects



ToddAtWSU
11-09-2006, 04:44 AM
I have been working with printing an OpenGL object for a couple of weeks now. I am again inside a Qt application using a QGLWidget and QPrinter to print out my OpenGL objects. I have only been able to get the image to print out or save to a file as black and white. Whatever has color prints out as black and whatever is white stays white. There is no gray-scaling or anything happening, either solid black or solid white. I have been able to easliy print when I use 24-bit RGB mode, but this time I am trying to use 8-bit color indexing mode. I am thinking it is in the color indexing because if Qt converts the image from 8-bit to 24-bit before printing, there shouldn't be a real problem with that. But if it expects the colors to be in a color indexed mode, could that cause some problems. To print I am just using QGLWidget::renderPixmap (http://doc.trolltech.com/4.1/qglwidget.html#renderPixmap) to get the OpenGL into a pixmap which I then print to the printer by setting a QPainter object to my printer and call QPainter::drawPixmap (http://doc.trolltech.com/4.1/qpainter.html#drawPixmap-7) which sends the rendered pixmap to the printer or file. But they always come out as black and white in my 8-bit color indexed mode. The printer is a color-printer and I can save the files as PostScript and JPEG. Thanks for all your help and if I can provide anymore information, please let me know what you need to know. Thanks!

mikael_aronsson
11-16-2006, 12:13 AM
I have no idea on this it all depends on how Qt does the printing, I think you should try on the Qt forum and see if they know more about it.

ToddAtWSU
11-16-2006, 03:20 AM
I discovered that I needed to use a QImage over a QPixmap because of my 8-bit image with color indexing. I also needed to set a color table for the QImage. So I called glReadPixels for my screen and then created a QImage the same size of my QGLWidget. I then set up the QImage's color table to be identical to my color map. I then set each and every pixel, one-by-one to construct the QImage. I was then able to print or save this image correctly. Thanks for your help but since nobody really knew I thought I would post my solution.