本文主要是介绍BMP图象(灰度图)转化为二维数组的C语言实现(bmp2array),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
以下代码可以实现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)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!