本来是一件很简单的事情,就是将View上使用OpenGL画出来的数据生成图片让其实现打印的功能,我们知道MFC提供打印的接口是不支持OpenGL的(至少我不清楚),必须将它转成GDI再画在Print的pDC上. OpenGL一直都有一个函数名字叫:glReadPixels,它能read a block of pixels from the frame buffer,但是谁都没想到它竟然转换成CImage竟然是这样的规则. http://www.opengl.org/sdk/docs/man/xh
uchar *pImg=(uchar *)CI.GetBits();//得到CImage数据区地址 ps=img.ptr<uchar>(i); void MatToCImage( Mat &mat, CImage &cImage) { //create new CImage int width = mat.cols; int height = mat.rows; int channels = mat.channels(); cImage.Destroy(); //clear c