[OpenGL] 获取画布背景的位图数据
来源:互联网 发布:算法工程师可以自学吗 编辑:程序博客网 时间:2024/04/30 17:42
用OpenGL绘制好画面后 可以将画面数据保存成位图
本文给出一个获取位图数据的函数:
// get data of canvas rendered with OpenGL// note : need to call delete[] for *pDatabool CaptureOpenGL(int& nWidth, int& nHeight, int& nPitch, BYTE** pData){static GLenum s_Format = GL_BGRA_EXT;static int s_nBytePerPixel = 4; // 4Byte : because pixel format is GL_BGRA_EXTnWidth = nHeight = nPitch = 0;*pData = NULL;GLint aViewport[4];glGetIntegerv(GL_VIEWPORT, aViewport);int width = aViewport[2];int height = aViewport[3]; if ((width * height) <= 0)return false;int pitch = width * s_nBytePerPixel;int len = pitch * height; BYTE* pBuffer = new BYTE[len];if (!pBuffer)return false; glPixelStorei(GL_PACK_ALIGNMENT, 1);glPixelStorei(GL_PACK_ROW_LENGTH, 0);glPixelStorei(GL_PACK_SKIP_ROWS, 0);glPixelStorei(GL_PACK_SKIP_PIXELS, 0);GLenum lastBuffer;glGetIntegerv(GL_READ_BUFFER, (GLint*)&lastBuffer);glReadBuffer(GL_FRONT);glReadPixels(0, 0, width, height, s_Format, GL_UNSIGNED_BYTE, pBuffer);glReadBuffer(lastBuffer); // reset value of alpha channel with 255. because sometimes the value is 0, such as CS1.6 CWindowTool::ResetAlpha(pBuffer, len, 255); // this function should be completed by yourselfnWidth = width;nHeight = height;nPitch = pitch;*pData = pBuffer;return true;}
1 0
- [OpenGL] 获取画布背景的位图数据
- 获取单色位图指定坐标的数据
- 位图背景的编辑框
- 位图背景的编辑框
- 位图的去背景显示
- OpenGL的位图和图像
- OpenGL中位图的操作
- opengl 中 位图的操作
- OPENGL的位图和图象
- 根据BITMAPINFO获取位图数据
- GetObject 和 GetBitmapBits 获取位图数据的区别
- Bitmap类中getPixels()方法介绍--获取位图的数据
- opengl位图
- OpenGL--位图
- 对话框的基本美化(背景位图和位图按钮)
- 画一个透明背景的位图
- MFC笔记 位图背景窗体的实现
- bmp位图和OpenGL的像素操作
- 扫地机器人排行 2017最新扫地机器人排行榜曝光
- 现金贷
- Linux系统中如何下载软件
- HTTP500内部服务器错误
- 数组
- [OpenGL] 获取画布背景的位图数据
- Js读取select多选的几种方法
- js调试IE兼容性
- self.和_的区别(self和下划线的区别)
- Hadoop学习之网络爬虫+分词+倒排索引实现搜索引擎案例
- 3月份网站项目开发总结
- CSDN博客专栏申请方法
- linux用户切换后显示-bash-4.1$
- CoreImage滤镜效果