C++代码求翻译C#代码
unsigned char* LoadBMP(FILE * img)
{
unsigned long bBMPFormat = 0;
unsigned long bData = 0;
Dword size = 0;
unsigned char *data;
fseek(img,10,SEEK_SET);
fread(&bData,4,1,img);
fseek(img,28,SEEK_SET);
fread(&bBMPFormat,2,1,img);
fseek(img,0,SEEK_END);
size = ftell(img) - bData;
if(bBMPFormat==24)
{
data = (unsigned char*)malloc(size);
fseek(img,bData,SEEK_SET);
fread(data,size,1,img);
}
else if(bBMPFormat==8)
{
data = (unsigned char*)malloc(size*3);
unsigned char* pdata = data;
unsigned char *ColorBoard = (unsigned char*)malloc(1024);
fseek(img,54,SEEK_SET);
fread(ColorBoard,1024,1,img);
unsigned char *ColorIndex = (unsigned char*)malloc(size);
fseek(img,1078,SEEK_SET);
fread(ColorIndex,size,1,img);
for(int i=0;i<size;i++)
{
*(pdata) = *(ColorBoard+(*ColorIndex)*4);
*(pdata+1) = *(ColorBoard+1+(*ColorIndex)*4);
*(pdata+2) = *(ColorBoard+2+(*ColorIndex)*4);
ColorIndex++;
pdata=pdata+3;
}
}
return data;
}
但他如同如同如果人人