/*写入注释*/
memcpy(ch, getfilename(bmpfile), sizeof(getfilename(bmpfile)));
wid = fileinfo.bmiHeader.biWidth;
hig = fileinfo.bmiHeader.biHeight;
sprintf(com, "/*The size is :%dX%d. The char is : %s.*/", wid, hig, ch);
fputs(com, fh_out);
putc(0x0d,fh_out);
putc('\n',fh_out);
/*写入数据*/
while (n<(infileLen-(int)file_head.bfOffBits))
{
putc('0',fh_out);
putc('X',fh_out);
c_in=getc(fh_in);
c=c_in;
c=(c>>4)&0x0f; //获取高四个BIT的内容
if (c<0x0a)
{
c+=0x30; //把符号转成数字
}
else
{
c+=0x37; //转成a到f
}
putc(c,fh_out);
c=c_in&0x0f; //获取低四个BIT内容
if (c<0x0a)
{
c+=0x30;
}
else
{
c+=0x37;
}
putc(c,fh_out);
putc(',',fh_out);
n++;
if (num++ % (fileinfo.bmiHeader.biWidth/8 + 1) ==0)
{
putc(0x0d,fh_out);
putc('\n',fh_out);
}
}
putc(0x0d,fh_out);
putc('\n',fh_out);
fclose(fh_in);
fclose(fh_out);
return 0;
}
int main(int argc, char* argv[])
{
WIN32_FIND_DATA fd;
if (argc>2)
{
printf("***************位图帮助***************\n");
printf("bmptofile [drive:][path][filename]");
return 1;
}
else if (argc == 2)
{
if (strchr(argv[1], '.')!=NULL)
{
bmp2headfile(argv[1], (char *)"font.h");
}
else //if (memcmp(argv[1], "\?", sizeof(argv[1])) == 0)
{
printf("***************位图帮助***************\n");
printf("bmptofile [drive:][path][filename]");
return 1;
}
}
else if (argc == 1)
{
HANDLE hd=::FindFirstFile((LPCTSTR)"*.bmp",&fd); //开始查找
if(hd==INVALID_HANDLE_VALUE)
{
printf("没有找到文件");
return 0;
}
bmp2headfile(fd.cFileName, (char *)"font.h");
while(FindNextFile(hd,&fd)) //继续查找
{
bmp2headfile(fd.cFileName, (char *)"font.h");
}
FindClose(hd);//关闭查找
}
return 0;
}
上一页 [1] [2] [3] [4]
责任编辑:cyth