简体   繁体   English

使用OpenGL写入图像文件

[英]Using OpenGL to write to an image file

I'm just curious if there is a way to use OpenGL to write pixel data to an external JPEG/PNG/some other image file type (and also create an image to write the data to if one does not already exist). 我只是想知道是否有一种方法可以使用OpenGL将像素数据写入外部JPEG / PNG /其他图像文件类型(如果还不存在,还可以创建图像将数据写入其中)。 I couldn't really find anything on the subject. 我真的找不到关于这个问题的任何东西。 My program doesn't really make use of openGL at all otherwise, I just need something that can write out images. 我的程序实际上根本不使用openGL,我只需要一些可以写出图像的东西。

Every image "put into" or "taken from" OpenGL is in a rather raw pixel format. 每个“放入”或“取自” OpenGL的图像都是原始像素格式。 OpenGL does neither have functionality for file I/O nor for handling of sophisticated image formats like eg BMP, JPEG or PNG, as that is completely out of its scope. OpenGL既没有文件I / O功能,也没有处理复杂的图像格式(例如BMP,JPEG或PNG)的功能,因为这完全超出了它的范围。 So you will have to look for a different library to manage that and if this was the only reason you considered OpenGL, then you don't need it at all. 因此,您将不得不寻找一个不同的库来进行管理,如果这是您考虑使用OpenGL的唯一原因,那么您根本就不需要它。

A very simple and easy to use one (and with an interface similar to OpenGL) would be DevIL . DevIL是一个非常简单易用的工具(并且具有类似于OpenGL的接口)。 But many other larger frameworks for more complex tasks, like Qt (GUI and OS) or OpenCV (image processing) have functionality for image loading and saving. 但是,许多其他更大型的框架可以处理更复杂的任务,例如Qt (GUI和OS)或OpenCV (图像处理)具有图像加载和保存的功能。 And last but not least many of the individual formats, like JPEG or PNG usually also have small official open-source libraries for handling their respective files. 最后但并非最不重要的是,许多单独的格式(例如JPEG或PNG)通常也具有用于处理其各自文件的小型官方开源库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM