当前位置:首页 » 编程语言 » c语言读取bmp图片
扩展阅读
webinf下怎么引入js 2023-08-31 21:54:13
堡垒机怎么打开web 2023-08-31 21:54:11

c语言读取bmp图片

发布时间: 2022-05-05 14:35:36

Ⅰ 用c语言读取24位位图bmp文件

可以使用C语言标准函数库中的fopen、fseek、fclose等系列函数来打开bmp位图文件,以及进行相应的处理,下面是一个demo,仅供参考。以下代码在vc6.0中编译通过。


#include<stdio.h>
#include<stdlib.h>
#//ThebmpFileHeaderlengthis14
#defineBM19778//TheASCIIcodeforBM
/*Testthefileisbmpfileornot*/
voidbmpFileTest(FILE*fpbmp);
/**/
voidbmpHeaderPartLength(FILE*fpbmp);
/**/
voidBmpWidthHeight(FILE*fpbmp);
//getr,g,bdata
voidbmpDataPart(FILE*fpbmp);
//
voidbmpoutput(FILE*fpout);
unsignedintOffSet=0;//
longwidth;//TheWidthoftheDataPart
longheight;//TheHeightoftheDataPart
unsignedcharr[2000][2000],output_r[2000][2000];
unsignedcharg[2000][2000],output_g[2000][2000];
unsignedcharb[2000][2000],output_b[2000][2000];
intmain(intargc,char*argv[])
{
/*Openbmpfile*/
unsignedchar*fp_temp;
FILE*fpbmp;
FILE*fpout;
fpbmp=fopen("1.bmp","rb");
if(fpbmp==NULL)
{
printf("Openbmpfailed!!! ");
return1;
}
fpout=fopen("out.bmp","wb+");
if(fpout==NULL)
{
printf("Openout.bmpfailed!!! ");
return1;
}

bmpFileTest(fpbmp);//Testthefileisbmpfileornot
bmpHeaderPartLength(fpbmp);//GetthelengthofHeaderPart
BmpWidthHeight(fpbmp);//


//
fseek(fpbmp,0L,SEEK_SET);
fseek(fpout,0L,SEEK_SET);

fp_temp=(unsignedchar*)malloc(OffSet);
fread(fp_temp,1,OffSet,fpbmp);
fwrite(fp_temp,1,OffSet,fpout);

bmpDataPart(fpbmp);//Reservethedatatofile

/*


如果您想对图片进行处理,请您再这里插入处理函数!!!!!!!!!!!!!!!!!!

*/
bmpoutput(fpout);
fclose(fpbmp);
fclose(fpout);
return0;
}
voidbmpoutput(FILE*fpout)
{
inti,j=0;
intstride;
unsignedchar*pixout=NULL;

stride=(24*width+31)/8;
stride=stride/4*4;
pixout=(unsignedchar*)malloc(stride);

fseek(fpout,OffSet,SEEK_SET);
for(j=0;j<height;j++)
{
for(i=0;i<width;i++)
{
pixout[i*3+2]=output_r[height-1-j][i];
pixout[i*3+1]=output_g[height-1-j][i];
pixout[i*3]=output_b[height-1-j][i];
}
fwrite(pixout,1,stride,fpout);
}
}
voidbmpDataPart(FILE*fpbmp)
{
inti,j=0;
intstride;
unsignedchar*pix=NULL;
FILE*fpr;
FILE*fpg;
FILE*fpb;

if((fpr=fopen("bmpr.txt","w+"))==NULL)
{
printf("Failedtoconstructfilebmpr.txt.!!!");
exit(1);
}
if((fpg=fopen("bmpg.txt","w+"))==NULL)
{
printf("Failedtoconstructfilebmpg.txt.!!!");
exit(1);
}
if((fpb=fopen("bmpb.txt","w+"))==NULL)
{
printf("Failedtoconstructfilebmpb.txt.!!!");
exit(1);
}

fseek(fpbmp,OffSet,SEEK_SET);
stride=(24*width+31)/8;
stride=stride/4*4;
pix=(unsignedchar*)malloc(stride);

for(j=0;j<height;j++)
{
fread(pix,1,stride,fpbmp);
for(i=0;i<width;i++)
{
r[height-1-j][i]=pix[i*3+2];
g[height-1-j][i]=pix[i*3+1];
b[height-1-j][i]=pix[i*3];
output_r[height-1-j][i]=pix[i*3+2];
output_g[height-1-j][i]=pix[i*3+1];
output_b[height-1-j][i]=pix[i*3];
}
}
for(i=0;i<height;i++)
{
for(j=0;j<width-1;j++)
{
fprintf(fpb,"%4d",b[i][j]);
fprintf(fpg,"%4d",g[i][j]);
fprintf(fpr,"%4d",r[i][j]);
}
fprintf(fpb,"%4d ",b[i][j]);
fprintf(fpg,"%4d ",g[i][j]);
fprintf(fpr,"%4d ",r[i][j]);
}

fclose(fpr);
fclose(fpg);
fclose(fpb);

}
voidbmpFileTest(FILE*fpbmp)
{
unsignedshortbfType=0;

fseek(fpbmp,0L,SEEK_SET);//seek_set起始位置
fread(&bfType,sizeof(char),2,fpbmp);
if(BM!=bfType)
{
printf("Thisfileisnotbmpfile.!!! ");
exit(1);
}
}
/**/
voidbmpHeaderPartLength(FILE*fpbmp)
{
fseek(fpbmp,10L,SEEK_SET);
fread(&OffSet,sizeof(char),4,fpbmp);
printf("TheHeaderPartisoflength%d. ",OffSet);
}
/**/
voidBmpWidthHeight(FILE*fpbmp)
{
fseek(fpbmp,18L,SEEK_SET);
fread(&width,sizeof(char),4,fpbmp);
fseek(fpbmp,22L,SEEK_SET);
fread(&height,sizeof(char),4,fpbmp);
printf("TheWidthofthebmpfileis%ld. ",width);
printf("TheHeightofthebmpfileis%ld. ",height);
}

Ⅱ 如何在c语言 读取BMP图片的信息

使用opencv的库吧,安装很简单,处理图像的功能很强大
#include "cv.h"
#include "highgui.h"

int main( int argc, char** argv )
{
IplImage* pImg; //声明IplImage指针

//载入图像
if( argc == 2 &&
(pImg = cvLoadImage(“XXX.bmp”, 1)) != 0 )//这里bmp要放到工程文件夹下,否则写绝对路径,取像素值请用:pImg.ptr<Vec3b>(i)[j]
{
cvNamedWindow( "Image", 1 );//创建窗口
cvShowImage( "Image", pImg );//显示图像

cvWaitKey(0); //等待按键

cvDestroyWindow( "Image" );//销毁窗口
cvReleaseImage( &pImg ); //释放图像
return 0;
}

return -1;
}

Ⅲ 如何用C语言读取BMP图像

fopen() 以b+r方式打开.bmp文件,从offset sizeof(BITMAPFILEHEADER)处,
读取sizeof(BITMAPINFOHEADER)个byte到BITMAPINFOHEADER bih,
bih.biWidth 即是宽,bih.biHeight即是高。

Ⅳ 用C语言怎么读取BMP格式的图片

没有标准函数读。
需要根据BMP文件的结构定义,读出头部和每个颜色值。
struct
header
{
unsigned
short
int
bfType;
unsigned
int
bfSize;
unsigned
short
int
bfReserved1;
unsigned
short
int
bfReserved2;
unsigned
int
bfoffBits;
}__attribute__
((packed));
struct
tinfoheader
{
unsigned
int
biSize;
unsigned
int
biWidth;
unsigned
int
biHeight;
unsigned
short
int
biPlanes;
unsigned
short
int
biBitCount;
unsigned
int
biCompression;
unsigned
int
biSizeImage;
unsigned
int
biXPelsPerMeter;
unsigned
int
biYPelsPerMeter;
unsigned
int
biClrUsed;
unsigned
int
biClrImportant;
}__attribute__
((packed));

Ⅳ 怎样用c语言实现BMP读存

直接用fread读取就可以。你得知道bmp的格式,头文件存放的信息,读出出来就知道文件的大小,分辨率,大小端等。在读取每一位的颜色信息。注意bmp是按行倒叙存取,还有注意bmp有字节对齐的。

Ⅵ c语言,怎样读取一个BMP图片

#ifndef IMAGE_H
#define IMAGE_H
void image_info(FILE* file);
void image_save(FILE *file);
void image_gray();
void image_binarization();
void image_opposite();
void image_channel(); //抽取RGB通道
void image_bright();//改变图像亮度

typedef struct BMP
{
//14字节
unsigned short bfType; //文件标识 2字节 必须为BM
unsigned int bfSize; //文件大小 4字节
unsigned short bfReserved1; //保留,每字节以"00"填写 2字节
unsigned short bfReserved2; //同上 2字节
unsigned int bfOffBits; //记录图像数据区的起始位置(图象数据相对于文件头字节的偏移量)。 4字节

//40字节
unsigned int biSize; //表示本结构的大小 4字节
int biWidth; //位图的宽度 4字节
int biHeight; //位图的高度 4字节
unsigned short biPlanes; //永远为1 , 2字节
unsigned short biBitCount; //位图的位数 分为1 4 8 16 24 32 2字节
unsigned int biCompression; //压缩说明 4字节
unsigned int biSizeImage; //表示位图数据区域的大小以字节为单位 4字节
int biXPelsPerMeter; //用象素/米表示的水平分辨率 4字节
int biYPelsPerMeter; //用象素/米表示的垂直分辨率 4字节
unsigned int biClrUsed; //位图使用的颜色索引数 4字节
unsigned int biClrImportant; //对图象显示有重要影响的颜色索引的数目 4字节

} BMP;

int line_byte;
unsigned char *imagedata;
extern BMP bmp;
extern int line_byte;
extern unsigned char *imagedata;
#endif

//image_rw.c文件

#include<stdio.h>
#include<stdlib.h>
#include"image.h"

void image_info(FILE *file)
{

int times=3; //输入文件名次数。
char bmp_name[10]; //文件名

printf("\nplease enter a file name for reading:");
do
{
if (times<3)
{
printf("\nplease enter a file name for reading again:");
}
fflush(stdin);
gets(bmp_name);
//printf("\n%s",bmp_name);
file=fopen(bmp_name,"rb+"); //打开一个文件进行读写操作。
--times;
if (file==NULL)
{
printf("\nerror opening %s for reading! ",bmp_name);
}
else
{
break;
}
}
while(times!=0);

if (times==0)
{
printf("\nsorry, shutdown!");
exit(1);
}

//读取图像信息

fseek(file,0L,0); //读取图像文件类型
fread(&bmp,sizeof(BMP),1,file);
printf("\n bmp tpye: %u",bmp.bfType);
printf("\n bmp size: %u",bmp.bfSize);
printf("\n bmp reserved1: %u",bmp.bfReserved1);
printf("\n bmp reserved2: %u",bmp.bfReserved2);
printf("\n bmp offBits: %u",bmp.bfOffBits);

printf("\n bmp bisize: %u",bmp.biSize);
printf("\n bmp biWidth: %d",bmp.biWidth);
printf("\n bmp biHeight: %d",bmp.biHeight);
printf("\n bmp biplans: %u",bmp.biPlanes);
printf("\n bmp biBitCount: %u",bmp.biBitCount);
printf("\n bmp biCompression: %u",bmp.biCompression);
printf("\n bmp biSizeImage: %u",bmp.biSizeImage);
printf("\n bmp biXPelsPerMeter: %d",bmp.biXPelsPerMeter);
printf("\n bmp biYPelsPerMeter: %d",bmp.biYPelsPerMeter);
printf("\n bmp biClrUsed: %u",bmp.biClrUsed);
printf("\n bmp biClrImportant: %u\n",bmp.biClrImportant);

line_byte=(bmp.biWidth*bmp.biBitCount/8+3)/4*4; //获得图像数据每行的数据个数
//printf("dfsa%u",bmp.line_byte);
//bmp.imagedata=NULL;
imagedata=(unsigned char*)malloc(bmp.biSizeImage);

fseek(file,(long)bmp.bfOffBits,0);
fread(imagedata,sizeof(unsigned char),bmp.biSizeImage,file);

fclose(file);
}

//保存图像
void image_save(FILE *file)
{
int times=3; //输入文件名次数。
char bmp_name[10]; //文件名
//int i; //记录数据区个数

printf("\nplease enter a file name for writeing:");
do
{
if (times<3)
{
printf("\nplease enter a file name for writeing again:");
}
fflush(stdin);
gets(bmp_name);
printf("\n%s",bmp_name);
file=fopen(bmp_name,"wb+"); //打开一个文件进行读写操作。
--times;
if (file==NULL)
{
printf("\nerror opening %s for writing",bmp_name);
}
else
{
break;
}
}
while(times!=0);

if (times==0)
{
printf("\nsorry, shutdown!");
exit(1);
}

//写文件头
printf("\n%s",bmp_name);
fseek(file,0L,0); //图像文件类型
fwrite(&(bmp.bfType),sizeof(short),1,file);
printf("\n bmp tpye: %d",bmp.bfType);

fseek(file,2L,0); //图像文件大小
fwrite(&(bmp.bfSize),sizeof(int),1,file);
printf("\n bmp size: %d",bmp.bfSize);

fseek(file,6L,0); //图像文件保留字1
fwrite(&(bmp.bfReserved1),sizeof(short),1,file);
printf("\n bmp reserved1: %d",bmp.bfReserved1);

fseek(file,8L,0); //图像文件保留字2
fwrite(&(bmp.bfReserved2),sizeof(short),1,file);
printf("\n bmp reserved2: %d",bmp.bfReserved2);

fseek(file,10L,0);//数据区的偏移量
fwrite(&(bmp.bfOffBits),sizeof(short),1,file);
printf("\n bmp offBits: %d",bmp.bfOffBits);

fseek(file,14L,0);//文件头结构大小
fwrite(&(bmp.biSize),sizeof(int),1,file);
printf("\n bmp bisize: %d",bmp.biSize);

fseek(file,18L,0);//图像的宽度
fwrite(&(bmp.biWidth),sizeof(int),1,file);
printf("\n bmp biWidth: %d",bmp.biWidth);

fseek(file,22L,0);//图像的高度
fwrite(&(bmp.biHeight),sizeof(int),1,file);
printf("\n bmp biHeight: %d",bmp.biHeight);

fseek(file,24L,0);//图像的面数
fwrite(&(bmp.biPlanes),sizeof(short),1,file);
printf("\n bmp biplans: %d",bmp.biPlanes);

fseek(file,28L,0);//图像一个像素的字节数
fwrite(&(bmp.biBitCount),sizeof(short),1,file);
printf("\n bmp biBitCount: %d",bmp.biBitCount);

fseek(file,30L,0);//图像压缩信息
fwrite(&(bmp.biCompression),sizeof(short),1,file);
printf("\n bmp biCompression: %d",bmp.biCompression);

fseek(file,34L,0);//图像数据区的大小
fwrite(&(bmp.biSizeImage),sizeof(int),1,file);
printf("\n bmp biSizeImage: %d",bmp.biSizeImage);

fseek(file,38L,0);//水平分辨率
fwrite(&(bmp.biXPelsPerMeter),sizeof(int),1,file);
printf("\n bmp biXPelsPerMeter: %d",bmp.biXPelsPerMeter);

fseek(file,42L,0);//垂直分辨率
fwrite(&(bmp.biYPelsPerMeter),sizeof(int),1,file);
printf("\n bmp biYPelsPerMeter: %d",bmp.biYPelsPerMeter);

fseek(file,46L,0);//颜色索引数
fwrite(&(bmp.biClrUsed),sizeof(int),1,file);
printf("\n bmp biClrUsed: %d",bmp.biClrUsed);

fseek(file,50L,0);//重要颜色索引数
fwrite(&(bmp.biClrImportant),sizeof(int),1,file);
printf("\n bmp biClrImportant: %d\n",bmp.biClrImportant);

fseek(file,(long)(bmp.bfOffBits),0);
fwrite(imagedata,sizeof(unsigned char),bmp.biSizeImage,file);

fclose(file);
}

//pixProcess.c文件

#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include"image.h"

//灰度化
void image_gray()
{
int i,j;
unsigned char tmp;
for (i=0;i<bmp.biHeight;i++)
{
for (j=0;j<line_byte/3;j++)
{
tmp=0.11*(*(imagedata+i*line_byte+j*3+0))+0.59*(*(imagedata+i*line_byte+j*3+1))+0.3*(*(imagedata+i*line_byte+j*3+2));
imagedata[i*line_byte+j*3+0]=tmp;
imagedata[i*line_byte+j*3+1]=tmp;
imagedata[i*line_byte+j*3+2]=tmp;
//printf("\nnidsfh%d %d",i,j);
}
}
}

//二值化

void image_binarization()
{
int i,j;
for (i=0;i<bmp.biHeight;i++)
{
for (j=0;j<line_byte;j++)
{
if ((*(imagedata+i*line_byte+j))<128)
{
imagedata[i*line_byte+j]=0;
}
else
{
imagedata[i*line_byte+j]=255;
}
}
}
}

void image_opposite() //反相
{
int i,j;
for (i=0;i<bmp.biHeight;i++)
{
for (j=0;j<line_byte;j++)
{
imagedata[i*line_byte+j]=abs(255-imagedata[i*line_byte+j]);
}
}
}

void image_channel() //抽取RGB通道
{
int i,j;
char rgb;
printf("\nplease enter a char(r/g/b): ");
fflush(stdin);
scanf("%c",&rgb);
if (rgb=='b')
{
for (i=0;i<bmp.biHeight;i++)
{
for (j=0;j<line_byte/3;j++)
{
imagedata[i*line_byte+3*j+1]=0;
imagedata[i*line_byte+3*j+2]=0;
}
}
}
else if(rgb=='g')
{
for (i=0;i<bmp.biHeight;i++)
{
for (j=0;j<line_byte/3;j++)
{
imagedata[i*line_byte+3*j]=0;
imagedata[i*line_byte+3*j+2]=0;
}
}
}
else
{
for (i=0;i<bmp.biHeight;i++)
{
for (j=0;j<line_byte/3;j++)
{
imagedata[i*line_byte+3*j]=0;
imagedata[i*line_byte+3*j+1]=0;
}
}
}

}

void image_bright()//改变图像亮度
{
int level;
int i,j;
printf("\n please enter the level of brightness[-255 to 255] :");
fflush(stdin);
scanf("%d",&level);
for (i=0;i<bmp.biHeight;i++)
{
for (j=0;j<line_byte;j++)
{
if (level>=0)
{

if ((imagedata[i*line_byte+j]+level)>255)
imagedata[i*line_byte+j]=255;
else
imagedata[i*line_byte+j]+=level;
}
else
{
if ((imagedata[i*line_byte+j]-abs(level))<0)
imagedata[i*line_byte+j]=0;
else
imagedata[i*line_byte+j]+=level;
}

}
}
}

//void image_create() //创建一幅24位BMP图像文件。
//{

//main.c文件

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<conio.h>
#include"image.h"

BMP bmp;

int main()
{
FILE *file=NULL;
int choose;
char gono;
do
{
image_info(file); //imagedata已经分配了动态内存,但是没有释放

printf("\n 1.image_opposite");
printf("\n 2.image_gray");
printf("\n 3.image_binarization");
printf("\n 4.image_channel");
printf("\n 5.image_brightness");
//printf("6.image_opposite");
//printf("7.image_opposite");

printf("\nchoose your options:");
fflush(stdin);
scanf("%d",&choose);
switch(choose)
{

case 1:
image_opposite();
image_save(file);
free(imagedata);
break;
case 2:
image_gray();
image_save(file);
free(imagedata);
break;
case 3:
image_binarization();
image_save(file);
free(imagedata);
break;
case 4:
image_channel();
image_save(file);
free(imagedata);
break;
case 5:
image_bright();
image_save(file);
free(imagedata);
break;
default:
printf("\n wrong choose!");

}

printf("\nlet's go on?(y/n):");
fflush(stdin);
scanf("%c",&gono);
if (gono=='n')
{
printf("\nbye bye!");
break;
}
}
while(1);

return 0;
}

Ⅶ C语言 读取BMP文件

读取文件方法:先定义一个int类型的文件描述符变量,再用open函数(适合在Unix或Linux环境下,若是在windows环境下应先定义一个FILE类型的指针变量,再调用fopen函数)打开所要读取的BMP文件即可。如果你要更改BMP文件的颜色,那么就看你对BMP格式的图片的存储原理知道多少了,bmp是无损压缩图片的一种算法,一般是由图片头部,文件头部,颜色表等组成,要改变颜色,就需要改变颜色表中的内容,当然由于BMP算法在不断改进,其过程和组成部分可能有变化,上面的仅是一般情况。

Ⅷ 怎么样在c语言中显示bmp图片,我要完整正确的程序,急!

lz 你好


c语言要显示bmp位图需要使用win32的api , 具体如下:

BOOLBitBlt(
HDChdcDest,//位图显示目标设备环境中
intnXDest,//位图显示在客户区的x坐标
intnYDest,//位图显示在客户区的y坐标
intnWidth,//位图显示的宽度
intnHeight,//位图显示的长度
HDChdcSrc,//源设备环境(包含需要显示的bmp位图)
intnXSrc,//在当前位图中显示的开始x位置
intnYSrc,//在当前位图中显示的开始y位置
DWORDdwRop//映射模式
);


以下是源代码:

//显示bmp位图
#include<windows.h>
#include"resource.h"

LRESULTCALLBACKWndProc(HWND,UINT,WPARAM,LPARAM);
voidDrawBrick();

intWINAPIWinMain(HINSTANCEhInstance,
HINSTANCEhPrevInstance,
PSTRszCmdLine,
intiCmdShow)
{
static TCHAR szAppName[]=TEXT("Bmp");
HWND hwnd;
MSG msg;
WNDCLASS wndclass;

wndclass.style =CS_HREDRAW|CS_VREDRAW;
wndclass.lpfnWndProc =WndProc;
wndclass.cbClsExtra =0;
wndclass.cbWndExtra =0;
wndclass.hInstance =hInstance;
wndclass.hIcon =LoadIcon(NULL,IDI_APPLICATION);
wndclass.hCursor =LoadCursor(NULL,IDC_ARROW);
wndclass.hbrBackground =(HBRUSH)GetStockObject(WHITE_BRUSH);
wndclass.lpszMenuName =NULL;
wndclass.lpszClassName =szAppName;

if(!RegisterClass(&wndclass))
{
MessageBox(NULL,TEXT("ThisprogramrequiresWindowsNT!"),
szAppName,MB_ICONERROR);
return0;
}

hwnd=CreateWindow(szAppName,
TEXT("BmpDemo"),
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
754,
566,
NULL,
NULL,
hInstance,
NULL);

ShowWindow(hwnd,iCmdShow);
UpdateWindow(hwnd);

while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}

returnmsg.wParam;
}

LRESULTCALLBACKWndProc(HWNDhwnd,UINTmessage,WPARAMwParam,LPARAMlParam)
{
static HBITMAP hBitmap; //位图句柄标示位图
staticint cxBitmap,cyBitmap; //位图的长宽
BITMAP bitmap;
HDC hdc,hdcMem;
HINSTANCE hInstance;
PAINTSTRUCT ps;

switch(message)
{
caseWM_CREATE:
hInstance=((LPCREATESTRUCT)lParam)->hInstance; //获取窗口的实例句柄

hBitmap=LoadBitmap(hInstance,MAKEINTRESOURCE(IDB_BITMAP1)); //将位图加载到内存中

GetObject(hBitmap,sizeof(BITMAP),&bitmap);

cxBitmap=bitmap.bmWidth;//获取位图的长
cyBitmap=bitmap.bmHeight;//获取位图的宽

return0;

caseWM_PAINT:
hdc=BeginPaint(hwnd,&ps);

hdcMem=CreateCompatibleDC(hdc);//创建一个兼容于hdc设备环境描述表的hdcMem主要是用于在内存中截图
SelectObject(hdcMem,hBitmap);//将位图选到hdcMem中

BitBlt(hdc,-1,-1,cxBitmap,cyBitmap,hdcMem,0,0,SRCCOPY);//绘制bmp位图

DeleteDC(hdcMem);
EndPaint(hwnd,&ps);

return0;

caseWM_DESTROY:
DeleteObject(hBitmap);
PostQuitMessage(0);

return0;
}

returnDefWindowProc(hwnd,message,wParam,lParam);
}



程序运行效果:

Ⅸ 如何用C语言读取BMP,GIF,JEP图像

1.
如果你是用VC编译的话,你可以加头文件#include<afx.h>然后在工程-->设置那,Microsoft基础类,选择“使用MFC作为静态链接库”。
之后就可以用BTYE这个类型了。。。
2.
其实BTYE就是 unsigned char ;
所以直接用unsigbed char 就行了。
3.
typedef BYTE (unsigned char);
上面三种任选一种。