もっと効率的な宣言があれば教えていただきたいです。
#include <stdio.h>
#include <string.h>
typedef struct type_BMP{
char H00[(2+1)*2]; //bfType 'As Integer 'ファイルタイプ
char H02[(2+1)*4]; //bfSize 'As Long 'ファイルサイズ[byte]
char H06[(2+1)*2]; //bfReserved1 'As Integer '予約領域1
char H08[(2+1)*2]; //bfReserved2 'As Integer '予約領域2
char H0A[(2+1)*4]; //bfOffBits 'As Long 'ファイル先頭から画像データまでのオフセット[byte]
char H0E[(2+1)*4]; //biSize 'As Long '情報ヘッダサイズ[byte]
char H12[(2+1)*4]; //biWidth 'As Long '画像の幅[ピクセル]
char H16[(2+1)*2]; //biHeight 'As Long '画像の高さ[ピクセル]
char H1A[(2+1)*2]; //biPlanes 'As Integer 'プレーン数
char H1C[(2+1)*2]; //biBitCount 'As Integer '色ビット数[bit]
char H1E[(2+1)*4]; //biCompression 'As Long '圧縮形式
char H22[(2+1)*4]; //biSizeImage 'As Long '画像データサイズ[byte]
char H26[(2+1)*4]; //biXPixPerMeter 'As Long '水平解像度[dot/m]
char H2A[(2+1)*4]; //biYPixPerMeter 'As Long '垂直解像度[dot/m]
char H2E[(2+1)*4]; //biClrUsed 'As Long '格納パレット数[使用色数]
char H32[(2+1)*4]; //biCirImportant 'As Long '重要色数
}BMP;
void BMP_set(BMP *);//,int,char);
/* 4バイトデータをリトルエンディアンに変換する */
#define ULONG_B2L(a) \
(unsigned long) \
( \
((unsigned long)(*((unsigned char *)a )) << 24) | \
((unsigned long)(*((unsigned char *)a + 1)) << 16) | \
((unsigned long)(*((unsigned char *)a + 2)) << 8) | \
((unsigned long)(*((unsigned char *)a + 3)) ) \
)
/* 2バイトデータをリトルエンディアンに変換する */
#define USHORT_B2L(a) \
(unsigned long) \
( \
((unsigned long)(*((unsigned char *)a + 2)) << 8) | \
((unsigned long)(*((unsigned char *)a + 3)) ) \
)
int main(int argc,char *argv[]){//設定値上書き用
BMP outFile;
BMP_set(&outfile);//,argc,*argv[0]);
//argc==where_exe+row
printf("%d",ULONG_B2L(16));
}
void BMP_set(BMP *outfile){//,int argc,char argv0){//初期値設定用
strncpy(outfile->H00,"42 4d",sizeof(outfile->H00));
//strcpy(file->H0A,"36 00");
}