还是朋友,我这里有一段c的例子,你看看,我觉得能满足我的要求(我的图像是黑白的),不过,怎么把它翻译成delphi呢:
int MakeBmp(unsigned char pImgData[128][128], char *filename)
{
unsigned char head[1078]={
//file header
0x42,0x4d,//file type
0x36,0x44,0x00,0x00, //file size***
0x00,0x00, //reserved
0x00,0x00,//reserved
0x36,0x4,0x00,0x00,//head byte***
//infoheader
0x28,0x00,0x00,0x00,//struct size
0x80,0x00,0x00,0x00,//map width***
0x80,0x00,0x00,0x00,//map height***
0x01,0x00,//must be 1
0x08,0x00,//color count***
0x00,0x00,0x00,0x00, //compressionx
0x00,0x40,0x00,0x00,//data size***
0x00,0x00,0x00,0x00, //dpix
0x00,0x00,0x00,0x00, //dpiy
0x00,0x00,0x00,0x00,//color usyumed
0x00,0x00,0x00,0x00,//color important
};
int i;
int j=0;
for (i=54;i<1078;i=i+4) //调色板数据
{
head=head[i+1]=head[i+2]=j;
head[i+3]=0;
j++;
}
CFile ff;
int succ=ff.Open(filename,CFile::modeCreate | CFile::modeWrite );
if( !succ )
return ERR_OPERATION;;//
ff.Write( head,1078*sizeof(char) );
ff.Close();
succ=ff.Open(filename,CFile::shareDenyWrite | CFile::modeReadWrite );
if( !succ )
return ERR_OPERATION;//;
for( i=0;i<128; i++ )
{
ff.Seek( 1078*sizeof(char)+(127-i)*128,CFile::begin );
ff.Write( &pImgData[0],128*sizeof(char) );
}
ff.Close();
return FR_OK;//;
}