C / C ++图像加载 [英] C/C++ Image Loading
问题描述
我工作的一个游戏引擎,我太胆小的编写多种格式的图像装载机,所以我的问题是这样的:有一个抽象的图像载入库加载镜像文件?我只需要加载文件,然后使用一个像素阵列图示他们到屏幕上。
I'm working on a game engine and I'm too much of a wuss to write image loaders for multiple formats, so my question is this: Is there an abstracted image loading library to load image files? I just need to load files then splat them on to the screen using an array of pixels.
推荐答案
我总是 CIMG 风扇。这是非常容易使用。另一位用户喜欢<一个href=\"http://stackoverflow.com/questions/3255074/how-to-process-jpg-images-with-c-c-most-easily/3255133#3255133\">the回答为好。我会后我张贴在回答相同的例子,所以你可以看到它是访问像素和尺寸的信息多么容易。
I'm always a fan of CImg. It's very easy to use. Another user liked the answer as well. I'll post the same example I posted in the answer so you can see how easy it is to access pixels and dimension info.
CImg<unsigned char> src("image.jpg");
int width = src.width();
int height = src.height();
unsigned char* ptr = src.data(10,10); // get pointer to pixel @ 10,10
unsigned char pixel = *ptr;
这篇关于C / C ++图像加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!