简体   繁体   English

如何使用boost /标准库在C ++中读/写图像?

[英]How can I read/write an image in C++ using just boost/standard library?

Is this possible? 这可能吗? It doesn't matter what format the image is, but I have to be able to open it, read pixel data into some sort of array, create a new image using a modified set of pixel data. 图像的格式无关紧要,但我必须能够打开它,将像素数据读入某种数组,使用一组经过修改的像素数据创建新图像。

Thanks! 谢谢!

Boost.GIL有一个很好的视频教程 ,向您展示如何以非常通用但高效的方式读/写和处理原始图像数据。

I suggest CImg . 我建议CImg This library is extremely easy to use. 该库非常易于使用。 You only have to include a header file in your code and set some parameters when compiling and that's it! 您只需在代码中包含头文件,并在编译时设置一些参数即可! I've used CImg with MingW and GCC. 我已经将CImg与MingW和GCC一起使用。

You need code to encode and decode the formats you want to support. 您需要使用代码对要支持的格式进行编码和解码。 You can do this yourself (not really ideal/practical,) you can embed encoding/decoding libraries (like libpng, for example,) or you can embed image libraries like DevIL. 你可以自己做(不是很理想/实用)你可以嵌入编码/解码库(例如libpng),或者你可以嵌入像DevIL这样的图像库。

Boost seems to include some sort of image access library known as Boost.GIL . Boost似乎包含某种称为Boost.GIL的图像访问库。 I really don't know much about it, though. 不过,我真的不太了解它。

I suggest the TARGA image format for your needs. 我建议您使用TARGA图像格式。 You just read/write a few values in a header, then the rest is an uncompressed array of RGBA pixel data. 您只需在标头中读取/写入一些值,其余的是RGBA像素数据的未压缩数组。 You won't even need Boost! 你甚至不需要Boost!

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

相关问题 如何使用 C++ boost 库创建带有 write_json 和 read_josn 的通用 function - How to create a generic function with write_json and read_josn using C++ boost library 如何仅使用标准库将 C++ 对象写入文件 - How to write C++ objects to files using only the standard library 如何编写一个采用通用C ++标准库容器的模板函数 - How can I write a template function that takes a generic C++ standard library container 我应该如何使用 C++ 中的 Boost 库编写相同的 XML 设计? - How should I write the same XML design using the Boost Library in C++? 如何在C ++中使用Boost库的Rtree? - How can I use the Rtree of the Boost Library in C++? 如何使用 SFML 库加载 C++ 中的图像? - How can I load an image in C++ using SFML library? Boost.Filesystem 和 C++ 标准文件系统库有多相似? - How similar are Boost.Filesystem and the C++ standard filesystem library? 如何在C ++标准库中启用哈希? - How can I enable hash in C++ Standard Library? 如何在 C++ 中生成 UUID,而不使用 boost 库? - How can I generate UUID in c++, without using boost library? C ++如何在不使用标准库中的随机播放功能的情况下随机播放矢量? - C++ How can I shuffle a vector without using the shuffle functions from the standard library?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM