如何创建位图(在C中)?
发布时间:2020-12-16 09:25:28 所属栏目:百科 来源:网络整理
导读:我想知道我如何能够从C导入和导出位图.我基本上不知道从哪里开始. 解决方法 内存中的位图看起来类似于: struct Image { int width; int height; char *data; // 1 byte per channel only 1 channel == grayscale}struct Image theImage;theImage.width = 10
我想知道我如何能够从C导入和导出位图.我基本上不知道从哪里开始.
解决方法
内存中的位图看起来类似于:
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. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |