我想知道我如何能够从C导入和导出位图.我基本上不知道从哪里开始. 内存中的位图看起来类似于: struct Image { int width; int height; char *data; // 1 byte per channel only 1 channel == grayscale}struct Im
struct Image {
int width;
int height;
char *data; // 1 byte per channel & only 1 channel == grayscale
}
struct Image theImage;
theImage.width = 100;
theImage.height = 100;
theImage.data = malloc(sizeof(char) * theImage.width * theImage.height);
至于导入和导出,有一些非常简单的文件格式,请看一下BMP.对于更复杂的格式,最好使用已有的库.
大多数框架已经有最常见的文件格式的加载/保存方法.如果你正在寻找一个轻量级的库,你可以看看SDL.
