如何绘制从glReadPixels捕获的屏幕截图到wxWidgets对话框/面板
How to draw screenshot captured from glReadPixels to wxWidgets dialog/panel
我有一个OpenGL窗口和一个wxWidget对话框。我想把OpenGL镜像到对话框。所以我要做的是:
- 捕获opengl的截图
- 显示在wxwidgets对话框中。
任何想法?
更新:这就是我目前如何使用glReadPixels(我也暂时使用FreeImage保存到BMP文件,但我希望文件保存被删除,如果有办法直接通道到wxImage)
// Make the BYTE array, factor of 3 because it's RBG.
BYTE* pixels = new BYTE[ 3 * width * height];
glReadPixels(0, 0, width, height, GL_RGB, GL_UNSIGNED_BYTE, pixels);
// Convert to FreeImage format & save to file
FIBITMAP* image = FreeImage_ConvertFromRawBits(pixels, width, height, 3 * width, 24, 0x0000FF, 0xFF0000, 0x00FF00, false);
FreeImage_Save(FIF_BMP, image, "C:/test.bmp", 0);
// Free memory
delete image;
delete pixels;
// Add Image Support for all types
wxInitAllImageHandlers();
BYTE* pixels = new BYTE[ 3 * width * height];
glReadPixels(0, 0, width, height, GL_RGB, GL_UNSIGNED_BYTE, pixels);
// width height pixels alpha
wxImage img(with, height, pixels, NULL); // I am not sure if NULL is permitted on the alpha channel, but you can test that yourself :).
// Second method:
wxImage img(width, heiht, true);
img.SetData(pixels);
你现在可以使用图像显示,保存为jpg png bmp任何你喜欢的。如果只是在对话框中显示,你不需要将其保存到硬盘上,当然,你可以这样做。然后在堆上创建图像。http://docs.wxwidgets.org/stable/wx_wximage.html wximagector
希望有所帮助
相关文章:
- Winapi:屏幕截图未显示在窗口中
- 截取屏幕截图后程序卡住
- C++鼠标单击时的屏幕截图不起作用
- GTKMM:拍摄绘图区域的屏幕截图?
- 有没有办法使用 ofstream 保存屏幕截图?
- 如何使用 DX11 截取屏幕截图?
- avcodec_receive_packet错误(gdi 屏幕截图 + ffmpeg)
- C++屏幕截图 - 如何读取位图?
- 使用QT C 屏幕截图
- 如何将屏幕截图位图转换为 cv::Mat
- QT自动保存使用命名模板的屏幕截图
- C 屏幕截图
- BMP的完整屏幕截图.与块状和保存有关的问题
- 使用OpenCV和C++在按键上截取网络摄像头源的屏幕截图
- DirectX 部分屏幕截图
- 截取屏幕截图,分析它,然后删除它
- WXWIDGETS应用于WXStaticBitMap时,屏幕截图将大部分图像留为空白
- 屏幕截图桌面DirectX C /QT
- 从另一个桌面捕获屏幕截图
- 如何绘制从glReadPixels捕获的屏幕截图到wxWidgets对话框/面板