以下代码可以实现BMP灰度图到二维数组的转换
#include <stdio.h>
#define get ch=getc(in)
#define getdw ch=getc(in);ch=getc(in);ch=getc(in);ch=getc(in)
int chabiao(FILE *fp,unsigned char color);
int main(int argc, char *argv[])
{
FILE * in ,*out;
int j,l,k,a,cout,length,width,Alength,offset,ofs;
unsigned long i,filesize;
unsigned char ch,infile[10],outfile[]="$tmp.txt",flip[800];
unsigned char temp,tempR,tempG,tempB,newtemp;
//unsigned int ch;
printf("input bmp filename:");
scanf("%s",infile);
if((in=fopen(infile,"rb"))==NULL)
{
printf("can't open ");
exit(0);
}
if((out=fopen(outfile,"w"))==NULL)
{
printf("cann't open");
exit(0);
}
ch=getc(in);
printf("this is a :%c
BMP图象(灰度图)转化为二维数组的C语言实现(bmp2array)
最新推荐文章于 2024-08-16 07:32:48 发布
这段C语言代码实现了将BMP灰度图像转换为二维字符数组。通过读取BMP文件并解析其头部信息,将像素值写入输出文件,最终得到一个表示图像数据的二维数组。
摘要由CSDN通过智能技术生成