BMP图象(灰度图)转化为二维数组的C语言实现(bmp2array)

这段C语言代码实现了将BMP灰度图像转换为二维字符数组。通过读取BMP文件并解析其头部信息,将像素值写入输出文件,最终得到一个表示图像数据的二维数组。
摘要由CSDN通过智能技术生成

以下代码可以实现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

评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值