当前位置: 技术问答>linux和unix
将一个BMP文件转化为二进制文件,并且存在一个数组中
来源: 互联网 发布时间:2017-04-11
本文导语: 请问大家,怎样子将一个BMP图片用程序转化为一个文本文件,并且存在一个数组中,我知道这个有些程序可惜实现,但现在我的需要自己写个程序完成它,麻烦各位帮忙哦! | 之前在做uboot里...
请问大家,怎样子将一个BMP图片用程序转化为一个文本文件,并且存在一个数组中,我知道这个有些程序可惜实现,但现在我的需要自己写个程序完成它,麻烦各位帮忙哦!
|
之前在做uboot里的splash image,需要将bmp文件转换为一个数组,下面是我写的一个,亲测可用,生成文件之后自己加上数组的名字就好,用法 ./xx.out xx.bmp xx.c
#include
#include
#include
#include
#include
#include
#include
int main(int argc, char *argv[])
{
int i, fd, ret, fd_out;
unsigned char buf[16] = "0";
unsigned char buf_out[6] = "0";
if (argc != 3) {
printf("usage: ./bmp_2_c a.bmp a.cn");
exit(-1);
}
fd = open(argv[1], 0666, O_RDWR);
if (fd
#include
#include
#include
#include
#include
#include
#include
int main(int argc, char *argv[])
{
int i, fd, ret, fd_out;
unsigned char buf[16] = "0";
unsigned char buf_out[6] = "0";
if (argc != 3) {
printf("usage: ./bmp_2_c a.bmp a.cn");
exit(-1);
}
fd = open(argv[1], 0666, O_RDWR);
if (fd